Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

javac crash on java 8 after adding pojobuilder #71

Closed
gionn opened this issue Aug 27, 2014 · 12 comments
Closed

javac crash on java 8 after adding pojobuilder #71

gionn opened this issue Aug 27, 2014 · 12 comments
Assignees
Labels
Milestone

Comments

@gionn
Copy link

gionn commented Aug 27, 2014

Hi,

after I've started using pojobuilder in a java 7 project using a java 8 jdk, and I found a reproducible issue every time the compile maven goal is executed without a prior clean.

Don't know if a workaround is possible, I've found only a fixed report in javadoc with the same error message: http://bugs.java.com/view_bug.do?bug_id=8029145

Anyone knows how to report a jdk bug to oracle?

Stacktrace for reference:

An exception has occurred in the compiler (1.8.0_20). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport)  after checking the Bug Parad
e 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:126)
        at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:169)
        at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:785)
        at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
        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:84)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
        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)
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] An unknown compilation problem occurred
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
@mkarneim
Copy link
Owner

Possibly the same reason as in #69.
However, the next days I will publish PojoBuilder 3 which is Java 8 compatible.

Thank you very much for your feedback!

@mkarneim
Copy link
Owner

Can you please check this scenario with PB 3.0.0 and confirm that (or if) it has been fixed?

@mkarneim mkarneim added this to the 3.0.0 milestone Sep 15, 2014
@manuelmazzuola
Copy link

Hi, I'm @gionn coworker, using java-7-openjdk and [email protected] the endPosTable already set error has gone, but if run mvn compile two times it fails on duplicate builder classes.

mvn compile

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.331 s
[INFO] Finished at: 2014-09-15T11:17:40+02:00
[INFO] Final Memory: 24M/195M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project datamodel: Compilation failure: Compilation failure:

[ERROR] /home/manuel/src/test/test-root/datamodel/target/generated-sources/annotations/com/manuelmazzuola/test/datamodel/entities/TestBuilder.java:[8,8] duplicate class: com.manuelmazzuola.test.datamodel.entities.TestBuilder

So a prior clean is always required.

Using java-8-oracle and [email protected] the compile goal not generates builders and the compilation fails.

@mkarneim
Copy link
Owner

I guess this happens even with a simple setup?

I'll try to handle this today or tomorrow.
Thank you for this feedback!

@mkarneim mkarneim reopened this Sep 16, 2014
@mkarneim
Copy link
Owner

Manuel,

I checked this on WIndows 7 but I got no failures using Maven and Java 7. Same for Java 8.
I will crosscheck that this evening or tomorrow when I have access to some Linux and OSX.

The test code is

package sample;

import net.karneim.pojobuilder.GeneratePojoBuilder;

@GeneratePojoBuilder
public class Contact {
  public String name;
  public int number;
}

and the pom.xml:

<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>sample</groupId>
  <artifactId>sample</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>pojobuilder-maven-sample</name>
  <dependencies>
    <dependency>
        <groupId>net.karneim</groupId>
        <artifactId>pojobuilder</artifactId>
        <version>3.1.0</version>
        <scope>provided</scope>
    </dependency>
  </dependencies>
</project

If you don't have any problems with this scenario, please post the scenario that causes the error, so I can reproduce it.

@manuelmazzuola
Copy link

Yes, this scenario works fine.
And, I've resolved the duplicate class problem adding <compilerArgument>-proc:none</compilerArgument> to the maven-compiler-plugin section as described here http://stackoverflow.com/questions/882295/maven-compilation-error-duplicate-classes 👍

But still does not work with java eight, I'll investigate in depth later

@mkarneim
Copy link
Owner

Manuel,
I just analayzed the issue with "incremental compilation using maven".

I tried 2 scenarios:

  • Ubuntu 14, OpenJDK 1.7.0_65 (64bit)
  • Ubuntu 14, Oracle JDK 1.8.0_20-b26 (64bit)

This is what I found out:

Repleatedly invoking mvn compile after code changes is not calling the annotation processors correctly. You always have to do a mvn clean compile to make sure that all pojo builders will be generated.

Since this is not what you want, you might want to disable the annotation processing in the maven-compiler-plugin and use the maven-processor-plugin instead. Here is a sample pom:

...
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.7</source>
          <target>1.7</target>
          <compilerArgument>-proc:none</compilerArgument>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.bsc.maven</groupId>
        <artifactId>maven-processor-plugin</artifactId>
        <version>2.2.4</version>
        <executions>
          <execution>
            <id>process</id>
            <goals>
              <goal>process</goal>
            </goals>
            <phase>process-sources</phase>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

This works both for Java 7 and Java 8.

Is that a solution for you?

@mkarneim mkarneim self-assigned this Sep 19, 2014
@gionn
Copy link
Author

gionn commented Sep 22, 2014

Yeah, that was the culprit.

I suggest to improve the README with those configurations in the maven section.

Thanks for your support @mkarneim !

@elucash
Copy link

elucash commented Jul 25, 2015

JFYI Disabling incremental compilation works in maven plugin, which resolved endPosTable problem for me

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.3</version>
        <configuration>
          <compilerVersion>1.8</compilerVersion>
          <source>1.8</source>
          <target>1.8</target>
          <useIncrementalCompilation>false</useIncrementalCompilation>
        </configuration>
      </plugin>

@membersound
Copy link

For me, "-proc:none" solved it, though I don't know what it does to my build.

The problem was introduced when using:
org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor

@lukasjelonek
Copy link

The problem came up in my setup when I updated the compiler plugin to a 3.x version. Downgrading it to 2.5.1 fixed it.

@rotatomel
Copy link

With java version:
openjdk version "1.8.0_77"
OpenJDK Runtime Environment (build 1.8.0_77-b03)
OpenJDK 64-Bit Server VM (build 25.77-b03, mixed mode)

I upgraded my compiler-plugin version to 3.5.1 and worked!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants