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

apt tool does not parse -A options correctly

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_04"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
      Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode, sharing)

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

      A DESCRIPTION OF THE PROBLEM :
      In the documentation of APT, the tool is suppose to parse the command line arguments and construct a map of options. This map should include all processor-specific options (the -A options).
      The syntax for -A option is -A[key][=value]. The problem occurs with options in the form of -Akey=value - the following code is suppose to return the value:

      AnnotationProcessorEnvironment env (obtained from the factory)
      String val=env.getOptions().get("-Akey");

      val should contain "value", instead it is always null, and the following key is added to the options map: "key=value", which means that in order to obtain the value the following code should be used:
      for(String s : env.getOptions().keySet()) {
        if(s.startsWith("-Akey=")) {
          String val=s.substring(s.indexOf("=")+1);
          System.out.println(val);
        }
      }

      in simple words - the parsing of the option is not done, instead the key value pair is inserted as the key of the options map and the value is always null.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      write an annotation processor factory that declares that it accepts a -Akey option and try my code.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      the expected result is the value of the key in the options map
      ACTUAL -
      the actual result is always null value - as if the key has no value

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      see probelm description
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      see above description

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: