com.sun.jdi.InvalidTypeException Java Examples
The following examples show how to use
com.sun.jdi.InvalidTypeException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EvaluationContext.java From netbeans with Apache License 2.0 | 6 votes |
@Override public void setValue(Value value) { try { if (fieldObject != null) { fieldObject.setValue(field, value); } else { ((ClassType) field.declaringType()).setValue(field, value); } } catch (IllegalArgumentException iaex) { throw new IllegalStateException(new InvalidExpressionException (iaex)); } catch (InvalidTypeException itex) { throw new IllegalStateException(new InvalidExpressionException (itex)); } catch (ClassNotLoadedException cnlex) { throw new IllegalStateException(cnlex); } }
Example #2
Source File: SetVariableRequestHandler.java From java-debug with Eclipse Public License 1.0 | 6 votes |
private Value handleSetValueForObject(String name, String belongToClass, String valueString, ObjectReference container, Map<String, Object> options) throws InvalidTypeException, ClassNotLoadedException { Value newValue; if (container instanceof ArrayReference) { ArrayReference array = (ArrayReference) container; Type eleType = ((ArrayType) array.referenceType()).componentType(); newValue = setArrayValue(array, eleType, Integer.parseInt(name), valueString, options); } else { if (StringUtils.isBlank(belongToClass)) { Field field = container.referenceType().fieldByName(name); if (field != null) { if (field.isStatic()) { newValue = this.setStaticFieldValue(container.referenceType(), field, name, valueString, options); } else { newValue = this.setObjectFieldValue(container, field, name, valueString, options); } } else { throw new IllegalArgumentException( String.format("SetVariableRequest: Variable %s cannot be found.", name)); } } else { newValue = setFieldValueWithConflict(container, container.referenceType().allFields(), name, belongToClass, valueString, options); } } return newValue; }
Example #3
Source File: StepIntoScriptHandler.java From netbeans with Apache License 2.0 | 6 votes |
@Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getNewValue() == null) { // Ignore resume. return ; } LOG.fine("Current frame changed>"); if (steppingField != null) { try { serviceClass.setValue(steppingField, serviceClass.virtualMachine().mirrorOf(-1)); steppingField = null; RemoteServices.interruptServiceAccessThread(debugger); LOG.fine("StepIntoScriptHandler: isSteppingInto set to false."); } catch (InvalidTypeException | ClassNotLoadedException ex) { Exceptions.printStackTrace(ex); } } else { // Cancel step into when the service is created DebugManagerHandler.execStepInto(debugger, false); } }
Example #4
Source File: SetVariableRequestHandler.java From java-debug with Eclipse Public License 1.0 | 6 votes |
private Value setFieldValueWithConflict(ObjectReference obj, List<Field> fields, String name, String belongToClass, String value, Map<String, Object> options) throws ClassNotLoadedException, InvalidTypeException { Field field; // first try to resolve field by fully qualified name List<Field> narrowedFields = fields.stream().filter(TypeComponent::isStatic) .filter(t -> t.name().equals(name) && t.declaringType().name().equals(belongToClass)) .collect(Collectors.toList()); if (narrowedFields.isEmpty()) { // second try to resolve field by formatted name narrowedFields = fields.stream().filter(TypeComponent::isStatic) .filter(t -> t.name().equals(name) && context.getVariableFormatter().typeToString(t.declaringType(), options).equals(belongToClass)) .collect(Collectors.toList()); } if (narrowedFields.size() == 1) { field = narrowedFields.get(0); } else { throw new UnsupportedOperationException(String.format("SetVariableRequest: Name conflicted for %s.", name)); } return field.isStatic() ? setStaticFieldValue(field.declaringType(), field, name, value, options) : this.setObjectFieldValue(obj, field, name, value, options); }
Example #5
Source File: SetVariableRequestHandler.java From java-debug with Eclipse Public License 1.0 | 5 votes |
private Value setObjectFieldValue(ObjectReference obj, Field field, String name, String value, Map<String, Object> options) throws ClassNotLoadedException, InvalidTypeException { if (field.isFinal()) { throw new UnsupportedOperationException( String.format("SetVariableRequest: Final field %s cannot be changed.", name)); } return setValueProxy(field.type(), value, newValue -> obj.setValue(field, newValue), options); }
Example #6
Source File: InvokableTypeImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Method invocation support. * Shared by ClassType and InterfaceType * @param threadIntf the thread in which to invoke. * @param methodIntf method the {@link Method} to invoke. * @param origArguments the list of {@link Value} arguments bound to the * invoked method. Values from the list are assigned to arguments * in the order they appear in the method signature. * @param options the integer bit flag options. * @return a {@link Value} mirror of the invoked method's return value. * @throws java.lang.IllegalArgumentException if the method is not * a member of this type, if the size of the argument list * does not match the number of declared arguments for the method, or * if the method is not static or is a static initializer. * @throws {@link InvalidTypeException} if any argument in the * argument list is not assignable to the corresponding method argument * type. * @throws ClassNotLoadedException if any argument type has not yet been loaded * through the appropriate class loader. * @throws IncompatibleThreadStateException if the specified thread has not * been suspended by an event. * @throws InvocationException if the method invocation resulted in * an exception in the target VM. * @throws InvalidTypeException If the arguments do not meet this requirement -- * Object arguments must be assignment compatible with the argument * type. This implies that the argument type must be * loaded through the enclosing class's class loader. * Primitive arguments must be either assignment compatible with the * argument type or must be convertible to the argument type without loss * of information. See JLS section 5.2 for more information on assignment * compatibility. * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}. */ final public Value invokeMethod(ThreadReference threadIntf, Method methodIntf, List<? extends Value> origArguments, int options) throws InvalidTypeException, ClassNotLoadedException, IncompatibleThreadStateException, InvocationException { validateMirror(threadIntf); validateMirror(methodIntf); validateMirrorsOrNulls(origArguments); MethodImpl method = (MethodImpl) methodIntf; ThreadReferenceImpl thread = (ThreadReferenceImpl) threadIntf; validateMethodInvocation(method); List<? extends Value> arguments = method.validateAndPrepareArgumentsForInvoke(origArguments); ValueImpl[] args = arguments.toArray(new ValueImpl[0]); InvocationResult ret; try { PacketStream stream = sendInvokeCommand(thread, method, args, options); ret = waitForReply(stream); } catch (JDWPException exc) { if (exc.errorCode() == JDWP.Error.INVALID_THREAD) { throw new IncompatibleThreadStateException(); } else { throw exc.toJDIException(); } } /* * There is an implict VM-wide suspend at the conclusion * of a normal (non-single-threaded) method invoke */ if ((options & ClassType.INVOKE_SINGLE_THREADED) == 0) { vm.notifySuspend(); } if (ret.getException() != null) { throw new InvocationException(ret.getException()); } else { return ret.getResult(); } }
Example #7
Source File: InvokableTypeImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private void validateMethodInvocation(Method method) throws InvalidTypeException, InvocationException { if (!canInvoke(method)) { throw new IllegalArgumentException("Invalid method"); } /* * Method must be a static and not a static initializer */ if (!method.isStatic()) { throw new IllegalArgumentException("Cannot invoke instance method on a class/interface type"); } else if (method.isStaticInitializer()) { throw new IllegalArgumentException("Cannot invoke static initializer"); } }
Example #8
Source File: InvokableTypeImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Method invocation support. * Shared by ClassType and InterfaceType * @param threadIntf the thread in which to invoke. * @param methodIntf method the {@link Method} to invoke. * @param origArguments the list of {@link Value} arguments bound to the * invoked method. Values from the list are assigned to arguments * in the order they appear in the method signature. * @param options the integer bit flag options. * @return a {@link Value} mirror of the invoked method's return value. * @throws java.lang.IllegalArgumentException if the method is not * a member of this type, if the size of the argument list * does not match the number of declared arguments for the method, or * if the method is not static or is a static initializer. * @throws {@link InvalidTypeException} if any argument in the * argument list is not assignable to the corresponding method argument * type. * @throws ClassNotLoadedException if any argument type has not yet been loaded * through the appropriate class loader. * @throws IncompatibleThreadStateException if the specified thread has not * been suspended by an event. * @throws InvocationException if the method invocation resulted in * an exception in the target VM. * @throws InvalidTypeException If the arguments do not meet this requirement -- * Object arguments must be assignment compatible with the argument * type. This implies that the argument type must be * loaded through the enclosing class's class loader. * Primitive arguments must be either assignment compatible with the * argument type or must be convertible to the argument type without loss * of information. See JLS section 5.2 for more information on assignment * compatibility. * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}. */ final public Value invokeMethod(ThreadReference threadIntf, Method methodIntf, List<? extends Value> origArguments, int options) throws InvalidTypeException, ClassNotLoadedException, IncompatibleThreadStateException, InvocationException { validateMirror(threadIntf); validateMirror(methodIntf); validateMirrorsOrNulls(origArguments); MethodImpl method = (MethodImpl) methodIntf; ThreadReferenceImpl thread = (ThreadReferenceImpl) threadIntf; validateMethodInvocation(method); List<? extends Value> arguments = method.validateAndPrepareArgumentsForInvoke(origArguments); ValueImpl[] args = arguments.toArray(new ValueImpl[0]); InvocationResult ret; try { PacketStream stream = sendInvokeCommand(thread, method, args, options); ret = waitForReply(stream); } catch (JDWPException exc) { if (exc.errorCode() == JDWP.Error.INVALID_THREAD) { throw new IncompatibleThreadStateException(); } else { throw exc.toJDIException(); } } /* * There is an implict VM-wide suspend at the conclusion * of a normal (non-single-threaded) method invoke */ if ((options & ClassType.INVOKE_SINGLE_THREADED) == 0) { vm.notifySuspend(); } if (ret.getException() != null) { throw new InvocationException(ret.getException()); } else { return ret.getResult(); } }
Example #9
Source File: InvokableTypeImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private void validateMethodInvocation(Method method) throws InvalidTypeException, InvocationException { if (!canInvoke(method)) { throw new IllegalArgumentException("Invalid method"); } /* * Method must be a static and not a static initializer */ if (!method.isStatic()) { throw new IllegalArgumentException("Cannot invoke instance method on a class/interface type"); } else if (method.isStaticInitializer()) { throw new IllegalArgumentException("Cannot invoke static initializer"); } }
Example #10
Source File: InvokableTypeImpl.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Method invocation support. * Shared by ClassType and InterfaceType * @param threadIntf the thread in which to invoke. * @param methodIntf method the {@link Method} to invoke. * @param origArguments the list of {@link Value} arguments bound to the * invoked method. Values from the list are assigned to arguments * in the order they appear in the method signature. * @param options the integer bit flag options. * @return a {@link Value} mirror of the invoked method's return value. * @throws java.lang.IllegalArgumentException if the method is not * a member of this type, if the size of the argument list * does not match the number of declared arguments for the method, or * if the method is not static or is a static initializer. * @throws {@link InvalidTypeException} if any argument in the * argument list is not assignable to the corresponding method argument * type. * @throws ClassNotLoadedException if any argument type has not yet been loaded * through the appropriate class loader. * @throws IncompatibleThreadStateException if the specified thread has not * been suspended by an event. * @throws InvocationException if the method invocation resulted in * an exception in the target VM. * @throws InvalidTypeException If the arguments do not meet this requirement -- * Object arguments must be assignment compatible with the argument * type. This implies that the argument type must be * loaded through the enclosing class's class loader. * Primitive arguments must be either assignment compatible with the * argument type or must be convertible to the argument type without loss * of information. See JLS section 5.2 for more information on assignment * compatibility. * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}. */ final public Value invokeMethod(ThreadReference threadIntf, Method methodIntf, List<? extends Value> origArguments, int options) throws InvalidTypeException, ClassNotLoadedException, IncompatibleThreadStateException, InvocationException { validateMirror(threadIntf); validateMirror(methodIntf); validateMirrorsOrNulls(origArguments); MethodImpl method = (MethodImpl) methodIntf; ThreadReferenceImpl thread = (ThreadReferenceImpl) threadIntf; validateMethodInvocation(method); List<? extends Value> arguments = method.validateAndPrepareArgumentsForInvoke(origArguments); ValueImpl[] args = arguments.toArray(new ValueImpl[0]); InvocationResult ret; try { PacketStream stream = sendInvokeCommand(thread, method, args, options); ret = waitForReply(stream); } catch (JDWPException exc) { if (exc.errorCode() == JDWP.Error.INVALID_THREAD) { throw new IncompatibleThreadStateException(); } else { throw exc.toJDIException(); } } /* * There is an implict VM-wide suspend at the conclusion * of a normal (non-single-threaded) method invoke */ if ((options & ClassType.INVOKE_SINGLE_THREADED) == 0) { vm.notifySuspend(); } if (ret.getException() != null) { throw new InvocationException(ret.getException()); } else { return ret.getResult(); } }
Example #11
Source File: InvokableTypeImpl.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private void validateMethodInvocation(Method method) throws InvalidTypeException, InvocationException { if (!canInvoke(method)) { throw new IllegalArgumentException("Invalid method"); } /* * Method must be a static and not a static initializer */ if (!method.isStatic()) { throw new IllegalArgumentException("Cannot invoke instance method on a class/interface type"); } else if (method.isStaticInitializer()) { throw new IllegalArgumentException("Cannot invoke static initializer"); } }
Example #12
Source File: SetVariableRequestHandler.java From java-debug with Eclipse Public License 1.0 | 5 votes |
private Value handleSetValueForStackFrame(String name, String belongToClass, String valueString, boolean showStaticVariables, StackFrame container, Map<String, Object> options) throws AbsentInformationException, InvalidTypeException, ClassNotLoadedException { Value newValue; if (name.equals("this")) { throw new UnsupportedOperationException("SetVariableRequest: 'This' variable cannot be changed."); } LocalVariable variable = container.visibleVariableByName(name); if (StringUtils.isBlank(belongToClass) && variable != null) { newValue = this.setFrameValue(container, variable, valueString, options); } else { if (showStaticVariables && container.location().method().isStatic()) { ReferenceType type = container.location().declaringType(); if (StringUtils.isBlank(belongToClass)) { Field field = type.fieldByName(name); newValue = setStaticFieldValue(type, field, name, valueString, options); } else { newValue = setFieldValueWithConflict(null, type.allFields(), name, belongToClass, valueString, options); } } else { throw new UnsupportedOperationException( String.format("SetVariableRequest: Variable %s cannot be found.", name)); } } return newValue; }
Example #13
Source File: SetVariableRequestHandler.java From java-debug with Eclipse Public License 1.0 | 5 votes |
private Value setStaticFieldValue(Type declaringType, Field field, String name, String value, Map<String, Object> options) throws ClassNotLoadedException, InvalidTypeException { if (field.isFinal()) { throw new UnsupportedOperationException( String.format("SetVariableRequest: Final field %s cannot be changed.", name)); } if (!(declaringType instanceof ClassType)) { throw new UnsupportedOperationException( String.format("SetVariableRequest: Field %s in interface cannot be changed.", name)); } return setValueProxy(field.type(), value, newValue -> ((ClassType) declaringType).setValue(field, newValue), options); }
Example #14
Source File: InvokableTypeImpl.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private void validateMethodInvocation(Method method) throws InvalidTypeException, InvocationException { if (!canInvoke(method)) { throw new IllegalArgumentException("Invalid method"); } /* * Method must be a static and not a static initializer */ if (!method.isStatic()) { throw new IllegalArgumentException("Cannot invoke instance method on a class/interface type"); } else if (method.isStaticInitializer()) { throw new IllegalArgumentException("Cannot invoke static initializer"); } }
Example #15
Source File: ExceptionInfoRequestHandler.java From java-debug with Eclipse Public License 1.0 | 5 votes |
@Override public CompletableFuture<Response> handle(Command command, Arguments arguments, Response response, IDebugAdapterContext context) { ExceptionInfoArguments exceptionInfoArgs = (ExceptionInfoArguments) arguments; ThreadReference thread = DebugUtility.getThread(context.getDebugSession(), exceptionInfoArgs.threadId); if (thread == null) { throw AdapterUtils.createCompletionException("Thread " + exceptionInfoArgs.threadId + " doesn't exist.", ErrorCode.EXCEPTION_INFO_FAILURE); } JdiExceptionReference jdiException = context.getExceptionManager().getException(exceptionInfoArgs.threadId); if (jdiException == null) { throw AdapterUtils.createCompletionException("No exception exists in thread " + exceptionInfoArgs.threadId, ErrorCode.EXCEPTION_INFO_FAILURE); } Method toStringMethod = null; for (Method method : jdiException.exception.referenceType().allMethods()) { if (Objects.equals("toString", method.name()) && Objects.equals("()Ljava/lang/String;", method.signature())) { toStringMethod = method; break; } } String typeName = jdiException.exception.type().name(); String exceptionToString = typeName; if (toStringMethod != null) { try { Value returnValue = jdiException.exception.invokeMethod(thread, toStringMethod, Collections.EMPTY_LIST, ObjectReference.INVOKE_SINGLE_THREADED); exceptionToString = returnValue.toString(); } catch (InvalidTypeException | ClassNotLoadedException | IncompatibleThreadStateException | InvocationException e) { logger.log(Level.SEVERE, String.format("Failed to get the return value of the method Exception.toString(): %s", e.toString(), e)); } } response.body = new Responses.ExceptionInfoResponse(typeName, exceptionToString, jdiException.isUncaught ? ExceptionBreakMode.USERUNHANDLED : ExceptionBreakMode.ALWAYS); return CompletableFuture.completedFuture(response); }
Example #16
Source File: InvokableTypeImpl.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Method invocation support. * Shared by ClassType and InterfaceType * @param threadIntf the thread in which to invoke. * @param methodIntf method the {@link Method} to invoke. * @param origArguments the list of {@link Value} arguments bound to the * invoked method. Values from the list are assigned to arguments * in the order they appear in the method signature. * @param options the integer bit flag options. * @return a {@link Value} mirror of the invoked method's return value. * @throws java.lang.IllegalArgumentException if the method is not * a member of this type, if the size of the argument list * does not match the number of declared arguments for the method, or * if the method is not static or is a static initializer. * @throws {@link InvalidTypeException} if any argument in the * argument list is not assignable to the corresponding method argument * type. * @throws ClassNotLoadedException if any argument type has not yet been loaded * through the appropriate class loader. * @throws IncompatibleThreadStateException if the specified thread has not * been suspended by an event. * @throws InvocationException if the method invocation resulted in * an exception in the target VM. * @throws InvalidTypeException If the arguments do not meet this requirement -- * Object arguments must be assignment compatible with the argument * type. This implies that the argument type must be * loaded through the enclosing class's class loader. * Primitive arguments must be either assignment compatible with the * argument type or must be convertible to the argument type without loss * of information. See JLS section 5.2 for more information on assignment * compatibility. * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}. */ final public Value invokeMethod(ThreadReference threadIntf, Method methodIntf, List<? extends Value> origArguments, int options) throws InvalidTypeException, ClassNotLoadedException, IncompatibleThreadStateException, InvocationException { validateMirror(threadIntf); validateMirror(methodIntf); validateMirrorsOrNulls(origArguments); MethodImpl method = (MethodImpl) methodIntf; ThreadReferenceImpl thread = (ThreadReferenceImpl) threadIntf; validateMethodInvocation(method); List<? extends Value> arguments = method.validateAndPrepareArgumentsForInvoke(origArguments); ValueImpl[] args = arguments.toArray(new ValueImpl[0]); InvocationResult ret; try { PacketStream stream = sendInvokeCommand(thread, method, args, options); ret = waitForReply(stream); } catch (JDWPException exc) { if (exc.errorCode() == JDWP.Error.INVALID_THREAD) { throw new IncompatibleThreadStateException(); } else { throw exc.toJDIException(); } } /* * There is an implict VM-wide suspend at the conclusion * of a normal (non-single-threaded) method invoke */ if ((options & ClassType.INVOKE_SINGLE_THREADED) == 0) { vm.notifySuspend(); } if (ret.getException() != null) { throw new InvocationException(ret.getException()); } else { return ret.getResult(); } }
Example #17
Source File: InvokableTypeImpl.java From hottub with GNU General Public License v2.0 | 5 votes |
private void validateMethodInvocation(Method method) throws InvalidTypeException, InvocationException { if (!canInvoke(method)) { throw new IllegalArgumentException("Invalid method"); } /* * Method must be a static and not a static initializer */ if (!method.isStatic()) { throw new IllegalArgumentException("Cannot invoke instance method on a class/interface type"); } else if (method.isStaticInitializer()) { throw new IllegalArgumentException("Cannot invoke static initializer"); } }
Example #18
Source File: InvokableTypeImpl.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * Method invocation support. * Shared by ClassType and InterfaceType * @param threadIntf the thread in which to invoke. * @param methodIntf method the {@link Method} to invoke. * @param origArguments the list of {@link Value} arguments bound to the * invoked method. Values from the list are assigned to arguments * in the order they appear in the method signature. * @param options the integer bit flag options. * @return a {@link Value} mirror of the invoked method's return value. * @throws java.lang.IllegalArgumentException if the method is not * a member of this type, if the size of the argument list * does not match the number of declared arguments for the method, or * if the method is not static or is a static initializer. * @throws {@link InvalidTypeException} if any argument in the * argument list is not assignable to the corresponding method argument * type. * @throws ClassNotLoadedException if any argument type has not yet been loaded * through the appropriate class loader. * @throws IncompatibleThreadStateException if the specified thread has not * been suspended by an event. * @throws InvocationException if the method invocation resulted in * an exception in the target VM. * @throws InvalidTypeException If the arguments do not meet this requirement -- * Object arguments must be assignment compatible with the argument * type. This implies that the argument type must be * loaded through the enclosing class's class loader. * Primitive arguments must be either assignment compatible with the * argument type or must be convertible to the argument type without loss * of information. See JLS section 5.2 for more information on assignment * compatibility. * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}. */ final public Value invokeMethod(ThreadReference threadIntf, Method methodIntf, List<? extends Value> origArguments, int options) throws InvalidTypeException, ClassNotLoadedException, IncompatibleThreadStateException, InvocationException { validateMirror(threadIntf); validateMirror(methodIntf); validateMirrorsOrNulls(origArguments); MethodImpl method = (MethodImpl) methodIntf; ThreadReferenceImpl thread = (ThreadReferenceImpl) threadIntf; validateMethodInvocation(method); List<? extends Value> arguments = method.validateAndPrepareArgumentsForInvoke(origArguments); ValueImpl[] args = arguments.toArray(new ValueImpl[0]); InvocationResult ret; try { PacketStream stream = sendInvokeCommand(thread, method, args, options); ret = waitForReply(stream); } catch (JDWPException exc) { if (exc.errorCode() == JDWP.Error.INVALID_THREAD) { throw new IncompatibleThreadStateException(); } else { throw exc.toJDIException(); } } /* * There is an implict VM-wide suspend at the conclusion * of a normal (non-single-threaded) method invoke */ if ((options & ClassType.INVOKE_SINGLE_THREADED) == 0) { vm.notifySuspend(); } if (ret.getException() != null) { throw new InvocationException(ret.getException()); } else { return ret.getResult(); } }
Example #19
Source File: InvokableTypeImpl.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private void validateMethodInvocation(Method method) throws InvalidTypeException, InvocationException { if (!canInvoke(method)) { throw new IllegalArgumentException("Invalid method"); } /* * Method must be a static and not a static initializer */ if (!method.isStatic()) { throw new IllegalArgumentException("Cannot invoke instance method on a class/interface type"); } else if (method.isStaticInitializer()) { throw new IllegalArgumentException("Cannot invoke static initializer"); } }
Example #20
Source File: InvokableTypeImpl.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Method invocation support. * Shared by ClassType and InterfaceType * @param threadIntf the thread in which to invoke. * @param methodIntf method the {@link Method} to invoke. * @param origArguments the list of {@link Value} arguments bound to the * invoked method. Values from the list are assigned to arguments * in the order they appear in the method signature. * @param options the integer bit flag options. * @return a {@link Value} mirror of the invoked method's return value. * @throws java.lang.IllegalArgumentException if the method is not * a member of this type, if the size of the argument list * does not match the number of declared arguments for the method, or * if the method is not static or is a static initializer. * @throws {@link InvalidTypeException} if any argument in the * argument list is not assignable to the corresponding method argument * type. * @throws ClassNotLoadedException if any argument type has not yet been loaded * through the appropriate class loader. * @throws IncompatibleThreadStateException if the specified thread has not * been suspended by an event. * @throws InvocationException if the method invocation resulted in * an exception in the target VM. * @throws InvalidTypeException If the arguments do not meet this requirement -- * Object arguments must be assignment compatible with the argument * type. This implies that the argument type must be * loaded through the enclosing class's class loader. * Primitive arguments must be either assignment compatible with the * argument type or must be convertible to the argument type without loss * of information. See JLS section 5.2 for more information on assignment * compatibility. * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}. */ final public Value invokeMethod(ThreadReference threadIntf, Method methodIntf, List<? extends Value> origArguments, int options) throws InvalidTypeException, ClassNotLoadedException, IncompatibleThreadStateException, InvocationException { validateMirror(threadIntf); validateMirror(methodIntf); validateMirrorsOrNulls(origArguments); MethodImpl method = (MethodImpl) methodIntf; ThreadReferenceImpl thread = (ThreadReferenceImpl) threadIntf; validateMethodInvocation(method); List<? extends Value> arguments = method.validateAndPrepareArgumentsForInvoke(origArguments); ValueImpl[] args = arguments.toArray(new ValueImpl[0]); InvocationResult ret; try { PacketStream stream = sendInvokeCommand(thread, method, args, options); ret = waitForReply(stream); } catch (JDWPException exc) { if (exc.errorCode() == JDWP.Error.INVALID_THREAD) { throw new IncompatibleThreadStateException(); } else { throw exc.toJDIException(); } } /* * There is an implict VM-wide suspend at the conclusion * of a normal (non-single-threaded) method invoke */ if ((options & ClassType.INVOKE_SINGLE_THREADED) == 0) { vm.notifySuspend(); } if (ret.getException() != null) { throw new InvocationException(ret.getException()); } else { return ret.getResult(); } }
Example #21
Source File: InvokableTypeImpl.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private void validateMethodInvocation(Method method) throws InvalidTypeException, InvocationException { if (!canInvoke(method)) { throw new IllegalArgumentException("Invalid method"); } /* * Method must be a static and not a static initializer */ if (!method.isStatic()) { throw new IllegalArgumentException("Cannot invoke instance method on a class/interface type"); } else if (method.isStaticInitializer()) { throw new IllegalArgumentException("Cannot invoke static initializer"); } }
Example #22
Source File: InvokableTypeImpl.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
/** * Method invocation support. * Shared by ClassType and InterfaceType * @param threadIntf the thread in which to invoke. * @param methodIntf method the {@link Method} to invoke. * @param origArguments the list of {@link Value} arguments bound to the * invoked method. Values from the list are assigned to arguments * in the order they appear in the method signature. * @param options the integer bit flag options. * @return a {@link Value} mirror of the invoked method's return value. * @throws java.lang.IllegalArgumentException if the method is not * a member of this type, if the size of the argument list * does not match the number of declared arguments for the method, or * if the method is not static or is a static initializer. * @throws {@link InvalidTypeException} if any argument in the * argument list is not assignable to the corresponding method argument * type. * @throws ClassNotLoadedException if any argument type has not yet been loaded * through the appropriate class loader. * @throws IncompatibleThreadStateException if the specified thread has not * been suspended by an event. * @throws InvocationException if the method invocation resulted in * an exception in the target VM. * @throws InvalidTypeException If the arguments do not meet this requirement -- * Object arguments must be assignment compatible with the argument * type. This implies that the argument type must be * loaded through the enclosing class's class loader. * Primitive arguments must be either assignment compatible with the * argument type or must be convertible to the argument type without loss * of information. See JLS section 5.2 for more information on assignment * compatibility. * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}. */ final public Value invokeMethod(ThreadReference threadIntf, Method methodIntf, List<? extends Value> origArguments, int options) throws InvalidTypeException, ClassNotLoadedException, IncompatibleThreadStateException, InvocationException { validateMirror(threadIntf); validateMirror(methodIntf); validateMirrorsOrNulls(origArguments); MethodImpl method = (MethodImpl) methodIntf; ThreadReferenceImpl thread = (ThreadReferenceImpl) threadIntf; validateMethodInvocation(method); List<? extends Value> arguments = method.validateAndPrepareArgumentsForInvoke(origArguments); ValueImpl[] args = arguments.toArray(new ValueImpl[0]); InvocationResult ret; try { PacketStream stream = sendInvokeCommand(thread, method, args, options); ret = waitForReply(stream); } catch (JDWPException exc) { if (exc.errorCode() == JDWP.Error.INVALID_THREAD) { throw new IncompatibleThreadStateException(); } else { throw exc.toJDIException(); } } /* * There is an implict VM-wide suspend at the conclusion * of a normal (non-single-threaded) method invoke */ if ((options & ClassType.INVOKE_SINGLE_THREADED) == 0) { vm.notifySuspend(); } if (ret.getException() != null) { throw new InvocationException(ret.getException()); } else { return ret.getResult(); } }
Example #23
Source File: InvokableTypeImpl.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
private void validateMethodInvocation(Method method) throws InvalidTypeException, InvocationException { if (!canInvoke(method)) { throw new IllegalArgumentException("Invalid method"); } /* * Method must be a static and not a static initializer */ if (!method.isStatic()) { throw new IllegalArgumentException("Cannot invoke instance method on a class/interface type"); } else if (method.isStaticInitializer()) { throw new IllegalArgumentException("Cannot invoke static initializer"); } }
Example #24
Source File: InvokableTypeImpl.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private void validateMethodInvocation(Method method) throws InvalidTypeException, InvocationException { if (!canInvoke(method)) { throw new IllegalArgumentException("Invalid method"); } /* * Method must be a static and not a static initializer */ if (!method.isStatic()) { throw new IllegalArgumentException("Cannot invoke instance method on a class/interface type"); } else if (method.isStaticInitializer()) { throw new IllegalArgumentException("Cannot invoke static initializer"); } }
Example #25
Source File: InvokableTypeImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private void validateMethodInvocation(Method method) throws InvalidTypeException, InvocationException { if (!canInvoke(method)) { throw new IllegalArgumentException("Invalid method"); } /* * Method must be a static and not a static initializer */ if (!method.isStatic()) { throw new IllegalArgumentException("Cannot invoke instance method on a class/interface type"); } else if (method.isStaticInitializer()) { throw new IllegalArgumentException("Cannot invoke static initializer"); } }
Example #26
Source File: RemoteFXScreenshot.java From netbeans with Apache License 2.0 | 5 votes |
private static void resumeMedia(ThreadReference tr, VirtualMachine vm) throws InvalidTypeException, ClassNotLoadedException, IncompatibleThreadStateException, InvocationException { if (!pausedPlayers.isEmpty()) { final InterfaceType mediaPlayerClass = getInterface(vm, tr, "com.sun.media.jfxmedia.MediaPlayer"); List<Method> play = mediaPlayerClass.methodsByName("play", "()V"); if (play.isEmpty()) { return; } Method p = play.iterator().next(); for(ObjectReference pR : pausedPlayers) { pR.invokeMethod(tr, p, Collections.emptyList(), ObjectReference.INVOKE_SINGLE_THREADED); } } }
Example #27
Source File: InvokableTypeImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Method invocation support. * Shared by ClassType and InterfaceType * @param threadIntf the thread in which to invoke. * @param methodIntf method the {@link Method} to invoke. * @param origArguments the list of {@link Value} arguments bound to the * invoked method. Values from the list are assigned to arguments * in the order they appear in the method signature. * @param options the integer bit flag options. * @return a {@link Value} mirror of the invoked method's return value. * @throws java.lang.IllegalArgumentException if the method is not * a member of this type, if the size of the argument list * does not match the number of declared arguments for the method, or * if the method is not static or is a static initializer. * @throws {@link InvalidTypeException} if any argument in the * argument list is not assignable to the corresponding method argument * type. * @throws ClassNotLoadedException if any argument type has not yet been loaded * through the appropriate class loader. * @throws IncompatibleThreadStateException if the specified thread has not * been suspended by an event. * @throws InvocationException if the method invocation resulted in * an exception in the target VM. * @throws InvalidTypeException If the arguments do not meet this requirement -- * Object arguments must be assignment compatible with the argument * type. This implies that the argument type must be * loaded through the enclosing class's class loader. * Primitive arguments must be either assignment compatible with the * argument type or must be convertible to the argument type without loss * of information. See JLS section 5.2 for more information on assignment * compatibility. * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}. */ final public Value invokeMethod(ThreadReference threadIntf, Method methodIntf, List<? extends Value> origArguments, int options) throws InvalidTypeException, ClassNotLoadedException, IncompatibleThreadStateException, InvocationException { validateMirror(threadIntf); validateMirror(methodIntf); validateMirrorsOrNulls(origArguments); MethodImpl method = (MethodImpl) methodIntf; ThreadReferenceImpl thread = (ThreadReferenceImpl) threadIntf; validateMethodInvocation(method); List<? extends Value> arguments = method.validateAndPrepareArgumentsForInvoke(origArguments); ValueImpl[] args = arguments.toArray(new ValueImpl[0]); InvocationResult ret; try { PacketStream stream = sendInvokeCommand(thread, method, args, options); ret = waitForReply(stream); } catch (JDWPException exc) { if (exc.errorCode() == JDWP.Error.INVALID_THREAD) { throw new IncompatibleThreadStateException(); } else { throw exc.toJDIException(); } } /* * There is an implict VM-wide suspend at the conclusion * of a normal (non-single-threaded) method invoke */ if ((options & ClassType.INVOKE_SINGLE_THREADED) == 0) { vm.notifySuspend(); } if (ret.getException() != null) { throw new InvocationException(ret.getException()); } else { return ret.getResult(); } }
Example #28
Source File: RemoteFXScreenshot.java From netbeans with Apache License 2.0 | 5 votes |
private static ReferenceType getType(VirtualMachine vm, ThreadReference tr, String name) { List<ReferenceType> classList = VirtualMachineWrapper.classesByName0(vm, name); if (!classList.isEmpty()) { return classList.iterator().next(); } List<ReferenceType> classClassList = VirtualMachineWrapper.classesByName0(vm, "java.lang.Class"); // NOI18N if (classClassList.isEmpty()) { throw new IllegalStateException("Cannot load class Class"); // NOI18N } ClassType cls = (ClassType) classClassList.iterator().next(); try { Method m = ClassTypeWrapper.concreteMethodByName(cls, "forName", "(Ljava/lang/String;)Ljava/lang/Class;"); // NOI18N StringReference mirrorOfName = VirtualMachineWrapper.mirrorOf(vm, name); ClassTypeWrapper.invokeMethod(cls, tr, m, Collections.singletonList(mirrorOfName), ObjectReference.INVOKE_SINGLE_THREADED); List<ReferenceType> classList2 = VirtualMachineWrapper.classesByName0(vm, name); if (!classList2.isEmpty()) { return classList2.iterator().next(); } } catch (ClassNotLoadedException | ClassNotPreparedExceptionWrapper | IncompatibleThreadStateException | InvalidTypeException | InvocationException | InternalExceptionWrapper | ObjectCollectedExceptionWrapper | UnsupportedOperationExceptionWrapper | VMDisconnectedExceptionWrapper ex) { logger.log(Level.FINE, "Cannot load class " + name, ex); // NOI18N } return null; }
Example #29
Source File: InvokableTypeImpl.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private void validateMethodInvocation(Method method) throws InvalidTypeException, InvocationException { if (!canInvoke(method)) { throw new IllegalArgumentException("Invalid method"); } /* * Method must be a static and not a static initializer */ if (!method.isStatic()) { throw new IllegalArgumentException("Cannot invoke instance method on a class/interface type"); } else if (method.isStaticInitializer()) { throw new IllegalArgumentException("Cannot invoke static initializer"); } }
Example #30
Source File: RemoteServices.java From netbeans with Apache License 2.0 | 5 votes |
private static ArrayReference createTargetBytes(VirtualMachine vm, byte[] bytes, ByteValue[] mirrorBytesCache) throws InvalidTypeException, ClassNotLoadedException, InternalExceptionWrapper, VMDisconnectedExceptionWrapper, ObjectCollectedExceptionWrapper, UnsupportedOperationExceptionWrapper { ArrayType bytesArrayClass = getArrayClass(vm, "byte[]"); ArrayReference array = null; boolean disabledCollection = false; while (!disabledCollection) { array = ArrayTypeWrapper.newInstance(bytesArrayClass, bytes.length); try { ObjectReferenceWrapper.disableCollection(array); disabledCollection = true; } catch (ObjectCollectedExceptionWrapper ocex) { // Collected too soon, try again... } } List<Value> values = new ArrayList<Value>(bytes.length); for (int i = 0; i < bytes.length; i++) { byte b = bytes[i]; ByteValue mb = mirrorBytesCache[128 + b]; if (mb == null) { mb = VirtualMachineWrapper.mirrorOf(vm, b); mirrorBytesCache[128 + b] = mb; } values.add(mb); } ArrayReferenceWrapper.setValues(array, values); return array; }