Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8038023

Compiler crash: ClassCastException

XMLWordPrintable

    • b13
    • x86
    • windows_7

        hFULL PRODUCT VERSION :
        java version "1.8.0_20-ea"
        Java(TM) SE Runtime Environment (build 1.8.0_20-ea-b05)
        Java HotSpot(TM) Client VM (build 25.20-b05, mixed mode, sharing)

        EXTRA RELEVANT SYSTEM CONFIGURATION :
        Compiling with IntelliJIdea 12.1.6

        A DESCRIPTION OF THE PROBLEM :
        When using JDK 1.8.0_20 to compile JSPs that reference classes compiled with IntelliJIdea 12.1.6 with @NotNull assertions added I get a compiler crash. I provide a reduced test case,

        REGRESSION. Last worked in version 8

        ADDITIONAL REGRESSION INFORMATION:
        java version "1.8.0_20-ea"
        Java(TM) SE Runtime Environment (build 1.8.0_20-ea-b05)
        Java HotSpot(TM) Client VM (build 25.20-b05, mixed mode, sharing)

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        1. Compile BugImported.java with IntelliJIdea 12.1.6 using 1.8.0_20 as the project JDK, or use the attached BugImported.class
        2. From the command line, compile Bug.java with the class file from step 1 in the classpath


        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        Bug.java should compile correctly
        ACTUAL -
        The compiler crashes

        ERROR MESSAGES/STACK TRACES THAT OCCUR :
        An exception has occurred in the compiler (1.8.0_20-ea). Please file a bug at the Java Developer Connection (http://java
        or duplicates. Include your program and the following diagnostic in your report. Thank you.
        java.lang.ClassCastException: com.sun.tools.javac.code.Symbol$ClassSymbol cannot be cast to com.sun.tools.javac.util.Name
                at com.sun.tools.javac.jvm.ClassReader.readName(ClassReader.java:597)
                at com.sun.tools.javac.jvm.ClassReader.setParameterNames(ClassReader.java:2125)
                at com.sun.tools.javac.jvm.ClassReader.readMethod(ClassReader.java:2026)
                at com.sun.tools.javac.jvm.ClassReader.readClass(ClassReader.java:2229)
                at com.sun.tools.javac.jvm.ClassReader.readClassFile(ClassReader.java:2301)
                at com.sun.tools.javac.jvm.ClassReader.fillIn(ClassReader.java:2488)
                at com.sun.tools.javac.jvm.ClassReader.complete(ClassReader.java:2419)
                at com.sun.tools.javac.jvm.ClassReader.access$000(ClassReader.java:76)
                at com.sun.tools.javac.jvm.ClassReader$1.complete(ClassReader.java:240)
                at com.sun.tools.javac.code.Symbol.complete(Symbol.java:560)
                at com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1024)
                at com.sun.tools.javac.jvm.ClassReader.loadClass(ClassReader.java:2600)
                at com.sun.tools.javac.comp.Resolve.loadClass(Resolve.java:1863)
                at com.sun.tools.javac.comp.Resolve.findIdentInPackage(Resolve.java:2102)
                at com.sun.tools.javac.comp.Attr.selectSym(Attr.java:3358)
                at com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:3257)
                at com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:1891)
                at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:596)
                at com.sun.tools.javac.comp.Attr.attribType(Attr.java:658)
                at com.sun.tools.javac.comp.Attr.attribType(Attr.java:651)
                at com.sun.tools.javac.comp.MemberEnter.attribImportType(MemberEnter.java:836)
                at com.sun.tools.javac.comp.MemberEnter.visitImport(MemberEnter.java:556)
                at com.sun.tools.javac.tree.JCTree$JCImport.accept(JCTree.java:571)
                at com.sun.tools.javac.comp.MemberEnter.memberEnter(MemberEnter.java:435)
                at com.sun.tools.javac.comp.MemberEnter.memberEnter(MemberEnter.java:447)
                at com.sun.tools.javac.comp.MemberEnter.visitTopLevel(MemberEnter.java:526)
                at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:518)
                at com.sun.tools.javac.comp.MemberEnter.memberEnter(MemberEnter.java:435)
                at com.sun.tools.javac.comp.MemberEnter.complete(MemberEnter.java:1038)
                at com.sun.tools.javac.code.Symbol.complete(Symbol.java:560)
                at com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1024)
                at com.sun.tools.javac.comp.Enter.complete(Enter.java:497)
                at com.sun.tools.javac.comp.Enter.main(Enter.java:475)
                at com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:985)
                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 ----------
        ---- File BugImported.class (base64 encoded)

        yv66vgAAADQAOgEAD2J1Zy9CdWdJbXBvcnRlZAcAAQEAEGphdmEvbGFuZy9PYmplY3QHAAMBABBC
        dWdJbXBvcnRlZC5qYXZhAQAGPGluaXQ+AQADKClWDAAGAAcKAAQACAEABHRoaXMBABFMYnVnL0J1
        Z0ltcG9ydGVkOwEACWdldFN0cmluZwEAJihMamF2YS9sYW5nL1N0cmluZzspTGphdmEvbGFuZy9T
        dHJpbmc7AQAjTG9yZy9qZXRicmFpbnMvYW5ub3RhdGlvbnMvTm90TnVsbDsBACJqYXZhL2xhbmcv
        SWxsZWdhbEFyZ3VtZW50RXhjZXB0aW9uBwAPAQBPQXJndW1lbnQgMCBmb3IgQE5vdE51bGwgcGFy
        YW1ldGVyIG9mIGJ1Zy9CdWdJbXBvcnRlZC5nZXRTdHJpbmcgbXVzdCBub3QgYmUgbnVsbAgAEQEA
        FShMamF2YS9sYW5nL1N0cmluZzspVgwABgATCgAQABQBAAAIABYBAB9qYXZhL2xhbmcvSWxsZWdh
        bFN0YXRlRXhjZXB0aW9uBwAYAQA+QE5vdE51bGwgbWV0aG9kIGJ1Zy9CdWdJbXBvcnRlZC5nZXRT
        dHJpbmcgbXVzdCBub3QgcmV0dXJuIG51bGwIABoKABkAFAEABnN0cmluZwEAEkxqYXZhL2xhbmcv
        U3RyaW5nOwEAEGphdmEvbGFuZy9TdHJpbmcHAB8BAARtYWluAQAWKFtMamF2YS9sYW5nL1N0cmlu
        ZzspVgEAEGphdmEvbGFuZy9TeXN0ZW0HACMBAANvdXQBABVMamF2YS9pby9QcmludFN0cmVhbTsM
        ACUAJgkAJAAnDAAMAA0KAAIAKQEAE2phdmEvaW8vUHJpbnRTdHJlYW0HACsBAAdwcmludGxuDAAt
        ABMKACwALgEABGFyZ3MBABNbTGphdmEvbGFuZy9TdHJpbmc7AQAEQ29kZQEAEkxvY2FsVmFyaWFi
        bGVUYWJsZQEAD0xpbmVOdW1iZXJUYWJsZQEADVN0YWNrTWFwVGFibGUBABtSdW50aW1lSW52aXNp
        YmxlQW5ub3RhdGlvbnMBACRSdW50aW1lSW52aXNpYmxlUGFyYW1ldGVyQW5ub3RhdGlvbnMBABBN
        ZXRob2RQYXJhbWV0ZXJzAQAKU291cmNlRmlsZQAhAAIABAAAAAAAAwABAAYABwABADIAAAAvAAEA
        AQAAAAUqtwAJsQAAAAIAMwAAAAwAAQAAAAUACgALAAAANAAAAAYAAQAAAAUACgAMAA0ABAAyAAAA
        VgAEAAEAAAAfKscADbsAEFkSErcAFb8SF1nHAA27ABlZEhu3ABy/sAAAAAMAMwAAAAwAAQAAAB8A
        HQAeAAAANAAAAAYAAQAOAAoANQAAAAcAAg5PBwAgADYAAAAGAAEADgAAADcAAAAHAQABAA4AAAA4
        AAAABQEAEQAQAAkAIQAiAAIAMgAAADoAAgABAAAADLIAKBIXuAAqtgAvsQAAAAIAMwAAAAwAAQAA
        AAwAMAAxAAAANAAAAAoAAgAAABAACwARADgAAAAFAQAZAAAAAQA5AAAAAgAF


        ---- File Bug.java

        package bug;

        import bug.BugImported;

        public class Bug
        {
        }


        --- For reference, file BugImported.java

        package bug;

        import org.jetbrains.annotations.NotNull;

        public class BugImported
        {
        @NotNull
        private static String getString (@NotNull final String string)
        {
        return "";
        }


        public static void main (String[] args)
        {
        System.out.println (getString (""));
        }

        }

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

        CUSTOMER SUBMITTED WORKAROUND :
        Disable "Add @NotNull assertions" in compile options for IntelliJIdea

              pgovereau Paul Govereau (Inactive)
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: