equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
280 /* |
280 /* |
281 * Method must be in this object's class, a superclass, or |
281 * Method must be in this object's class, a superclass, or |
282 * implemented interface |
282 * implemented interface |
283 */ |
283 */ |
284 ReferenceTypeImpl declType = (ReferenceTypeImpl)method.declaringType(); |
284 ReferenceTypeImpl declType = (ReferenceTypeImpl)method.declaringType(); |
|
285 |
285 if (!declType.isAssignableFrom(this)) { |
286 if (!declType.isAssignableFrom(this)) { |
286 throw new IllegalArgumentException("Invalid method"); |
287 throw new IllegalArgumentException("Invalid method"); |
287 } |
288 } |
288 |
289 |
289 if (declType instanceof ClassTypeImpl) { |
290 if (declType instanceof ClassTypeImpl) { |
309 } |
310 } |
310 |
311 |
311 /* |
312 /* |
312 * For nonvirtual invokes, method must have a body |
313 * For nonvirtual invokes, method must have a body |
313 */ |
314 */ |
314 if ((options & INVOKE_NONVIRTUAL) != 0) { |
315 if (isNonVirtual(options)) { |
315 if (method.isAbstract()) { |
316 if (method.isAbstract()) { |
316 throw new IllegalArgumentException("Abstract method"); |
317 throw new IllegalArgumentException("Abstract method"); |
317 } |
318 } |
318 } |
319 } |
319 |
320 |
321 * Get the class containing the method that will be invoked. |
322 * Get the class containing the method that will be invoked. |
322 * This class is needed only for proper validation of the |
323 * This class is needed only for proper validation of the |
323 * method argument types. |
324 * method argument types. |
324 */ |
325 */ |
325 ClassTypeImpl invokedClass; |
326 ClassTypeImpl invokedClass; |
326 if ((options & INVOKE_NONVIRTUAL) != 0) { |
327 if (isNonVirtual(options)) { |
327 // No overrides in non-virtual invokes |
328 // No overrides in non-virtual invokes |
328 invokedClass = clazz; |
329 invokedClass = clazz; |
329 } else { |
330 } else { |
330 /* |
331 /* |
331 * For virtual invokes, find any override of the method. |
332 * For virtual invokes, find any override of the method. |
346 throws InvalidTypeException, |
347 throws InvalidTypeException, |
347 InvocationException { |
348 InvocationException { |
348 /* |
349 /* |
349 * Only default methods allowed for nonvirtual invokes |
350 * Only default methods allowed for nonvirtual invokes |
350 */ |
351 */ |
351 if (!method.isDefault()) { |
352 if (isNonVirtual(options) && !method.isDefault()) { |
352 throw new IllegalArgumentException("Not a default method"); |
353 throw new IllegalArgumentException("Not a default method"); |
353 } |
354 } |
354 } |
355 } |
355 |
356 |
356 PacketStream sendInvokeCommand(final ThreadReferenceImpl thread, |
357 PacketStream sendInvokeCommand(final ThreadReferenceImpl thread, |
381 List<? extends Value> origArguments, int options) |
382 List<? extends Value> origArguments, int options) |
382 throws InvalidTypeException, |
383 throws InvalidTypeException, |
383 IncompatibleThreadStateException, |
384 IncompatibleThreadStateException, |
384 InvocationException, |
385 InvocationException, |
385 ClassNotLoadedException { |
386 ClassNotLoadedException { |
|
387 |
386 validateMirror(threadIntf); |
388 validateMirror(threadIntf); |
387 validateMirror(methodIntf); |
389 validateMirror(methodIntf); |
388 validateMirrorsOrNulls(origArguments); |
390 validateMirrorsOrNulls(origArguments); |
389 |
391 |
390 MethodImpl method = (MethodImpl)methodIntf; |
392 MethodImpl method = (MethodImpl)methodIntf; |
622 } |
624 } |
623 |
625 |
624 byte typeValueKey() { |
626 byte typeValueKey() { |
625 return JDWP.Tag.OBJECT; |
627 return JDWP.Tag.OBJECT; |
626 } |
628 } |
|
629 |
|
630 private static boolean isNonVirtual(int options) { |
|
631 return (options & INVOKE_NONVIRTUAL) != 0; |
|
632 } |
627 } |
633 } |