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

javac throws exception during compilation when annotation processing is enabled

    XMLWordPrintable

Details

    • b155
    • x86_64
    • windows_7
    • Verified

    Backports

      Description

        FULL PRODUCT VERSION :
        java version "1.8.0_25"
        Java(TM) SE Runtime Environment (build 1.8.0_25-b18)
        Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

        ADDITIONAL OS VERSION INFORMATION :
        Windows 8 64 bit

        A DESCRIPTION OF THE PROBLEM :
        Maven compilation with annotation processing enabled fails, if the target/generated-sources/metamodel directory is not empty.
        If it's not empty, javac fails to compile.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Create at least 1 JPA entity (@Entity) and a persistence unit
        Configure maven to use an annotation processor (QueryDSL 3.6 or eclipseLink 2.5.2) during compilation (both tested, giving the same exception)
        run: mvn compile twice, without using mvn clean in between, i.e.
        > mvn clean compile
        > mvn compile


        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        compilation succeeds both times
        ACTUAL -
        The first compilation succeeds. the second fails with an exception.

        ERROR MESSAGES/STACK TRACES THAT OCCUR :
        [INFO] Compiling 108 source files to myproject\target\classes
        An exception has occurred in the compiler (1.8.0_25). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for
        duplicates. Include your program and the following diagnostic in your report. Thank you.
        java.lang.IllegalStateException: endPosTable already set
                at com.sun.tools.javac.util.DiagnosticSource.setEndPosTable(DiagnosticSource.java:136)
                at com.sun.tools.javac.util.Log.setEndPosTable(Log.java:350)
                at com.sun.tools.javac.main.JavaCompiler.parse(JavaCompiler.java:667)
                at com.sun.tools.javac.main.JavaCompiler.parseFiles(JavaCompiler.java:950)
                at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.<init>(JavacProcessingEnvironment.java:892)
                at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.next(JavacProcessingEnvironment.java:921)
                at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1187)
                at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
                at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
                at com.sun.tools.javac.main.Main.compile(Main.java:523)
                at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
                at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
                at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:125)
                at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:169)
                at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:823)
                at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
                at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
                at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
                at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
                at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
                at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
                at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
                at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
                at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
                at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
                at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
                at org.apache.maven.cli.MavenCli.execute(MavenCli.java:582)
                at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
                at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                at java.lang.reflect.Method.invoke(Method.java:483)
                at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
                at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
                at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
                at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        SampleEntity.java:

        @Entity
        public class SampleEntity {
        @Id
        public long id;

        @Version
        public long version;

        public String name;

        }

        maven POM:
        <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
            <modelVersion>4.0.0</modelVersion>
            <groupId>com.test</groupId>
            <artifactId>mavenproject1</artifactId>
            <version>1.0-SNAPSHOT</version>
            <packaging>war</packaging>
            
            <properties>
                <maven.compiler.source>1.8</maven.compiler.source>
                <maven.compiler.target>1.8</maven.compiler.target>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </properties>

        <build>
        <plugins>
        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.2</version>
        <configuration>
        <encoding>${project.build.sourceEncoding}</encoding>
        <generatedSourcesDirectory>${basedir}/target/generated-sources/metamodel</generatedSourcesDirectory>
        <showWarnings>true</showWarnings>
        <optimize>true</optimize>
        <showDeprecation>true</showDeprecation>
        <compilerId>javac</compilerId>
        <!-- <verbose /> -->
        <annotationProcessors>
        <annotationProcessor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</annotationProcessor>
        </annotationProcessors>
        </configuration>
        </plugin>
        </plugins>
        </build>
        <dependencies>
        <dependency>
                    <groupId>javax</groupId>
                    <artifactId>javaee-api</artifactId>
                    <version>7.0</version>
                    <scope>provided</scope>
                </dependency>
        <!-- Needed for annotation processing only -->
        <dependency>
        <groupId>com.mysema.querydsl</groupId>
        <artifactId>querydsl-apt</artifactId>
        <version>3.6.0</version>
        <classifier>jpa</classifier>
        <scope>provided</scope>
        </dependency>
            </dependencies>
        </project>
        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        none known

        Attachments

          Issue Links

            Activity

              People

                jlahoda Jan Lahoda
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: