Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6354725

Custom APT options not separated into name/value

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 5.0
    • tools
    • apt
    • x86
    • windows_2000

      FULL PRODUCT VERSION :
      java version "1.5.0_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
      Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows 2000 [Version 5.00.2195]

      A DESCRIPTION OF THE PROBLEM :
      APT reserves command line options beginning with -A for use by annotation processors, and defines the syntax as -Aname=value.

      Using the AnnotationProcessorEnvironment, it should be possible to access all command line options and their respective values, using the Map returned by ape.getOptions(). For the standard options, this works, but for the custom ones, it doesn't!

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Create an annotation type "mypackage.Foo" and a Java class using it.
      2. Start apt, specifying the attached AnnotationProcessorFactory and providing the additional argument -AmyOption=myValue.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Output:
       '-AmyOption' => 'myValue'
      ACTUAL -
      Output:
       '-AmyOption=myValue' => 'null'

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package mypackage;

      import java.util.Arrays;
      import java.util.Collection;
      import java.util.Collections;
      import java.util.Set;

      import com.sun.mirror.apt.AnnotationProcessor;
      import com.sun.mirror.apt.AnnotationProcessorEnvironment;
      import com.sun.mirror.apt.AnnotationProcessorFactory;
      import com.sun.mirror.apt.AnnotationProcessors;
      import com.sun.mirror.declaration.AnnotationTypeDeclaration;

      public class TestAPF implements AnnotationProcessorFactory
      {
          public Collection<String> supportedOptions()
          {
              return Collections.emptySet();
          }

          public Collection<String> supportedAnnotationTypes()
          {
              return Collections.unmodifiableCollection( Arrays.asList( "mypackage.Foo" ) );
          }

          public AnnotationProcessor getProcessorFor( Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env )
          {
              for( String key : env.getOptions().keySet() )
              {
                  System.out.println(" '" + key + "' => '" + env.getOptions().get( key ) + "'" );
              }
              return AnnotationProcessors.NO_OP;
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Implementing a class that wraps the original AnnotationProcessorEnvironment, but parses the option map and generates the value entries for custom options.

            Unassigned Unassigned
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: