Uploaded image for project: 'NetBeans'
  1. NetBeans
  2. NETBEANS-3747

Package rename causes bogus error

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 11.2
    • None
    • java - Refactoring
    • None

    Description

      How to reproduce:

      All defaults, hello world application as simple as possible.

      Menu|File|New Project|Java with Maven|Java Application|Finish
      Projects|New|java Class|NewClass|Finish

      [Alt+Insert]|Generate|Constructor

      Remove public from public NewClass()

      Add a method:

      void hello()

      { System.out.println("Hello"); }

      Save.

      [Ctrl+Shift+U] Create / Update Tests|JUnit|OK

      In the source packages tree, rename mavenproject1 to mavenproject2.
      Click button "refactor"

      The following warnings and errors were found. You can continue only with warnings.

      List or errors:

      Warning:
      Class "NewClassTest" within the same package is using feature "hello()" of class you want to move ("NewClass").

      Click "Refactor"

      That actually creates an import in the test class:

      import my.mavenproject2.NewClass;

      But the test class has 2 errors as can be expected:

      NewClass() is not public in NewClass; cannot be accessed from outside package

      hello() is not public in NewClass; cannot be accessed from outside package

      Rename the test package mavenproject1 to mavenproject2 to fix the error.

      NewClassTest does not have any more errors.

      The new import statement in the test class is now "Import From The Same Package".

      But the test package has a red badge "Contains files with errors."

      Attachments

        Activity

          People

            Unassigned Unassigned
            bht Bernard
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: