JDK-8029569 : internal javac cast exception when resolving varargs ambiguity
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2013-12-04
  • Updated: 2014-04-16
  • Resolved: 2013-12-09
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8 b122Fixed 9Fixed
Related Reports
Relates :  
Relates :  
Description
Compiling the following source code will cause an internal ClassCastException in javac.

Uncomment the cast of null to Long in order to compile without the crash.

public class Puke {
    public static void main(String[] args) {
        doit(/* (Long) */ null, new Exception());
    }

    public static void doit(Long l) {
    }

    public static void doit(Exception... exception) {
    }

    public static void doit(Long l, Exception... exception) {
    }
}

The crash error on 1.8.0-ea-b118 is:


java.lang.ClassCastException: com.sun.tools.javac.comp.Resolve$BadVarargsMethod cannot be cast to com.sun.tools.javac.comp.Resolve$AmbiguityError
        at com.sun.tools.javac.comp.Resolve$BasicLookupHelper.lookup(Resolve.java:3058)
        at com.sun.tools.javac.comp.Resolve.lookupMethod(Resolve.java:3307)
        at com.sun.tools.javac.comp.Resolve.lookupMethod(Resolve.java:3292)
        at com.sun.tools.javac.comp.Resolve.resolveMethod(Resolve.java:2361)
        at com.sun.tools.javac.comp.Attr.visitIdent(Attr.java:3129)
        at com.sun.tools.javac.tree.JCTree$JCIdent.accept(JCTree.java:2005)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:597)
        at com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1828)
        at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1459)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:597)
        at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:646)
        at com.sun.tools.javac.comp.Attr.visitExec(Attr.java:1596)
        at com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1290)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:597)
        at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:666)
        at com.sun.tools.javac.comp.Attr.attribStats(Attr.java:682)
        at com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1127)
        at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:903)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:597)
        at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:666)
        at com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:1020)
        at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:772)
        at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:597)
        at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:666)
        at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4287)
        at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4197)
        at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4131)
        at com.sun.tools.javac.comp.Attr.attrib(Attr.java:4106)
        at com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1251)
        at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:904)
        at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:863)
        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)

Comments
Release team: Approved for fixing
11-12-2013

sqe-ok: a fix to compiler crash with low risk and very small fix.
09-12-2013

8-critical-request justification: This fix should be included for 8 as this is a regression and a compiler crash Risk Assessment: Minimum Level of testing coverage: JCK tests, langtools jtreg tests executed through jprt in all available platforms, build whole JDK with the change applied. Size of fix: small: 5 lines, not including jtreg test.
05-12-2013

This is a regression, the code was providing the right error message in JDK 7.
05-12-2013

Updated to P3 for now, for crash to be analyzed. All crashes are bad.
04-12-2013