FULL PRODUCT VERSION :
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
The java compiler has obviously a problem retrieving the right type of an interface method, which is defined in two different object hierarhies, but is used by one and the same subclass. For better understanding see the provided examples. The same code compiles without any errors in 1.7.0_21.
ADDITIONAL REGRESSION INFORMATION:
java version "1.7.0_21"
Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Information:Using javac 1.8.0_31 to compile java sources
Information:java: An exception has occurred in the compiler (1.8.0_31). 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.
Information:java: at com.sun.tools.javac.code.Symbol.isSubClass(Symbol.java:447)
Information:java: at com.sun.tools.javac.code.Symbol.isMemberOf(Symbol.java:456)
Information:java: at com.sun.tools.javac.code.Symbol$MethodSymbol.overrides(Symbol.java:1469)
Information:java: at com.sun.tools.javac.code.Types$ImplementationCache.implementationInternal(Types.java:2671)
Information:java: at com.sun.tools.javac.code.Types$ImplementationCache.get(Types.java:2653)
Information:java: at com.sun.tools.javac.code.Types.implementation(Types.java:2682)
Information:java: at com.sun.tools.javac.code.Symbol$MethodSymbol.implementation(Symbol.java:1529)
Information:java: at com.sun.tools.javac.code.Symbol$MethodSymbol.implementation(Symbol.java:1518)
Information:java: at com.sun.tools.javac.comp.Resolve.notOverriddenIn(Resolve.java:416)
Information:java: at com.sun.tools.javac.comp.Resolve.isAccessible(Resolve.java:402)
Information:java: at com.sun.tools.javac.comp.Resolve.isAccessible(Resolve.java:362)
Information:java: at com.sun.tools.javac.comp.Resolve.selectBest(Resolve.java:1448)
Information:java: at com.sun.tools.javac.comp.Resolve.findMethodInScope(Resolve.java:1618)
Information:java: at com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1710)
Information:java: at com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1662)
Information:java: at com.sun.tools.javac.comp.DeferredAttr$DeferredChecker$2.lookup(DeferredAttr.java:1325)
Information:java: at com.sun.tools.javac.comp.Resolve.lookupMethod(Resolve.java:3325)
Information:java: at com.sun.tools.javac.comp.Resolve.lookupMethod(Resolve.java:3310)
Information:java: at com.sun.tools.javac.comp.DeferredAttr$DeferredChecker.quicklyResolveMethod(DeferredAttr.java:1333)
Information:java: at com.sun.tools.javac.comp.DeferredAttr$DeferredChecker.visitApply(DeferredAttr.java:1223)
Information:java: at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1465)
Information:java: at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
Information:java: at com.sun.tools.javac.comp.DeferredAttr$FilterScanner.scan(DeferredAttr.java:901)
Information:java: at com.sun.tools.javac.comp.DeferredAttr.isDeferred(DeferredAttr.java:1088)
Information:java: at com.sun.tools.javac.comp.Attr.attribArgs(Attr.java:701)
Information:java: at com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1834)
Information:java: at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:607)
Information:java: at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:656)
Information:java: at com.sun.tools.javac.comp.Attr.visitExec(Attr.java:1611)
Information:java: at com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1296)
Information:java: at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:676)
Information:java: at com.sun.tools.javac.comp.Attr.attribStats(Attr.java:692)
Information:java: at com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1142)
Information:java: at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:909)
Information:java: at com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:1035)
Information:java: at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:778)
Information:java: at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4342)
Information:java: at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4252)
Information:java: at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4181)
Information:java: at com.sun.tools.javac.comp.Attr.attrib(Attr.java:4156)
Information:java: at com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1248)
Information:java: at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:901)
Information:java: at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:860)
Information:java: at com.sun.tools.javac.main.Main.compile(Main.java:523)
Information:java: at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
Information:java: at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
Information:java: at org.jetbrains.jps.javac.JavacMain.compile(JavacMain.java:165)
Information:java: at org.jetbrains.jps.incremental.java.JavaBuilder.compileJava(JavaBuilder.java:380)
Information:java: at org.jetbrains.jps.incremental.java.JavaBuilder.compile(JavaBuilder.java:298)
Information:java: at org.jetbrains.jps.incremental.java.JavaBuilder.doBuild(JavaBuilder.java:204)
Information:java: at org.jetbrains.jps.incremental.java.JavaBuilder.build(JavaBuilder.java:176)
Information:java: at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1140)
Information:java: at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:826)
Information:java: at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:894)
Information:java: at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:789)
Information:java: at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:612)
Information:java: at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:352)
Information:java: at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:191)
Information:java: at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:137)
Information:java: at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:289)
Information:java: at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:124)
Information:java: at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler$1.run(BuildMain.java:238)
Information:java: at org.jetbrains.jps.service.impl.SharedThreadPoolImpl$1.run(SharedThreadPoolImpl.java:41)
Information:java: at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
Information:java: at java.util.concurrent.FutureTask.run(FutureTask.java:266)
Information:java: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
Information:java: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
Information:java: at java.lang.Thread.run(Thread.java:745)
Information:java: Errors occurred while compiling module 'Java8Bug'
Information:28.01.2015 08:22 - Compilation completed with 1 error and 0 warnings in 1 sec
Error:java: java.lang.AssertionError: isSubClass T
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
######## First example #########
public class ClassA {
private String property;
public String getProperty() {
return property;
}
}
public interface InterfaceB {
String getProperty();
}
public class Main {
public <T extends ClassA & InterfaceB> void reproduce(T meldung) {
System.out.println(meldung.getProperty());
//Explicitly casting the getProperty output to String fixes the problem System.out.println((String)meldung.getProperty());
}
}
####### End of first example ########
####### Second example ###########
public abstract class AbstractModel {
private Long version;
public Long getVersion() {
return version;
}
}
public interface VersionInterface {
public Long getVersion();
}
public abstract class AbstractVersionInterface extends AbstractModel implements VersionInterface {
}
public class Main {
public <T extends AbstractVersionInterface> void reproduce(final T object) {
System.out.println(object.getVersion());
//this is working!!! System.out.println((Long)object.getVersion());
}
}
####### End of second example #######
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Explicitly cast the result of the getter method.