-
Bug
-
Resolution: Fixed
-
P4
-
1.4.0, 1.4.2, 5.0, 6, 8, 9, 10
-
b10
-
generic
-
generic
Name: elR10090 Date: 05/24/2001
The method
ClassType.newInstance(ThreadReference thread,
Method method,
java.util.List arguments,
int options)
throws IllegalArgumentException
when it is invoked to create new instance of a ClassType object
which mirrors an inner class and an outer class extends the class Thread.
This is from comments in debugger's source code file:
* The test works as follows.
* A debugger launchs a debuggee which creates new thread, thread2
* a tested class TestClass1 is specified within a class
* Threadnewinstance002a extends Thread
* After getting thread2 running but locked at a monitor
* the debugger informs the debugger of the thread2 creation
* and waits for an instruction from it.
* Upon receiving the message from the debuggee, the debugger
* sets up a breakpoint for the thread2 and instructs the
* debuggee to unlock the thread2 and after getting it suspended
* at the breakpoint, prepares arguments and invokes the method.
* After the method completes, the debugger checks up on
* a returned ObjectReference value;
* the following is expected to be true:
* objRef.referenceType().equals(classType)
* where
* ObjectReference objRef - is returned value
* ClassType classType - is a mirror of the tested class.
This result is observed
when HS 1.3.1-rc2-b23 or 1.4.0-beta-b65 is runnning a test program
on the following H/S configurations:
- SUNW Ultra1: sparc 200MHz, RAM 128Mb;
OS: Solaris-8;
JVM: Client & Server
- Intel: dual Pentium-III 600MHz processor, RAM 512Mb;
OS: Solaris-8;
JVM: Client & Server
- Intel: dual Pentium-III 600MHz processor, RAM 512Mb;
OS: Linux/RedHat6.2;
JVM: Client & Server
- Intel: Pentium-II 350MHz, RAM 128Mb;
OS: WinNT/4-Workstation;
JVM: Client & Server
Corresponding code fragments in a debugger and a debuggee
and corresponding log for the tested case is below.
Steps to reproduce the bug:
1. cd /net/sqesvr.eng/export/vsn/GammaBase/Bugs/{this bug ID}
2. sh doit.sh {JAVA_HOME}
This bug affects the following testbase_nsk tests:
nsk/jdi/ClassType/newInstance/newinstance002
The tests will be in the next release of testbase_nsk;
the current release of testbase_nsk (1.4) is accessable through:
/net/sqesvr.eng/export/vsn/VM/testbase/testbase_nsk.v14
///////////////////////////////////////////////////////////////////////
// code fragments in the debugger
int expresult = returnCode0;
eventRManager = vm.eventRequestManager();
eventQueue = vm.eventQueue();
String breakpointMethod1 = "runt1";
String bpLine1 = "breakpointLineNumber1";
List allThreads = null;
ListIterator listIterator = null;
List classes = null;
BreakpointRequest breakpRequest1 = null;
ClassType classType = null;
label0: {
log2("getting ThreadReference object");
try {
allThreads = vm.allThreads();
classes = vm.classesByName(threadClassName);
threadClass = (ReferenceType) classes.get(0);
} catch ( Exception e) {
log3("ERROR: Exception at very beginning !? : " + e);
expresult = returnCode1;
break label0;
}
listIterator = allThreads.listIterator();
for (;;) {
try {
thread2 = (ThreadReference) listIterator.next();
if (thread2.name().equals(threadName))
break ;
} catch ( NoSuchElementException e ) {
log3("ERROR: NoSuchElementException for listIterator.next()");
log3("ERROR: NO THREAD2 ?????????!!!!!!!");
expresult = returnCode1;
break label0;
}
}
log2("setting up a breakpoint");
breakpRequest1 = settingBreakpoint(breakpointMethod1, bpLine1, "one");
if (breakpRequest1 == null) {
expresult = returnCode1;
break label0;
}
}
label1: {
if (expresult != returnCode0)
break label1;
log2(" enabling breakpRequest1");
breakpRequest1.enable();
log2(" forcing the main thread to leave synchronized block");
pipe.println("continue");
line = pipe.readln();
if (!line.equals("docontinue")) {
log3("ERROR: returned string is not 'docontinue'");
expresult = returnCode4;
break label1;
}
log2(" getting BreakpointEvent");
expresult = breakpoint();
if (expresult != returnCode0)
break label1;
log2(" thread2 is at breakpoint");
log2("......getting ClassType classType - an object to apply newInstance()");
classes = vm.classesByName(testedClassName);
testedClass = (ReferenceType) classes.get(0);
classType = (ClassType) testedClass;
List invokeMethods = testedClass.methods();
ListIterator li = invokeMethods.listIterator();
Method invokeMethod = null;
log2("......getting Method invokeMethod - a constructor to invoke; 2-nd
argument");
try {
for (;;) {
invokeMethod = (Method) li.next();
if (!invokeMethod.isConstructor())
continue;
if (invokeMethod.arguments().size() == 0)
break;
}
} catch ( AbsentInformationException e1 ) {
log2(" AbsentInformationException ");
break label1;
} catch ( NoSuchElementException e2 ) {
log3("ERROR: NoSuchElementException ");
expresult = returnCode2;
break label1;
}
// this is only to get an empty List with JDI methods but not with API List
methods
log2("......forming an empty List argumentList for 3-d argument");
log2(" List argumentList = testedClass.methodsByName('m');");
List argumentList = testedClass.methodsByName("m");
log2(" argumentList.clear();");
argumentList.clear();
ObjectReference objRef = null;
log2("......ObjectReference objRef = classType.newInstance(thread2, invokeMethod,
argumentList, 0);");
log2(" No Exception is expected");
try {
objRef = classType.newInstance(thread2,
invokeMethod, argumentList, 0);
if (objRef == null)
log2(" objRe == null");
log2(" ReferenceType refType = objRef.referenceType();");
ReferenceType refType = objRef.referenceType();
log2(" ClassType cType = (ClassType) refType;");
ClassType cType = (ClassType) refType;
log2("......checking up on: cType.equals(classType); ");
if (!cType.equals(classType)) {
log3("ERROR: !cType.equals(classType)");
expresult = returnCode1;
}
} catch ( Exception e ) {
log3("ERROR: Exception for classType.newInstance() :" + e);
expresult = returnCode1;
}
===============================================================
// code fragments in the debuggee
class Threadnewinstance002a extends Thread {
public Threadnewinstance002a(String threadName) {
super(threadName);
}
public static Object waitnotifyObj = new Object();
public static Object lockingObject = new Object();
public void run() {
log("method 'run' enter");
synchronized (waitnotifyObj) {
log("entered into block: synchronized (waitnotifyObj)");
waitnotifyObj.notify(); }
log("exited from block: synchronized (waitnotifyObj)");
synchronized (lockingObject) {
log("entered into block: synchronized (lockingObject)"); }
log("exited from block: synchronized (lockingObject)");
log("call to the method 'runt1'");
runt1();
log("returned from the method 'runt1'");
log("method 'run' exit");
return;
}
public void runt1() {
int i0 = 0;
log("method 'runt1': enter");
i0 = 1;
log("method 'runt1': body: i0 == " + i0);
log("method 'runt1': exit");
return;
}
public static final int breakpointLineNumber1 = 3;
void log(String str) {
newinstance002a.log2("thread2: " + str);
}
TestClass1 obj1 = new TestClass1();
public class TestClass1 {
public TestClass1() {
super();
}
boolean bl1 = true, bl2 = false;
byte bt1 = 0, bt2 = 1;
char ch1 = 0, ch2 = 1;
double db1 = 0.0d, db2 = 1111111111.0d;
float fl1 = 0.0f, fl2 = 1111111111.0f;
int in1 = 0, in2 = 1;
long ln1 = 0, ln2 = 0x1234567890abcdefL; // ln2 = 1; // ln2 = 2;
short sh1 = 0, sh2 = 1;
int m () {
return in1;
}
}
}
======================================================
// log with comments
==> nsk/jdi/ClassType/newInstance/newinstance002 TESTING BEGINS
debugee.err> **> debuggee: waiting for an instruction from the debugger ...
debugee.err> **> debuggee: thread2 is created
debugee.err> **> debuggee: synchronized (waitnotifyObj) { enter
debugee.err> **> debuggee: before: test_thread.start()
debugee.err> **> debuggee: before: waitnotifyObj.wait();
debugee.err> **> thread2: method 'run' enter
debugee.err> **> thread2: entered into block: synchronized (waitnotifyObj)
debugee.err> **> thread2: exited from block: synchronized (waitnotifyObj)
debugee.err> **> debuggee: after: waitnotifyObj.wait();
==> nsk/jdi/ClassType/newInstance/newinstance002 new checkready: #0
--> debugger: getting ThreadReference object
--> debugger: setting up a breakpoint
--> debugger: setting up a breakpoint: method: 'runt1' line: breakpointLineNumber1
--> debugger: a breakpoint has been set up
--> debugger: enabling breakpRequest1
--> debugger: forcing the main thread to leave synchronized block
debugee.err> **> debuggee: mainThread is out of: synchronized (lockingObject) {
debugee.err> **> debuggee: waiting for an instruction from the debugger ...
debugee.err> **> thread2: entered into block: synchronized (lockingObject)
debugee.err> **> thread2: exited from block: synchronized (lockingObject)
debugee.err> **> thread2: call to the method 'runt1'
debugee.err> **> thread2: method 'runt1': enter
--> debugger: getting BreakpointEvent
--> debugger: waiting for BreakpointEvent
--> debugger: new: eventSet = eventQueue.remove();
--> debugger: : eventSet != null; size == 1
--> debugger: VMStartEvent removed
--> debugger: new: eventSet = eventQueue.remove();
--> debugger: : eventSet != null; size == 1
--> debugger: BreakpointEvent removed
--> debugger: : eventSet == null: EventQueue is empty
--> debugger: thread2 is at breakpoint
--> debugger: ......getting ClassType classType - an object to apply newInstance()
--> debugger: ......getting Method invokeMethod - a constructor to invoke; 2-nd argument
--> debugger: ......forming an empty List argumentList for 3-d argument
--> debugger: List argumentList = testedClass.methodsByName('m');
--> debugger: argumentList.clear();
--> debugger: ......ObjectReference objRef = classType.newInstance(thread2, invokeMethod,
argumentList, 0);
--> debugger: No Exception is expected
# ERROR: ##> debugger: ERROR: Exception for classType.newInstance()
:java.lang.IllegalArgumentException: Invalid argument count
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
debugee.err> **> thread2: method 'runt1': body: i0 == 1
debugee.err> **> thread2: method 'runt1': exit
debugee.err> **> thread2: returned from the method 'runt1'
debugee.err> **> thread2: method 'run' exit
--> debugger: the end of testing
debugee.err> **> debuggee: waiting for an instruction from the debugger ...
--> debugger: : returned string is 'checkend'
==> nsk/jdi/ClassType/newInstance/newinstance002 TESTING ENDS
----------------------------------------------------------------------
======================================================================
- relates to
-
JDK-8200150 Argument list returned by com.sun.tool.jdi.Method.arguments() method doesn't include the reference to the instance of the enclosing class
-
- Closed
-