swagger-core icon indicating copy to clipboard operation
swagger-core copied to clipboard

Compilation error with JDK 7 (1.7.0_71) on mac

Open thegreatdao opened this issue 11 years ago • 9 comments

Hi Here is my maven settings:

Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 15:22:22+0000) Maven home: /usr/local/Cellar/maven/3.1.1/libexec Java version: 1.7.0_71, vendor: Oracle Corporation Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre Default locale: en_US, platform encoding: UTF-8 OS name: "mac os x", version: "10.10.3", arch: "x86_64", family: "mac"

I can build with swagger-jersey-jaxrs_2.10 no problem, once switching to swagger-jersey-1.5.3-M1

I got this error:

[ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] Failure executing javac, but could not parse the error: An exception has occurred in the compiler (1.7.0_71). 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.ClassCastException: com.sun.tools.javac.tree.JCTree$JCLiteral cannot be cast to com.sun.tools.javac.tree.JCTree$JCAnnotation at com.sun.tools.javac.comp.Annotate.enterAttributeValue(Annotate.java:229) at com.sun.tools.javac.comp.Annotate.enterAttributeValue(Annotate.java:243) at com.sun.tools.javac.comp.Annotate.enterAnnotation(Annotate.java:181) at com.sun.tools.javac.comp.MemberEnter.enterAnnotations(MemberEnter.java:783) at com.sun.tools.javac.comp.MemberEnter.access$300(MemberEnter.java:57) at com.sun.tools.javac.comp.MemberEnter$5.enterAnnotation(MemberEnter.java:751) at com.sun.tools.javac.comp.Annotate.flush(Annotate.java:109) at com.sun.tools.javac.comp.Annotate.enterDone(Annotate.java:101) at com.sun.tools.javac.comp.Enter.complete(Enter.java:510) at com.sun.tools.javac.comp.Enter.main(Enter.java:469) at com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:929) at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:824) at com.sun.tools.javac.main.Main.compile(Main.java:439) at com.sun.tools.javac.main.Main.compile(Main.java:353) at com.sun.tools.javac.main.Main.compile(Main.java:342) at com.sun.tools.javac.main.Main.compile(Main.java:333) at com.sun.tools.javac.Main.compile(Main.java:94) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.codehaus.plexus.compiler.javac.JavacCompiler.compileInProcess(JavacCompiler.java:554) at org.codehaus.plexus.compiler.javac.JavacCompiler.compile(JavacCompiler.java:161) at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:605) at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:128) 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.MojoExecutor.executeForkedExecutions(MojoExecutor.java:364) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:198) 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:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) 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] 1 error [INFO] ------------------------------------------------------------- [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE

Anyone has any idea why this happened? Does swagger work with JDK7?

Thanks, H

thegreatdao avatar May 14 '15 18:05 thegreatdao

Swagger works with Java 7, yes.

Are you trying to compile swagger-core or your own application?

webron avatar May 14 '15 18:05 webron

Hi,

Thanks for the quick response.

I'm only add the depency in my pom as:

        <dependency>
            <groupId>com.wordnik</groupId>
            <artifactId>swagger-jersey-jaxrs</artifactId>
            <version>1.5.1.M1</version>
        </dependency>

My project is set to both source and target to 1.7, does this break swagger?

<plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${maven-compiler-plugin.version}</version>
                    <configuration>
                        <source>1.7</source>
                        <target>1.7</target>
                    </configuration>
                </plugin>

Thanks, H

thegreatdao avatar May 14 '15 18:05 thegreatdao

Well, that's not a valid dependency version. Try changing it to 1.5.1-M2

webron avatar May 14 '15 18:05 webron

That's the first one I tried, I got the error, then I went to http://mvnrepository.com/artifact/com.wordnik/swagger-core, and found other version. so tried most 1.5.x. pretty much got the same errors. From error message, It complains about classcastexception.

Googled, not much information about that specific error.

thegreatdao avatar May 14 '15 18:05 thegreatdao

I don't see how that's related to swagger-core. The error itself tells you the issue is with the jdk. Try upgrading your JDK, there have been new releases.

webron avatar May 14 '15 18:05 webron

Ok, that's the last thing I can try. Thanks, will report later.

thegreatdao avatar May 14 '15 18:05 thegreatdao

Tried latest JDK 7u79 no luck. Tried JDK 8u45 worked.

Not sure what happened.

thegreatdao avatar May 14 '15 20:05 thegreatdao

no idea. I'm using 7u67 and it works fine.

webron avatar May 15 '15 09:05 webron

Switched back to 7u79 worked again. I think you can close the issue.

Thanks

thegreatdao avatar May 15 '15 11:05 thegreatdao