JDK-6221045 : apt -print option shoud not print abstract modifier on interfaces or annotations
  • Type: Enhancement
  • Component: tools
  • Sub-Component: apt
  • Affected Version: 6
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2005-01-25
  • Updated: 2010-04-02
  • Resolved: 2006-03-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6 b75Fixed
Related Reports
Relates :  
Description
The apt -print option should not print the abstract modifier on interfaces and annotations.

###@###.### 2005-1-25 01:15:10 GMT

Comments
SUGGESTED FIX src/share/classes/com/sun/tools/apt/comp>sccs sccsdiff -r1.10 -r1.11 PrintAP.java ------- PrintAP.java ------- 10a11 > import static com.sun.mirror.declaration.Modifier.*; 29a31,35 > static Set<Modifier> EMPTY_ELIDES = Collections.emptySet(); > static Set<Modifier> INTERFACE_ELIDES = EnumSet.of(ABSTRACT); > static Set<Modifier> ENUM_ELIDES = EnumSet.of(FINAL, ABSTRACT); > static Set<Modifier> INTERFACE_MEMBER_ELIDES = EnumSet.of(ABSTRACT, PUBLIC, STATIC, FINAL); > 80c86 < printModifiers(d); --- > printModifiers(d, EMPTY_ELIDES); 102c108 < printModifiers(d); --- > printModifiers(d, ENUM_ELIDES); 117c123 < printModifiers(d); --- > printModifiers(d, INTERFACE_ELIDES); 131c137 < printModifiers(d); --- > printModifiers(d, INTERFACE_ELIDES); 145c151,153 < printModifiers(d); --- > printModifiers(d, > (d.getDeclaringType() instanceof InterfaceDeclaration)? > INTERFACE_MEMBER_ELIDES : EMPTY_ELIDES); 172c180,182 < printModifiers(d); --- > printModifiers(d, > (d.getDeclaringType() instanceof InterfaceDeclaration)? > INTERFACE_MEMBER_ELIDES : EMPTY_ELIDES); 185c195 < printModifiers(d); --- > printModifiers(d, EMPTY_ELIDES); 237c247 < printModifiers(parameter); --- > printModifiers(parameter, EMPTY_ELIDES); 258c268 < printModifiers(parameter); --- > printModifiers(parameter, EMPTY_ELIDES); 301c311 < private void printModifiers(Declaration d) { --- > private void printModifiers(Declaration d, Collection<Modifier> elides) { 305,306c315,316 < Collection<Modifier> mods = d.getModifiers(); < for(Modifier m: mods) { --- > > for(Modifier m: adjustModifiers(d.getModifiers(), elides) ){ 311c321 < private void printModifiers(ParameterDeclaration d) { --- > private void printModifiers(ParameterDeclaration d, Collection<Modifier> elides) { 314,315c324 < Collection<Modifier> mods = d.getModifiers(); < for(Modifier m: mods) { --- > for(Modifier m: adjustModifiers(d.getModifiers(), elides) ) { 318a328,339 > > private Collection<Modifier> adjustModifiers(Collection<Modifier> mods, > Collection<Modifier> elides) { > if (elides.isEmpty()) > return mods; > else { > Collection<Modifier> newMods = new LinkedHashSet<Modifier>(); > newMods.addAll(mods); > newMods.removeAll(elides); > return newMods; > } > } src/share/classes/com/sun/tools/javac/processing>sccs sccsdiff -r1.2 -r1.3 PrintingProcessor.java ------- PrintingProcessor.java ------- 85d84 < printDocComment(e); 87a87 > printDocComment(e); 97a98,112 > Element enclosing = e.getEnclosingElement(); > > // Don't print out the constructor of an anonymous class > if (kind == CONSTRUCTOR && > enclosing != null && > NestingKind.ANONYMOUS == > // Use an anonymous class to determine anonymity! > (new SimpleElementVisitor6<NestingKind, Void>() { > @Override > public NestingKind visitType(TypeElement e, Void p) { > return e.getNestingKind(); > } > }).visit(enclosing)) > return this; > 130,131d144 < defaultAction(e, true); < 133,141c146,151 < switch(kind) { < case ANNOTATION_TYPE: < writer.print("@interface"); < break; < default: < writer.print(kind.toString().toLowerCase()); < } < writer.print(" "); < writer.print(e.getSimpleName()); --- > > if (NestingKind.ANONYMOUS == e.getNestingKind()) { > // Print out an anonymous class in the style of a > // class instance creation expression rather than a > // class declaration. > writer.print("new "); 143c153,159 < printFormalTypeParameters(e); --- > // If the anonymous class implements an interface > // print that name, otherwise print the superclass. > List<? extends TypeMirror> interfaces = e.getInterfaces(); > if (!interfaces.isEmpty()) > writer.print(interfaces.get(0)); > else > writer.print(e.getSuperclass()); 145,153c161,177 < // Print superclass information if informative < if (kind == CLASS) { < TypeMirror supertype = e.getSuperclass(); < if (supertype.getKind() != TypeKind.NONE && < ((TypeElement)supertype.asElement()).getSuperclass().getKind() != TypeKind.NONE) < writer.print(" extends " + supertype); < } < < printInterfaces(e); --- > writer.print("("); > // Anonymous classes that implement an interface can't > // have any constructor arguments. > if (interfaces.isEmpty()) { > // Print out the parameter list from the sole > // constructor. For now, don't try to elide any > // synthetic parameters by determining if the > // anonymous class is in a static context, etc. > List<? extends ExecutableElement> constructors = > ElementFilter.constructorsIn(e.getEnclosedElements()); > > if (!constructors.isEmpty()) > printParameters(constructors.get(0)); > } > writer.print(")"); > } else { > defaultAction(e, true); 154a179,200 > switch(kind) { > case ANNOTATION_TYPE: > writer.print("@interface"); > break; > default: > writer.print(kind.toString().toLowerCase()); > } > writer.print(" "); > writer.print(e.getSimpleName()); > > printFormalTypeParameters(e); > > // Print superclass information if informative > if (kind == CLASS) { > TypeMirror supertype = e.getSuperclass(); > if (supertype.getKind() != TypeKind.NONE && > ((TypeElement)supertype.asElement()).getSuperclass().getKind() != TypeKind.NONE) > writer.print(" extends " + supertype); > } > > printInterfaces(e); > } 266c312 < case INTERFACE: // Fallthrough intentional --- > case INTERFACE: 275a322 > case FIELD: 279d325 < modifiers.remove(Modifier.ABSTRACT); 280a327,329 > modifiers.remove(Modifier.ABSTRACT); // only for methods > modifiers.remove(Modifier.STATIC); // only for fields > modifiers.remove(Modifier.FINAL); // only for fields 282a332 >
25-02-2006

EVALUATION A fine idea. ###@###.### 2005-1-25 01:15:10 GMT
25-01-2005