FULL PRODUCT VERSION :
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Linux hipnosi.net 2.4.27-2um #1 Sun Aug 8 09:45:02 UTC 2004 i686 i686 i386 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
http://java.sun.com/j2se/1.5.0/docs/guide/apt/mirror/com/sun/mirror/apt/AnnotationProcessorEnvironment.html#getOptions() says:
"Options are returned in the form of a map from option name (such as "-encoding") to option value."
However, when I pass -Afoo=bar on the command line, the map contains a key "-Afoo=bar", but no key "-Afoo".
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run apt with the processor factory given below.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Output should include
-Afoo
ACTUAL -
Output is
warning: Annotation types without processors: [java.lang.annotation.Inherited]
Options supplied:
-factory
-target
-Afoo=bar
save-parameter-names
-classpath
Visited Test
Visited AbstractBean
1 warning
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import com.sun.mirror.apt.AnnotationProcessor;
import com.sun.mirror.apt.AnnotationProcessors;
import com.sun.mirror.apt.AnnotationProcessorEnvironment;
import com.sun.mirror.apt.AnnotationProcessorFactory;
import com.sun.mirror.declaration.AnnotationTypeDeclaration;
import com.sun.mirror.declaration.ClassDeclaration;
import com.sun.mirror.declaration.FieldDeclaration;
import com.sun.mirror.declaration.MethodDeclaration;
import com.sun.mirror.declaration.Modifier;
import com.sun.mirror.declaration.TypeDeclaration;
import com.sun.mirror.type.TypeMirror;
import com.sun.mirror.type.VoidType;
import com.sun.mirror.util.SimpleDeclarationVisitor;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import static com.sun.mirror.declaration.Modifier.*;
import static com.sun.mirror.util.DeclarationVisitors.*;
import static java.util.Collections.*;
public class AddGetAndSetMethods implements AnnotationProcessorFactory {
private static final Collection<String> supportedAnnotations =
singleton ("Bean");
private static final Collection<String> supportedOptions =
singleton ("foo");
public Collection<String> supportedAnnotationTypes() {
return supportedAnnotations;
}
public Collection<String> supportedOptions () {
return supportedOptions;
}
public AnnotationProcessor getProcessorFor
(Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env) {
System.err.println ("Options supplied:");
for (String k : env.getOptions ().keySet ()) {
System.err.println (k);
}
return atds.isEmpty () ? AnnotationProcessors.NO_OP : new Processor (env);
}
public static class Processor extends SimpleDeclarationVisitor
implements AnnotationProcessor {
private final AnnotationProcessorEnvironment env;
public Processor (AnnotationProcessorEnvironment env) {
this.env = env;
}
public void process () {
for (TypeDeclaration typeDecl : env.getTypeDeclarations ()) {
typeDecl.accept (this);
}
}
public void visitClassDeclaration (final ClassDeclaration c) {
System.err.println ("Visited " + c);
}
} // end of class Processor
} // end of class AddGetAndSetMethods
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Use environment variables instead.
###@###.### 2005-04-20 21:47:22 GMT
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Linux hipnosi.net 2.4.27-2um #1 Sun Aug 8 09:45:02 UTC 2004 i686 i686 i386 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
http://java.sun.com/j2se/1.5.0/docs/guide/apt/mirror/com/sun/mirror/apt/AnnotationProcessorEnvironment.html#getOptions() says:
"Options are returned in the form of a map from option name (such as "-encoding") to option value."
However, when I pass -Afoo=bar on the command line, the map contains a key "-Afoo=bar", but no key "-Afoo".
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run apt with the processor factory given below.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Output should include
-Afoo
ACTUAL -
Output is
warning: Annotation types without processors: [java.lang.annotation.Inherited]
Options supplied:
-factory
-target
-Afoo=bar
save-parameter-names
-classpath
Visited Test
Visited AbstractBean
1 warning
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import com.sun.mirror.apt.AnnotationProcessor;
import com.sun.mirror.apt.AnnotationProcessors;
import com.sun.mirror.apt.AnnotationProcessorEnvironment;
import com.sun.mirror.apt.AnnotationProcessorFactory;
import com.sun.mirror.declaration.AnnotationTypeDeclaration;
import com.sun.mirror.declaration.ClassDeclaration;
import com.sun.mirror.declaration.FieldDeclaration;
import com.sun.mirror.declaration.MethodDeclaration;
import com.sun.mirror.declaration.Modifier;
import com.sun.mirror.declaration.TypeDeclaration;
import com.sun.mirror.type.TypeMirror;
import com.sun.mirror.type.VoidType;
import com.sun.mirror.util.SimpleDeclarationVisitor;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import static com.sun.mirror.declaration.Modifier.*;
import static com.sun.mirror.util.DeclarationVisitors.*;
import static java.util.Collections.*;
public class AddGetAndSetMethods implements AnnotationProcessorFactory {
private static final Collection<String> supportedAnnotations =
singleton ("Bean");
private static final Collection<String> supportedOptions =
singleton ("foo");
public Collection<String> supportedAnnotationTypes() {
return supportedAnnotations;
}
public Collection<String> supportedOptions () {
return supportedOptions;
}
public AnnotationProcessor getProcessorFor
(Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env) {
System.err.println ("Options supplied:");
for (String k : env.getOptions ().keySet ()) {
System.err.println (k);
}
return atds.isEmpty () ? AnnotationProcessors.NO_OP : new Processor (env);
}
public static class Processor extends SimpleDeclarationVisitor
implements AnnotationProcessor {
private final AnnotationProcessorEnvironment env;
public Processor (AnnotationProcessorEnvironment env) {
this.env = env;
}
public void process () {
for (TypeDeclaration typeDecl : env.getTypeDeclarations ()) {
typeDecl.accept (this);
}
}
public void visitClassDeclaration (final ClassDeclaration c) {
System.err.println ("Visited " + c);
}
} // end of class Processor
} // end of class AddGetAndSetMethods
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Use environment variables instead.
###@###.### 2005-04-20 21:47:22 GMT
- duplicates
-
JDK-6345271 apt tool does not parse -A options correctly
- Closed
-
JDK-6354725 Custom APT options not separated into name/value
- Closed
-
JDK-6471011 AnnotationProcessorEnvironment does not parse options
- Closed