--- a/jdk/src/share/classes/com/sun/tools/jdi/ObjectReferenceImpl.java Mon Apr 28 13:49:49 2014 +0100
+++ b/jdk/src/share/classes/com/sun/tools/jdi/ObjectReferenceImpl.java Tue Apr 29 11:15:21 2014 +0200
@@ -277,7 +277,6 @@
void validateMethodInvocation(Method method, int options)
throws InvalidTypeException,
InvocationException {
-
/*
* Method must be in this object's class, a superclass, or
* implemented interface
@@ -287,6 +286,19 @@
throw new IllegalArgumentException("Invalid method");
}
+ if (declType instanceof ClassTypeImpl) {
+ validateClassMethodInvocation(method, options);
+ } else if (declType instanceof InterfaceTypeImpl) {
+ validateIfaceMethodInvocation(method, options);
+ } else {
+ throw new InvalidTypeException();
+ }
+ }
+
+ void validateClassMethodInvocation(Method method, int options)
+ throws InvalidTypeException,
+ InvocationException {
+
ClassTypeImpl clazz = invokableReferenceType(method);
/*
@@ -300,9 +312,7 @@
* For nonvirtual invokes, method must have a body
*/
if ((options & INVOKE_NONVIRTUAL) != 0) {
- if (method.declaringType() instanceof InterfaceType) {
- throw new IllegalArgumentException("Interface method");
- } else if (method.isAbstract()) {
+ if (method.isAbstract()) {
throw new IllegalArgumentException("Abstract method");
}
}
@@ -324,7 +334,7 @@
*/
Method invoker = clazz.concreteMethodByName(method.name(),
method.signature());
- // isAssignableFrom check above guarantees non-null
+ // invoker is supposed to be non-null under normal circumstances
invokedClass = (ClassTypeImpl)invoker.declaringType();
}
/* The above code is left over from previous versions.
@@ -332,6 +342,17 @@
*/
}
+ void validateIfaceMethodInvocation(Method method, int options)
+ throws InvalidTypeException,
+ InvocationException {
+ /*
+ * Only default methods allowed for nonvirtual invokes
+ */
+ if (!method.isDefault()) {
+ throw new IllegalArgumentException("Not a default method");
+ }
+ }
+
PacketStream sendInvokeCommand(final ThreadReferenceImpl thread,
final ClassTypeImpl refType,
final MethodImpl method,
@@ -370,7 +391,10 @@
ThreadReferenceImpl thread = (ThreadReferenceImpl)threadIntf;
if (method.isStatic()) {
- if (referenceType() instanceof ClassType) {
+ if (referenceType() instanceof InterfaceType) {
+ InterfaceType type = (InterfaceType)referenceType();
+ return type.invokeMethod(thread, method, origArguments, options);
+ } else if (referenceType() instanceof ClassType) {
ClassType type = (ClassType)referenceType();
return type.invokeMethod(thread, method, origArguments, options);
} else {