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

javac fails to run annotation processors when star import of package of gensrc

XMLWordPrintable

    • 7
    • b25
    • x86
    • linux
    • Verified

        After unpacking http://netbeans.org/bugzilla/attachment.cgi?id=114753 and running 'mvn -f netbeans-generation-issue/sampleprocessor/pom.xml install', if (with JAVA_HOME set to JDK 7u1 or u2) you run 'mvn -f netbeans-generation-issue/generatingissue/pom.xml clean compile' you will get an error:

        [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ generatingissue ---
        [INFO] Compiling 2 source files to /tmp/netbeans-generation-issue/generatingissue/target/classes
        [INFO] -------------------------------------------------------------
        [ERROR] COMPILATION ERROR :
        [INFO] -------------------------------------------------------------
        [ERROR] /tmp/netbeans-generation-issue/generatingissue/src/main/java/jp/javelindev/netbeans/generatingissue/ClassWithIssue.java:[4,0] error: package jp.javelindev.netbeans.generatingissue.impl does not exist
        [ERROR] /tmp/netbeans-generation-issue/generatingissue/src/main/java/jp/javelindev/netbeans/generatingissue/ClassWithIssue.java:[14,32] error: cannot find symbol
        [INFO] 2 errors

        Using JDK 6u30 it works:

        [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ generatingissue ---
        [INFO] Compiling 2 source files to /tmp/netbeans-generation-issue/generatingissue/target/classes
        [WARNING] /tmp/netbeans-generation-issue/generatingissue/src/main/java/jp/javelindev/netbeans/generatingissue/ClassWithIssue.java:[4,0] package jp.javelindev.netbeans.generatingissue.impl does not exist
        [INFO] ------------------------------------------------------------------------
        [INFO] BUILD SUCCESS

        Pulling out the actual forked javac command line (obtainable using -X), which includes -verbose, shows that in JDK 7 (or javac built from langtools c747f413d531) no apparent attempt is made to run the annotation processor, though its @SupportedAnnotationTypes matches the annotation in the source file, whereas JDK 6 loads it as expected:

        Round 1:
        input files: {jp.javelindev.netbeans.generatingissue.ClassWithIssue, jp.javelindev.netbeans.generatingissue.GenerateOrigin}
        annotations: [jp.javelindev.netbeans.sampleprocessor.SampleAnnotation]
        last round: false
        RUNNING...
        Processor jp.javelindev.netbeans.sampleprocessor.SampleProcessor matches [jp.javelindev.netbeans.sampleprocessor.SampleAnnotation] and returns true.

        The problem seems to go away if you replace the wildcard import with an exact import:

        import jp.javelindev.netbeans.generatingissue.impl.GenerateOriginImpl;

        Then even JDK 7 javac goes through the required multiple rounds, running the AP.

              jjh James Holmlund (Inactive)
              jglick Jesse Glick (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: