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
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