JDK-8141264 : Exception in compiler while compiling using Maven 3
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8u40
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • OS: linux_ubuntu
  • CPU: x86_64
  • Submitted: 2015-09-30
  • Updated: 2016-03-16
  • Resolved: 2016-03-16
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_40-ea"
Java(TM) SE Runtime Environment (build 1.8.0_40-ea-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b16, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Linux gerlaptop 3.13.0-37-generic #64-Ubuntu SMP Mon Sep 22 21:28:38 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

EXTRA RELEVANT SYSTEM CONFIGURATION :
Using:
Apache Maven 3.2.3 (33f8c3e1027c3ddde99d3cdebad2656a31e8fdf4; 2014-08-11T22:58:10+02:00)


A DESCRIPTION OF THE PROBLEM :
[INFO] Compiling 200 source files to /home/gerbrand/workspace/Fundeon/subsidies/sub-war/target/classes
An exception has occurred in the compiler (1.8.0_40-ea). 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.code.Type$UnionClassType cannot be cast to com.sun.tools.javac.code.Type$IntersectionClassType
	at com.sun.tools.javac.code.Types$8.visitClassType(Types.java:1542)
	at com.sun.tools.javac.code.Types$8.visitClassType(Types.java:1499)
	at com.sun.tools.javac.code.Type$ClassType.accept(Type.java:778)
	at com.sun.tools.javac.code.Types$DefaultTypeVisitor.visit(Types.java:4459)
	at com.sun.tools.javac.code.Types.isCastable(Types.java:1490)
	at com.sun.tools.javac.comp.Check.checkCastable(Check.java:568)
	at com.sun.tools.javac.comp.Check.checkCastable(Check.java:565)
	at com.sun.tools.javac.comp.Attr.visitTypeCast(Attr.java:3086)
	at com.sun.tools.javac.tree.JCTree$JCTypeCast.accept(JCTree.java:1814)
	at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
	at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:608)
	at com.sun.tools.javac.comp.Attr.visitVarDef(Attr.java:1052)
	at com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:852)
	at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
	at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:635)
	at com.sun.tools.javac.comp.Attr.attribStats(Attr.java:651)
	at com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1101)
	at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:909)
	at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
	at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:635)
	at com.sun.tools.javac.comp.Attr.visitTry(Attr.java:1354)
	at com.sun.tools.javac.tree.JCTree$JCTry.accept(JCTree.java:1173)
	at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
	at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:635)
	at com.sun.tools.javac.comp.Attr.attribStats(Attr.java:651)
	at com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1101)
	at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:909)
	at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
	at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:635)
	at com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:994)
	at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:778)
	at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
	at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:635)
	at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4321)
	at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4231)
	at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4160)
	at com.sun.tools.javac.comp.Attr.attrib(Attr.java:4135)
	at com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1248)
	at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:901)
	at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:860)
	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:497)
	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)

REGRESSION.  Last worked in version 7u65

ADDITIONAL REGRESSION INFORMATION: 
 % mvn -version
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=1024m; support was removed in 8.0
Apache Maven 3.2.3 (33f8c3e1027c3ddde99d3cdebad2656a31e8fdf4; 2014-08-11T22:58:10+02:00)
Maven home: /usr/local/apache-maven
Java version: 1.8.0_40-ea, vendor: Oracle Corporation
Java home: /usr/local/jdk1.8.0_40/jre
Default locale: nl_NL, platform encoding: UTF-8
OS name: "linux", version: "3.13.0-37-generic", arch: "amd64", family: "unix"


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
The problem occurs while compiling a webapplication using Maven:

 % mvn compile
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=1024m; support was removed in 8.0
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Subsidies WAR 4.7.0
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- buildnumber-maven-plugin:1.1:create (default) @ sub-war ---
[INFO] Checking for local modifications: skipped.
[INFO] Updating project files from SCM: skipped.
[INFO] Executing: /bin/sh -c cd /home/gerbrand/workspace/Fundeon/subsidies/sub-war && git rev-parse --verify HEAD
[INFO] Working directory: /home/gerbrand/workspace/Fundeon/subsidies/sub-war
[INFO] Storing buildNumber: fdbdb4d50626d7a4f55de98e36a640acbad01174 at timestamp: 1414683141651
[INFO] Executing: /bin/sh -c cd /home/gerbrand/workspace/Fundeon/subsidies/sub-war && git rev-parse --verify HEAD
[INFO] Working directory: /home/gerbrand/workspace/Fundeon/subsidies/sub-war
[INFO] Storing buildScmBranch: UNKNOWN
[INFO] 
[INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ sub-war ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ sub-war ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 200 source files to /home/gerbrand/workspace/Fundeon/subsidies/sub-war/target/classes
An exception has occurred in the compiler (1.8.0_40-ea). 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.code.Type$UnionClassType cannot be cast to com.sun.tools.javac.code.Type$IntersectionClassType


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
A succesfull compilation
ACTUAL -
When using JDK 8 to compile our source-code we get the above exception. When using Java 7 the code is compiled successfully.

REPRODUCIBILITY :
This bug can be reproduced always.


Comments
received reply from submitter == >Thanks for your reply. I just downloaded the latest release and tried compiling. The problem does indeed not occur anymore in jdk9, great work > ==
03-11-2015

Additional information requested from submitter == Thanks for reporting the incident to Oracle. Would you please confirm the issue exist in 9 early access? You can download from https://jdk9.java.net/ ==
16-10-2015