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

ClassCastException in case of service implementation is nested static class

    XMLWordPrintable

Details

    Description

      Compiler throw ClassCastException if in module-info file there is provides statement with nested static class as service implementation.

      Message:
      An exception has occurred in the compiler (9-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: com.sun.tools.javac.code.Symbol$ClassSymbol (in module: jdk.compiler) cannot be cast to com.sun.tools.javac.code.Symbol$PackageSymbol (in module: jdk.compiler) at com.sun.tools.javac.comp.Modules$UsesProvidesVisitor.checkForCorrectness(jdk.compiler@9-ea/Modules.java:689) at com.sun.tools.javac.comp.Modules.lambda$getUsesProvidesCompleter$1(jdk.compiler@9-ea/Modules.java:579) at com.sun.tools.javac.code.Symbol$ModuleSymbol.completeUsesProvides(jdk.compiler@9-ea/Symbol.java:939) at com.sun.tools.javac.comp.Attr.visitModuleDef(jdk.compiler@9-ea/Attr.java:4401) at com.sun.tools.javac.tree.JCTree$JCModuleDecl.accept(jdk.compiler@9-ea/JCTree.java:2627) at com.sun.tools.javac.comp.Attr$ResultInfo.attr(jdk.compiler@9-ea/Attr.java:504) at com.sun.tools.javac.comp.Attr.attribTree(jdk.compiler@9-ea/Attr.java:642) at com.sun.tools.javac.comp.Attr.attribStat(jdk.compiler@9-ea/Attr.java:711) at com.sun.tools.javac.comp.Attr.attribModule(jdk.compiler@9-ea/Attr.java:4299) at com.sun.tools.javac.comp.Attr.attribModule(jdk.compiler@9-ea/Attr.java:4289) at com.sun.tools.javac.comp.Attr.attrib(jdk.compiler@9-ea/Attr.java:4263) at com.sun.tools.javac.main.JavaCompiler.attribute(jdk.compiler@9-ea/JavaCompiler.java:1330) at com.sun.tools.javac.main.JavaCompiler.compile(jdk.compiler@9-ea/JavaCompiler.java:958) at com.sun.tools.javac.main.Main.compile(jdk.compiler@9-ea/Main.java:261) at com.sun.tools.javac.main.Main.compile(jdk.compiler@9-ea/Main.java:143) at com.sun.tools.javac.Main.compile(jdk.compiler@9-ea/Main.java:55) at com.sun.tools.javac.Main.main(jdk.compiler@9-ea/Main.java:41)

      -----------------------
      Minimal case:

      Directory layout:
      mod1/module-info.java
      mod1/pack1/Outer.java
      mod1/pack1/Inter.java

      Code:
      mod1/module-info.java:
               
      module mod1 {
          provides pack1.Inter with pack1.Outer.A;
      }
            
      mod1/pack1/Inter.java:

      package pack1;
      public interface Inter {
      }
        
      mod1/pack1/Outer.java:

      package pack1;
      public class Outer {
          public static class A implements pack1.Inter {}
      }

      Attachments

        Activity

          People

            vromero Vicente Arturo Romero Zaldivar
            kbarzilovich Konstantin Barzilovich (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: