This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 270036

Summary: Class name change refactoring does not change class name in annotations or enums parameters
Product: java Reporter: bronek77 <bronek77>
Component: RefactoringAssignee: Svata Dedic <sdedic>
Status: RESOLVED FIXED    
Severity: normal CC: jlahoda
Priority: P2    
Version: 8.2   
Hardware: PC   
OS: Windows 7   
Issue Type: DEFECT Exception Reporter:

Description bronek77 2017-03-09 14:49:33 UTC
If a class is used as a parameter of an annotation - for example:

@PrepareForTest({ Business.class, Economic.class, Eclipse.class ...

- and the class name change refactoring is done, then the old class name remains as an annotation parameter (so - if I refactor 'Economic' class to be named 'Cheap', then the annotation will still have 'Economic' altough the rest of the class usages will be updated to use 'Cheap').  Projects do not compile, class name change must be done manually.

The same happens when the class is used as a parameter of an enum, example:
public enum something {
  INSTANCE_ONE(Something.class);
...
}
It's in maven projects.

This makes class name change refactoring a semi auto-manual process.
Comment 1 Svata Dedic 2017-03-24 16:53:24 UTC
Only happens if the renamed class name appears in implicit 'value' annotation member

I could not reproduce the enum parameter error; tried a class, or even enum's class itself - rename operation renamed such reference.
Comment 2 Svata Dedic 2017-03-27 08:10:02 UTC
The culrpit seems to be TreeUtilities.isSynthetic; it reports the A reference in @Annotation(A.class) as synthetic despite the tree is really present in the source; its parent (value = A.class) assignment is synthetic, but the child is real.

Lahvaci: is it desirable to return isSynthetic = true for such cases ?
Comment 3 Svata Dedic 2017-03-27 09:34:55 UTC
Should be fixed in jet-main#976b61fbb370
Comment 4 Quality Engineering 2017-03-30 01:44:55 UTC
Integrated into 'main-silver', will be available in build *201703300002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/976b61fbb370
User: Svata Dedic <sdedic@netbeans.org>
Log: #270036: extra handling for annotation implicit attribute added