JDK-8133123 : javac: AssertionError: isSubClass T
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8u51
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_7
  • CPU: x86_64
  • Submitted: 2015-08-03
  • Updated: 2016-05-26
  • Resolved: 2015-08-11
Related Reports
Duplicate :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) Client VM (build 25.51-b03, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]

A DESCRIPTION OF THE PROBLEM :
javac throws an AssertionError when compiling the following classes. While the structure of the classes looks similar to the case described in JDK-8067111 (which was resolved in 8u40), the problem still occurs with 8u51.

The problem does NOT occur on java 9, javac 1.9.0-ea-b72 complies those classes as expected

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the classes using

javac *.java

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Classes compile without error
ACTUAL -
javac throws AssertionError, complete message/stack trace see below 

ERROR MESSAGES/STACK TRACES THAT OCCUR :
An exception has occurred in the compiler (1.8.0_51). 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.AssertionError: isSubClass T
        at com.sun.tools.javac.code.Symbol.isSubClass(Symbol.java:447)
        at com.sun.tools.javac.code.Symbol.isMemberOf(Symbol.java:456)
        at com.sun.tools.javac.code.Symbol$MethodSymbol.overrides(Symbol.java:1469)
        at com.sun.tools.javac.code.Types$ImplementationCache.implementationInternal(Types.java:2678)
        at com.sun.tools.javac.code.Types$ImplementationCache.get(Types.java:2660)
        at com.sun.tools.javac.code.Types.implementation(Types.java:2689)
        at com.sun.tools.javac.code.Symbol$MethodSymbol.implementation(Symbol.java:1529)
        at com.sun.tools.javac.code.Symbol$MethodSymbol.implementation(Symbol.java:1518)
        at com.sun.tools.javac.comp.Resolve.notOverriddenIn(Resolve.java:419)
        at com.sun.tools.javac.comp.Resolve.isAccessible(Resolve.java:405)
        at com.sun.tools.javac.comp.Resolve.isAccessible(Resolve.java:365)
        at com.sun.tools.javac.comp.Resolve.selectBest(Resolve.java:1458)
        at com.sun.tools.javac.comp.Resolve.findMethodInScope(Resolve.java:1628)
        at com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1720)
        at com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1672)
        at com.sun.tools.javac.comp.Resolve$MethodReferenceLookupHelper.lookup(Resolve.java:3179)
        at com.sun.tools.javac.comp.Resolve.lookupMethod(Resolve.java:3335)
        at com.sun.tools.javac.comp.Resolve.lookupMethod(Resolve.java:3320)
        at com.sun.tools.javac.comp.Resolve.getMemberReference(Resolve.java:2728)
        at com.sun.tools.javac.comp.DeferredAttr$DeferredChecker.visitReference(DeferredAttr.java:1182)
        at com.sun.tools.javac.tree.JCTree$JCMemberReference.accept(JCTree.java:1973)
        at com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
        at com.sun.tools.javac.comp.DeferredAttr$FilterScanner.scan(DeferredAttr.java:912)
        at com.sun.tools.javac.comp.DeferredAttr.isDeferred(DeferredAttr.java:1099)
        at com.sun.tools.javac.comp.Attr.attribArgs(Attr.java:660)
        at com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1797)
        at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1465)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
        at com.sun.tools.javac.comp.DeferredAttr.attribSpeculative(DeferredAttr.java:386)
        at com.sun.tools.javac.comp.DeferredAttr$2.complete(DeferredAttr.java:279)
        at com.sun.tools.javac.comp.DeferredAttr$DeferredType.check(DeferredAttr.java:245)
        at com.sun.tools.javac.comp.DeferredAttr$DeferredType.check(DeferredAttr.java:232)
        at com.sun.tools.javac.comp.Resolve$MethodResultInfo.check(Resolve.java:1003)
        at com.sun.tools.javac.comp.Resolve$4.checkArg(Resolve.java:829)
        at com.sun.tools.javac.comp.Resolve$AbstractMethodCheck.argumentsAcceptable(Resolve.java:734)
        at com.sun.tools.javac.comp.Resolve$4.argumentsAcceptable(Resolve.java:838)
        at com.sun.tools.javac.comp.Infer.instantiateMethod(Infer.java:162)
        at com.sun.tools.javac.comp.Resolve.rawInstantiate(Resolve.java:567)
        at com.sun.tools.javac.comp.Resolve.selectBest(Resolve.java:1441)
        at com.sun.tools.javac.comp.Resolve.findMethodInScope(Resolve.java:1628)
        at com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1699)
        at com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1672)
        at com.sun.tools.javac.comp.Resolve$9.doLookup(Resolve.java:2425)
        at com.sun.tools.javac.comp.Resolve$BasicLookupHelper.lookup(Resolve.java:3084)
        at com.sun.tools.javac.comp.Resolve.lookupMethod(Resolve.java:3335)
        at com.sun.tools.javac.comp.Resolve.resolveQualifiedMethod(Resolve.java:2422)
        at com.sun.tools.javac.comp.Resolve.resolveQualifiedMethod(Resolve.java:2416)
        at com.sun.tools.javac.comp.Attr.selectSym(Attr.java:3364)
        at com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:3246)
        at com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:1897)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
        at com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1806)
        at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1465)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
        at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:615)
        at com.sun.tools.javac.comp.Attr.visitExec(Attr.java:1574)
        at com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1296)
        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:1105)
        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:4330)
        at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4240)
        at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4169)
        at com.sun.tools.javac.comp.Attr.attrib(Attr.java:4144)
        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.main.Main.compile(Main.java:381)
        at com.sun.tools.javac.main.Main.compile(Main.java:370)
        at com.sun.tools.javac.main.Main.compile(Main.java:361)
        at com.sun.tools.javac.Main.compile(Main.java:56)
        at com.sun.tools.javac.Main.main(Main.java:42)

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
CollectionConsumer.java
====================
import static java.util.stream.Collectors.toMap;

import java.util.Collection;
import java.util.function.Function;

abstract class CollectionConsumer<T extends AbstractClass> {

  protected CollectionConsumer(Collection<T> col) {
    col.stream().collect(toMap(T::getId, Function.identity())); // crashes javac (1.8.0_51-b16), compiles fine with eclipse compiler
                                                                // and javac (1.9.0-ea-b72)
    col.stream().collect(toMap(AbstractClass::getId, Function.identity())); // compiles fine with both javac (all versions) and
                                                                            // eclipse compiler
  }

}


Intfc.java
=======
public interface Intfc {
  
  String getId();

}


SuperClassWithGetId.java
=====================
public abstract class SuperClassWithGetId {
  
  public String getId() {
    return "Id";
  }

}


AbstractClass.java
===============
public abstract class AbstractClass extends SuperClassWithGetId implements Intfc {

}



---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
See the the CollectionConsumer class in the test case for a working, equivalent alternative


Comments
This issue is fixed only for 9, and it still exist in 8u92.
25-05-2016

Fixed by JDK-8073842.
11-08-2015

1. Compile the attached source files in Windows 7. 2. Checked this for JDK 8u51, 8u60 ea b26, 9 ea b75 8u40: FAIL 8u51: FAIL 8u60 ea b26: FAIL 9 ea b75: PASS 3. Output with JDK 8u51: > javac *.java An exception has occurred in the compiler (1.8.0_51). 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 follo wing diagnostic in your report. Thank you. java.lang.AssertionError: isSubClass T at com.sun.tools.javac.code.Symbol.isSubClass(Symbol.java:447) at com.sun.tools.javac.code.Symbol.isMemberOf(Symbol.java:456) at com.sun.tools.javac.code.Symbol$MethodSymbol.overrides(Symbol.java:1469) at com.sun.tools.javac.code.Types$ImplementationCache.implementationInternal(Types.java:2678) at com.sun.tools.javac.code.Types$ImplementationCache.get(Types.java:2660) at com.sun.tools.javac.code.Types.implementation(Types.java:2689) at com.sun.tools.javac.code.Symbol$MethodSymbol.implementation(Symbol.java:1529) at com.sun.tools.javac.code.Symbol$MethodSymbol.implementation(Symbol.java:1518) at com.sun.tools.javac.comp.Resolve.notOverriddenIn(Resolve.java:419) at com.sun.tools.javac.comp.Resolve.isAccessible(Resolve.java:405) at com.sun.tools.javac.comp.Resolve.isAccessible(Resolve.java:365) at com.sun.tools.javac.comp.Resolve.selectBest(Resolve.java:1458) ------------------------------ ---------------------------------- --------------------------------------- 4. This issue is reproducible with JDK 8u51, 8u60 ea b26, while the code compiles fine with 9 ea b75.
06-08-2015