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

    • Bug
    • Resolution: Cannot Reproduce
    • P3
    • 9
    • 8
    • core-svc
    • 8
    • generic
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: