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

ClassCastException: com.sun.tools.jdi.InterfaceTypeImpl cannot be cast to com.sun.tools.jdi.ClassTypeImpl

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Cannot Reproduce
    • Affects Version/s: 8
    • Fix Version/s: 9
    • Component/s: core-svc
    • Labels:
    • Subcomponent:
    • Introduced In Version:
      8
    • CPU:
      generic
    • OS:
      generic

      Description

      In ObjectReferenceImpl.validateMethodInvocation() it is expected, that the method invoker is declared in a ClassType. However, this is not the case for default methods in interfaces in Java 8.

      Following exception is thrown when invoking a default method of an interface via debugger:

      java.lang.ClassCastException: com.sun.tools.jdi.InterfaceTypeImpl cannot be cast to com.sun.tools.jdi.ClassTypeImpl
         at com.sun.tools.jdi.ObjectReferenceImpl.validateMethodInvocation(ObjectReferenceImpl.java:328)
         at com.sun.tools.jdi.ObjectReferenceImpl.invokeMethod(ObjectReferenceImpl.java:381)

      A project that can be used to reproduce this issue is attached. Stop on line 19 and evaluate "c.getId()".

      Can be reproduced via jdb:
      $ java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=4567 -classpath build/classes interfacemethods.InterfaceMethods

      $ jdb -attach 4567
      main[1] stop at interfacemethods.InterfaceMethods:19
      main[1] cont
      Breakpoint hit: "thread=main", interfacemethods.InterfaceMethods.main(), line=19 bci=8

      main[1] print c.getId()
      java.lang.ClassCastException: com.sun.tools.jdi.InterfaceTypeImpl cannot be cast to com.sun.tools.jdi.ClassTypeImpl
       c.getId() = null

        Attachments

          Activity

            People

            Assignee:
            hb Harsha Wardhana B (Inactive)
            Reporter:
            mentlich Martin Entlicher
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: