Bug 270036 - Class name change refactoring does not change class name in annotations or enums parameters
Class name change refactoring does not change class name in annotations or en...
Status: RESOLVED FIXED
Product: java
Classification: Unclassified
Component: Refactoring
8.2
PC Windows 7
: P2 (vote)
: Dev
Assigned To: Svata Dedic
issues@java
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2017-03-09 14:49 UTC by bronek77
Modified: 2017-03-30 01:44 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo