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

functional interface causes ClassCastException when extending raw superinterface

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 9
    • 8
    • tools
    • b122
    • x86_64
    • linux
    • Verified

    Description

      FULL PRODUCT VERSION :
      java version "1.8.0"
      Java(TM) SE Runtime Environment (build 1.8.0-b132)
      Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux yolo 3.5.0-45-generic #68-Ubuntu SMP Mon Dec 2 21:58:52 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

      OS X-version: 10.9.2 (Darwin Kernel Version 13.1.0: Thu Jan 16 19:40:37 PST 2014; root:xnu-2422.90.20~2/RELEASE_X86_64 x86_64)

      A DESCRIPTION OF THE PROBLEM :
      Javac generates an exception when using the FunctionalInterface-annotation for an interface extending two or more generic superinterfaces, where at least one of them is used without explicit type arguments.

      ADDITIONAL REGRESSION INFORMATION:
      The test case compiled in javac 1.8.0-ea

      java version "1.8.0"
      Java(TM) SE Runtime Environment (build 1.8.0-b132)
      Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)

      javac 1.8.0

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile the test case with javac.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Compile was expected to pass.
      ACTUAL -
      Compile failed with a ClassCastException.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      An exception has occurred in the compiler (1.8.0). 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.ClassCastException: com.sun.tools.javac.code.Type$MethodType cannot be cast to com.sun.tools.javac.code.Type$ForAll
              at com.sun.tools.javac.code.Types$DescriptorCache.mergeDescriptors(Types.java:521)
              at com.sun.tools.javac.code.Types$DescriptorCache.findDescriptorInternal(Types.java:433)
              at com.sun.tools.javac.code.Types$DescriptorCache.get(Types.java:394)
              at com.sun.tools.javac.code.Types.findDescriptorSymbol(Types.java:562)
              at com.sun.tools.javac.comp.Check.checkFunctionalInterface(Check.java:3515)
              at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4219)
              at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4149)
              at com.sun.tools.javac.comp.Attr.visitClassDef(Attr.java:877)
              at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:687)
              at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:596)
              at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:665)
              at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4305)
              at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4215)
              at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4149)
              at com.sun.tools.javac.comp.Attr.attrib(Attr.java:4124)
              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)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.util.*;
      import java.io.Serializable;

      class Test {
              interface X<A> { <T extends A> void execute(int a); }
              interface Y<B> { <S extends B> void execute(int a); }

              @FunctionalInterface
              interface Exec<A> extends Y, X<A> { }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      Use the superinterfaces with explicit type arguments.

      Attachments

        Activity

          People

            vromero Vicente Arturo Romero Zaldivar
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: