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

regression: CCE (Type$ErrorType cannot be cast to Type$ArrayType) when using annotation processor for a method with unresolvable vararg parameter type

    Details

    • Type: Bug
    • Status: New
    • Priority: P2
    • Resolution: Unresolved
    • Affects Version/s: 10
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:

      Description

      The following code calling JSR#269/199 API programmatically causes compiler crash in JDK10 b25+. It just prints error as expected when run on JDK10b24 and on earlier builds (including JDK9)

      === full source attached to the bug ==
              JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
              JavaCompiler.CompilationTask task =
                  javac.getTask(new OutputStreamWriter(System.err),
                  javac.getStandardFileManager(null, null, null),
                  null, List.of(), null, List.of(
                      new SimpleJavaFileObject(URI.create(""), JavaFileObject.Kind.SOURCE) {
                          @Override public CharSequence getCharContent(boolean ignoreEncodingErrors) {
                              return "class C { void m(Unkn... own) { } }";
                          }
                      })
                  );
              task.setProcessors(List.of(new AbstractProcessor() {
                  @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
                      return false;
                  }
              }));
              task.call();
      =============================

      JDK10b25+:
      -----------------------------------
      An exception has occurred in the compiler (10-ea). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you.
      java.lang.ClassCastException: jdk.compiler/com.sun.tools.javac.code.Type$ErrorType cannot be cast to jdk.compiler/com.sun.tools.javac.code.Type$ArrayType
      at jdk.compiler/com.sun.tools.javac.comp.MemberEnter.visitVarDef(MemberEnter.java:278)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:956)
      at jdk.compiler/com.sun.tools.javac.comp.MemberEnter.memberEnter(MemberEnter.java:162)
      at jdk.compiler/com.sun.tools.javac.comp.MemberEnter.signature(MemberEnter.java:110)
      at jdk.compiler/com.sun.tools.javac.comp.MemberEnter.visitMethodDef(MemberEnter.java:192)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:866)
      at jdk.compiler/com.sun.tools.javac.comp.MemberEnter.memberEnter(MemberEnter.java:162)
      at jdk.compiler/com.sun.tools.javac.comp.MemberEnter.memberEnter(MemberEnter.java:174)
      at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$MembersPhase.finishClass(TypeEnter.java:955)
      at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$MembersPhase.runPhase(TypeEnter.java:939)
      at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$Phase.doCompleteEnvs(TypeEnter.java:279)
      at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$MembersPhase.doCompleteEnvs(TypeEnter.java:874)
      at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$Phase.completeEnvs(TypeEnter.java:248)
      at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$Phase.completeEnvs(TypeEnter.java:263)
      at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$Phase.completeEnvs(TypeEnter.java:263)
      at jdk.compiler/com.sun.tools.javac.comp.TypeEnter$Phase.completeEnvs(TypeEnter.java:263)
      at jdk.compiler/com.sun.tools.javac.comp.TypeEnter.complete(TypeEnter.java:197)
      at jdk.compiler/com.sun.tools.javac.code.Symbol.complete(Symbol.java:633)
      at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1308)
      at jdk.compiler/com.sun.tools.javac.comp.Enter.complete(Enter.java:577)
      at jdk.compiler/com.sun.tools.javac.comp.Enter.main(Enter.java:554)
      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:1057)
      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:928)
      at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:100)
      at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:142)
      at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:96)
      at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:90)
      at temp.Temp.main(Temp.java:35)
      -----------------------------------

      JDK10b24 and below:
      -----------------------------------
      warning: No SupportedSourceVersion annotation found on temp.Temp$2, returning RELEASE_6.
      warning: Supported source version 'RELEASE_6' from annotation processor 'temp.Temp$2' less than -source '1.10'
      warning: No SupportedAnnotationTypes annotation found on temp.Temp$2, returning an empty set.
      :1: error: cannot find symbol
      class C { void m(Unkn... own) { } }
                       ^
        symbol: class Unkn
        location: class C
      1 error
      3 warnings
      -----------------------------------


      1. Temp.java
        1 kB
        Dmitry Bessonov

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            dbessono Dmitry Bessonov
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: