in src/main/java/com/jetbrains/jdi/ClassTypeImpl.java [210:257]
public ObjectReference newInstance(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;
validateConstructorInvocation(method);
List<Value> arguments = method.validateAndPrepareArgumentsForInvoke(origArguments, options);
ValueImpl[] args = arguments.toArray(new ValueImpl[0]);
JDWP.ClassType.NewInstance ret;
try {
PacketStream stream =
sendNewInstanceCommand(thread, method, args, options);
ret = JDWP.ClassType.NewInstance.waitForReply(vm, stream);
} catch (JDWPException exc) {
if (exc.errorCode() == JDWP.Error.INVALID_THREAD) {
throw new IncompatibleThreadStateException();
} else {
throw exc.toJDIException();
}
}
/*
* There is an implicit VM-wide suspend at the conclusion
* of a normal (non-single-threaded) method invoke
*/
if ((options & INVOKE_SINGLE_THREADED) == 0) {
vm.notifySuspend();
}
if (ret.exception != null) {
throw new InvocationException(ret.exception);
} else {
ObjectReferenceImpl newObject = ret.newObject;
newObject.setType(this);
return newObject;
}
}