You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by lv...@apache.org on 2008/03/26 11:28:08 UTC
svn commit: r641236 - in
/harmony/enhanced/jdktools/branches/java6/modules/jpda: make/
src/main/native/include/ src/main/native/jdwp/common/agent/commands/
src/main/native/jdwp/common/agent/core/
src/main/native/jdwp/common/generic/ src/test/java/org/a...
Author: lvjing
Date: Wed Mar 26 03:28:02 2008
New Revision: 641236
URL: http://svn.apache.org/viewvc?rev=641236&view=rev
Log:
Apply patch for HARMONY-5647, [jdktools][jdwp6] Add new command ForceEarlyReturn Command for Java 6
Added:
harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturn002Test.java (with props)
harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturn003Test.java (with props)
harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturn004Test.java (with props)
harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturn005Test.java (with props)
harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturn006Test.java (with props)
harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturnDebuggee.java (with props)
harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturnTest.java (with props)
Modified:
harmony/enhanced/jdktools/branches/java6/modules/jpda/make/exclude.common
harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/include/jvmti.h
harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ThreadReference.cpp
harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ThreadReference.h
harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/CommandDispatcher.cpp
harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/generic/jdwp.h
harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/Capabilities.java
harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/JDWPCommands.java
harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/Packet.java
harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/VmMirror.java
Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/make/exclude.common
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/make/exclude.common?rev=641236&r1=641235&r2=641236&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/make/exclude.common (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/make/exclude.common Wed Mar 26 03:28:02 2008
@@ -17,3 +17,10 @@
org/apache/harmony/jpda/tests/jdwp/ObjectReference/ReferringObjectsTest.java
#5613
org/apache/harmony/jpda/tests/jdwp/ThreadReference/OwnedMonitorsStackDepthInfoTest.java
+#5647
+org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturnTest.java
+org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturn002Test.java
+org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturn003Test.java
+org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturn004Test.java
+org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturn005Test.java
+org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturn006Test.java
Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/include/jvmti.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/include/jvmti.h?rev=641236&r1=641235&r2=641236&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/include/jvmti.h (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/include/jvmti.h Wed Mar 26 03:28:02 2008
@@ -409,17 +409,28 @@
jvmtiError (JNICALL * PopFrame) (jvmtiEnv * env, jthread thread);
- void *reserved81;
+ jvmtiError (JNICALL *ForceEarlyReturnObject) (jvmtiEnv* env,
+ jthread thread,
+ jobject value);
+
+ jvmtiError (JNICALL *ForceEarlyReturnInt) (jvmtiEnv* env,
+ jthread thread,
+ jint value);
+
+ jvmtiError (JNICALL *ForceEarlyReturnLong) (jvmtiEnv* env,
+ jthread thread,
+ jlong value);
+
+ jvmtiError (JNICALL *ForceEarlyReturnFloat) (jvmtiEnv* env,
+ jthread thread,
+ jfloat value);
+
+ jvmtiError (JNICALL *ForceEarlyReturnDouble) (jvmtiEnv* env,
+ jthread thread,
+ jdouble value);
- void *reserved82;
-
- void *reserved83;
-
- void *reserved84;
-
- void *reserved85;
-
- void *reserved86;
+ jvmtiError (JNICALL *ForceEarlyReturnVoid) (jvmtiEnv* env,
+ jthread thread);
jvmtiError (JNICALL * RedefineClasses) (jvmtiEnv * env,
jint class_count,
@@ -847,6 +858,36 @@
jvmtiError PopFrame (jthread thread)
{
return funcs->PopFrame (this, thread);
+ }
+
+ jvmtiError ForceEarlyReturnObject (jthread thread, jobject value)
+ {
+ return funcs->ForceEarlyReturnObject (this, thread, value);
+ }
+
+ jvmtiError ForceEarlyReturnInt (jthread thread, jint value)
+ {
+ return funcs->ForceEarlyReturnInt (this, thread, value);
+ }
+
+ jvmtiError ForceEarlyReturnLong (jthread thread, jlong value)
+ {
+ return funcs->ForceEarlyReturnLong (this, thread, value);
+ }
+
+ jvmtiError ForceEarlyReturnFloat (jthread thread, jfloat value)
+ {
+ return funcs->ForceEarlyReturnFloat (this, thread, value);
+ }
+
+ jvmtiError ForceEarlyReturnDouble (jthread thread, jdouble value)
+ {
+ return funcs->ForceEarlyReturnDouble (this, thread, value);
+ }
+
+ jvmtiError ForceEarlyReturnVoid (jthread thread)
+ {
+ return funcs->ForceEarlyReturnVoid (this, thread);
}
jvmtiError GetFrameLocation (jthread thread,
Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ThreadReference.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ThreadReference.cpp?rev=641236&r1=641235&r2=641236&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ThreadReference.cpp (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ThreadReference.cpp Wed Mar 26 03:28:02 2008
@@ -373,6 +373,7 @@
//-----------------------------------------------------------------------------
//OwnedMonitorsStackDepthInfoHandler-------------------------------------------
+
void
ThreadReference::OwnedMonitorsStackDepthInfoHandler::Execute(JNIEnv *jni)
throw (AgentException)
@@ -414,6 +415,103 @@
JDWP_TRACE_DATA("OwnedMonitorsStackDepthInfo: received: monitor stack depth=" << stack_depth);
m_cmdParser->reply.WriteInt(stack_depth);
}
+}
+
+//-----------------------------------------------------------------------------
+//ForceEarlyReturnHandler------------------------------------------------------
+
+void
+ThreadReference::ForceEarlyReturnHandler::Execute(JNIEnv *jni)
+ throw (AgentException)
+{
+ // Read thread id from ForceEarlyReturnHandler command
+ jthread thrd = m_cmdParser->command.ReadThreadID(jni);
+ JDWP_TRACE_DATA("ForceEarlyReturn Command: received: threadID = " << thrd);
+
+ // If the thread is not suspended, throw exception
+ if (!GetThreadManager().IsSuspended(thrd))
+ throw AgentException(JDWP_ERROR_THREAD_NOT_SUSPENDED);
+
+ // Attain return value type from the command
+ jdwpTaggedValue taggedValue = m_cmdParser->command.ReadValue(jni);
+ JDWP_TRACE_DATA("ForceEarlyReturn Command: received value type:" << taggedValue.tag);
+
+ // Invoke relevant jvmti function according to return value's type
+ jvmtiError err = JVMTI_ERROR_NONE;
+ switch(taggedValue.tag){
+ case JDWP_TAG_OBJECT:
+ case JDWP_TAG_ARRAY:
+ case JDWP_TAG_STRING:
+ case JDWP_TAG_THREAD:
+ case JDWP_TAG_THREAD_GROUP:
+ case JDWP_TAG_CLASS_LOADER:
+ case JDWP_TAG_CLASS_OBJECT:{
+ JDWP_TRACE_DATA("ForceEarlyReturn Command: jobject return value:"<< taggedValue.value.l);
+ JVMTI_TRACE(err, GetJvmtiEnv()->ForceEarlyReturnObject(thrd, taggedValue.value.l));
+ break;
+ }
+ case JDWP_TAG_BOOLEAN:
+ case JDWP_TAG_BYTE:
+ case JDWP_TAG_CHAR:
+ case JDWP_TAG_SHORT:
+ case JDWP_TAG_INT:{
+ jint ivalue = 0;
+ switch (taggedValue.tag) {
+ case JDWP_TAG_BOOLEAN:
+ ivalue = static_cast<jint>(taggedValue.value.z);
+ JDWP_TRACE_DATA("ForceEarlyReturn Command: value=(boolean)" << taggedValue.value.z);
+ break;
+ case JDWP_TAG_BYTE:
+ ivalue = static_cast<jint>(taggedValue.value.b);
+ JDWP_TRACE_DATA("ForceEarlyReturn Command: value=(byte)" << taggedValue.value.b);
+ break;
+ case JDWP_TAG_CHAR:
+ ivalue = static_cast<jint>(taggedValue.value.c);
+ JDWP_TRACE_DATA("ForceEarlyReturn Command: value=(char)" << taggedValue.value.c);
+ break;
+ case JDWP_TAG_SHORT:
+ ivalue = static_cast<jint>(taggedValue.value.s);
+ JDWP_TRACE_DATA("ForceEarlyReturn Command: value=(short)" << taggedValue.value.s);
+ break;
+ case JDWP_TAG_INT:
+ ivalue = taggedValue.value.i;
+ JDWP_TRACE_DATA("ForceEarlyReturn Command: value=(int)" << taggedValue.value.i);
+ break;
+ }
+ JVMTI_TRACE(err, GetJvmtiEnv()->ForceEarlyReturnInt(thrd, ivalue));
+ break;
+ }
+ case JDWP_TAG_LONG:{
+ JDWP_TRACE_DATA("ForceEarlyReturn Command: jlong returne value:"<< taggedValue.value.j);
+ JVMTI_TRACE(err, GetJvmtiEnv()->ForceEarlyReturnLong(thrd, taggedValue.value.j));
+ break;
+ }
+ case JDWP_TAG_FLOAT:{
+ JDWP_TRACE_DATA("ForceEarlyReturn Command: jfloat return value:"<< taggedValue.value.f);
+ JVMTI_TRACE(err, GetJvmtiEnv()->ForceEarlyReturnFloat(thrd, taggedValue.value.f));
+ break;
+
+ }
+ case JDWP_TAG_DOUBLE:{
+ JDWP_TRACE_DATA("ForceEarlyReturn Command: jdouble return value:"<< taggedValue.value.d);
+ JVMTI_TRACE(err, GetJvmtiEnv()->ForceEarlyReturnDouble(thrd, taggedValue.value.d));
+ break;
+ }
+ case JDWP_TAG_VOID:{
+ JDWP_TRACE_DATA("ForceEarlyReturn Command: void return value");
+ JVMTI_TRACE(err, GetJvmtiEnv()->ForceEarlyReturnVoid(thrd));
+ break;
+ }
+ default:{
+ JDWP_TRACE_DATA("ForceEarlyReturn Command: Value's type is not supported " << taggedValue.tag);
+ throw AgentException(JDWP_ERROR_INVALID_TAG);
+ }
+ }
+
+ if (err != JVMTI_ERROR_NONE) {
+ throw AgentException(err);
+ }
+ JDWP_TRACE_DATA("ForceEarlyReturn Command finished.");
}
//-----------------------------------------------------------------------------
Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ThreadReference.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ThreadReference.h?rev=641236&r1=641235&r2=641236&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ThreadReference.h (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ThreadReference.h Wed Mar 26 03:28:02 2008
@@ -262,6 +262,23 @@
virtual void Execute(JNIEnv *jni) throw(AgentException);
};//OwnedMonitorsStackDepthInfoHandler
+
+ /**
+ * The class implements the <code>ForceEarlyReturn</code> command from the
+ * ThreadReference command set.
+ */
+ class ForceEarlyReturnHandler : public SyncCommandHandler {
+ protected:
+
+ /**
+ * Executes the <code>ForceEarlyReturn</code> JDWP command for the
+ * ThreadReference command set.
+ *
+ * @param jni - the JNI interface pointer
+ */
+ virtual void Execute(JNIEnv *jni) throw(AgentException);
+
+ };//ForceEarlyReturnHandler
}//ThreadReference
Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/CommandDispatcher.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/CommandDispatcher.cpp?rev=641236&r1=641235&r2=641236&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/CommandDispatcher.cpp (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/core/CommandDispatcher.cpp Wed Mar 26 03:28:02 2008
@@ -361,6 +361,9 @@
// New command for Java 6
case JDWP_COMMAND_TR_OWNED_MONITORS_STACK_DEPTH:
return new ThreadReference::OwnedMonitorsStackDepthInfoHandler();
+
+ case JDWP_COMMAND_TR_FORCE_EARLY_RETURN:
+ return new ThreadReference::ForceEarlyReturnHandler();
}//JDWP_COMMAND_SET_THREAD_REFERENCE
break;
Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/generic/jdwp.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/generic/jdwp.h?rev=641236&r1=641235&r2=641236&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/generic/jdwp.h (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/generic/jdwp.h Wed Mar 26 03:28:02 2008
@@ -153,6 +153,7 @@
JDWP_COMMAND_TR_SUSPEND_COUNT = 12,
// New command for Java 6
JDWP_COMMAND_TR_OWNED_MONITORS_STACK_DEPTH = 13,
+ JDWP_COMMAND_TR_FORCE_EARLY_RETURN = 14,
/* Commands ThreadGroupReference */
JDWP_COMMAND_TGR_NAME = 1,
Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/Capabilities.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/Capabilities.java?rev=641236&r1=641235&r2=641236&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/Capabilities.java (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/Capabilities.java Wed Mar 26 03:28:02 2008
@@ -71,7 +71,7 @@
public boolean canGetConstantPool = false;
- public boolean reserved21 = false;
+ public boolean canForceEarlyReturn = false;
public boolean reserved22 = false;
Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/JDWPCommands.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/JDWPCommands.java?rev=641236&r1=641235&r2=641236&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/JDWPCommands.java (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/JDWPCommands.java Wed Mar 26 03:28:02 2008
@@ -256,6 +256,8 @@
//New command for Java 6
public static final byte OwnedMonitorsStackDepthInfoCommand = 13;
+
+ public static final byte ForceEarlyReturnCommand = 14;
}
/**
Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/Packet.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/Packet.java?rev=641236&r1=641235&r2=641236&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/Packet.java (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/Packet.java Wed Mar 26 03:28:02 2008
@@ -1052,6 +1052,8 @@
case JDWPConstants.Tag.SHORT_TAG:
this.setNextValueAsShort(value.getShortValue());
break;
+ case JDWPConstants.Tag.VOID_TAG:
+ break;
case JDWPConstants.Tag.STRING_TAG:
case JDWPConstants.Tag.ARRAY_TAG:
case JDWPConstants.Tag.CLASS_LOADER_TAG:
Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/VmMirror.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/VmMirror.java?rev=641236&r1=641235&r2=641236&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/VmMirror.java (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/VmMirror.java Wed Mar 26 03:28:02 2008
@@ -73,8 +73,10 @@
/**
* Creates new VmMirror instance for given test run options.
*
- * @param config test run options
- * @param logWriter log writer
+ * @param config
+ * test run options
+ * @param logWriter
+ * log writer
*/
public VmMirror(TestOptions config, LogWriter logWriter) {
connection = null;
@@ -357,8 +359,8 @@
/**
* Requests debuggee VM capabilities. Function parses reply packet of
- * VirtualMachine::CapabilitiesNew command, creates and fills class Capabilities with
- * returned info.
+ * VirtualMachine::CapabilitiesNew command, creates and fills class
+ * Capabilities with returned info.
*
* @return ReplyPacket useless, already parsed reply packet.
*/
@@ -378,7 +380,7 @@
// Send packet
ReplyPacket replyPacket = checkReply(performCommand(commandPacket));
-
+
targetVMCapabilities = new Capabilities();
// Set capabilities
@@ -413,11 +415,13 @@
targetVMCapabilities.canGetInstanceInfo = replyPacket
.getNextValueAsBoolean();
targetVMCapabilities.reserved17 = replyPacket.getNextValueAsBoolean();
- targetVMCapabilities.canGetMonitorFrameInfo = replyPacket.getNextValueAsBoolean();
+ targetVMCapabilities.canGetMonitorFrameInfo = replyPacket
+ .getNextValueAsBoolean();
targetVMCapabilities.reserved19 = replyPacket.getNextValueAsBoolean();
targetVMCapabilities.canGetConstantPool = replyPacket
.getNextValueAsBoolean();
- targetVMCapabilities.reserved21 = replyPacket.getNextValueAsBoolean();
+ targetVMCapabilities.canForceEarlyReturn = replyPacket
+ .getNextValueAsBoolean();
targetVMCapabilities.reserved22 = replyPacket.getNextValueAsBoolean();
targetVMCapabilities.reserved23 = replyPacket.getNextValueAsBoolean();
targetVMCapabilities.reserved24 = replyPacket.getNextValueAsBoolean();
@@ -2121,7 +2125,7 @@
if (superID != 0) {
List superClassFields = getAllFields(superID);
for (int i = 0; i < superClassFields.size(); i++) {
- fields.add((Field)superClassFields.toArray()[i]);
+ fields.add((Field) superClassFields.toArray()[i]);
}
}
Added: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturn002Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturn002Test.java?rev=641236&view=auto
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturn002Test.java (added)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturn002Test.java Wed Mar 26 03:28:02 2008
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.jpda.tests.jdwp.ThreadReference;
+
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
+import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.Value;
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+public class ForceEarlyReturn002Test extends JDWPSyncTestCase {
+
+ static final String thisCommandName = "ThreadReference.ForceEarlyReturn command ";
+
+ static final long EXPECTED_LONG = 100;
+
+ protected String getDebuggeeClassName() {
+ return "org.apache.harmony.jpda.tests.jdwp.ThreadReference.ForceEarlyReturnDebuggee";
+ }
+
+ // ForceEarlyReturn needs canForceEarlyReturn VM capability support
+ private boolean isCapability() {
+ // check capability, relevant for this test
+ logWriter.println("=> Check capability: canForceEarlyReturn");
+ debuggeeWrapper.vmMirror.capabilities();
+ boolean isCapability = debuggeeWrapper.vmMirror.targetVMCapabilities.canForceEarlyReturn;
+ return isCapability;
+ }
+
+ /**
+ * This testcase exercises ThreadReference.ForceEarlyReturn command. <BR>
+ * At first the test starts ForceEarlyReturnDebuggee and send it the thread
+ * name through which to start a specific thread. Then the test performs the
+ * ThreadReference.ForceEarlyReturn command for the tested thread and gets
+ * the returned value of the called method. The returned value should be
+ * equal to the value which is used in ForceEarlyReturn Command. In this
+ * testcase, an Long value is returned.
+ */
+ public void testForceEarlyReturn_ReturnLong() {
+ String thisTestName = "testForceEarlyReturn_ReturnLong";
+ logWriter.println("==> " + thisTestName + " for " + thisCommandName
+ + ": START...");
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ if (!isCapability()) {
+ logWriter
+ .println("##WARNING: this VM dosn't possess capability:canForceEarlyReturn");
+ return;
+ }
+ // Tell debuggee to start a thread named THREAD_LONG
+ synchronizer.sendMessage(ForceEarlyReturnDebuggee.THREAD_LONG);
+
+ // Wait until the func_Long is processing.
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ // Getting ID of the tested thread
+ logWriter.println("==> testedThreadName = "
+ + ForceEarlyReturnDebuggee.THREAD_LONG);
+ logWriter.println("==> Get testedThreadID...");
+ long testedThreadID = debuggeeWrapper.vmMirror
+ .getThreadID(ForceEarlyReturnDebuggee.THREAD_LONG);
+ logWriter.println("==> Get testedThreadID is" + testedThreadID);
+
+ // Suspend the VM before perform command
+ logWriter.println("==> testedThreadID = " + testedThreadID);
+ logWriter.println("==> suspend testedThread...");
+ debuggeeWrapper.vmMirror.suspendThread(testedThreadID);
+
+ // Compose the ForceEarlyReturn command
+ CommandPacket forceEarlyReturnPacket = new CommandPacket(
+ JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
+ JDWPCommands.ThreadReferenceCommandSet.ForceEarlyReturnCommand);
+ forceEarlyReturnPacket.setNextValueAsThreadID(testedThreadID);
+ forceEarlyReturnPacket.setNextValueAsValue(new Value(EXPECTED_LONG));
+
+ // Perform the command
+ logWriter.println("==> Perform " + thisCommandName);
+ ReplyPacket forceEarlyReturnReply = debuggeeWrapper.vmMirror
+ .performCommand(forceEarlyReturnPacket);
+ forceEarlyReturnPacket = null;
+
+ checkReplyPacket(forceEarlyReturnReply,
+ "ThreadReference::ForceEarlyReturn command");
+
+ // Resume the thread
+ logWriter.println("==> testedThreadID = " + testedThreadID);
+ logWriter.println("==> resume testedThread...");
+ debuggeeWrapper.vmMirror.resumeThread(testedThreadID);
+
+ String actualValue = synchronizer.receiveMessage();
+ // Check the early returned value
+ if (!actualValue.equals(new Long(EXPECTED_LONG).toString())) {
+ printErrorAndFail(thisCommandName
+ + "returned value is not set by ForceEarlyReturn command"
+ + " expected:<" + EXPECTED_LONG + "> but was:<"
+ + actualValue + ">");
+ }
+ logWriter
+ .println("==> CHECK: PASSED: returned value does set by ForceEarlyReturn command.");
+ logWriter.println("==> Returned value: " + actualValue);
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(ForceEarlyReturn002Test.class);
+
+ }
+
+}
Propchange: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturn002Test.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturn003Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturn003Test.java?rev=641236&view=auto
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturn003Test.java (added)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturn003Test.java Wed Mar 26 03:28:02 2008
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.jpda.tests.jdwp.ThreadReference;
+
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
+import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.Value;
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+public class ForceEarlyReturn003Test extends JDWPSyncTestCase {
+
+ static final String thisCommandName = "ThreadReference.ForceEarlyReturn command ";
+
+ static final float EXPECTED_FLOAT = 0.5f;
+
+ protected String getDebuggeeClassName() {
+ return "org.apache.harmony.jpda.tests.jdwp.ThreadReference.ForceEarlyReturnDebuggee";
+ }
+
+ // ForceEarlyReturn needs canForceEarlyReturn VM capability support
+ private boolean isCapability() {
+ // check capability, relevant for this test
+ logWriter.println("=> Check capability: canForceEarlyReturn");
+ debuggeeWrapper.vmMirror.capabilities();
+ boolean isCapability = debuggeeWrapper.vmMirror.targetVMCapabilities.canForceEarlyReturn;
+ return isCapability;
+ }
+
+ /**
+ * This testcase exercises ThreadReference.ForceEarlyReturn command. <BR>
+ * At first the test starts ForceEarlyReturnDebuggee and send it the thread
+ * name through which to start a specific thread. Then the test performs the
+ * ThreadReference.ForceEarlyReturn command for the tested thread and gets
+ * the returned value of the called method. The returned value should be
+ * equal to the value which is used in ForceEarlyReturn Command. In this
+ * testcase, an Float value is returned.
+ */
+ public void testForceEarlyReturn_ReturnFloat() {
+ String thisTestName = "testForceEarlyReturn_ReturnFloat";
+ logWriter.println("==> " + thisTestName + " for " + thisCommandName
+ + ": START...");
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ if (!isCapability()) {
+ logWriter
+ .println("##WARNING: this VM dosn't possess capability:canForceEarlyReturn");
+ return;
+ }
+ // Tell debuggee to start a thread named THREAD_FLOAT
+ synchronizer.sendMessage(ForceEarlyReturnDebuggee.THREAD_FLOAT);
+
+ // Wait until the func_FLOAT is processing.
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ // Getting ID of the tested thread
+ logWriter.println("==> testedThreadName = "
+ + ForceEarlyReturnDebuggee.THREAD_FLOAT);
+ logWriter.println("==> Get testedThreadID...");
+ long testedThreadID = debuggeeWrapper.vmMirror
+ .getThreadID(ForceEarlyReturnDebuggee.THREAD_FLOAT);
+ logWriter.println("==> Get testedThreadID is" + testedThreadID);
+
+ // Suspend the VM before perform command
+ logWriter.println("==> testedThreadID = " + testedThreadID);
+ logWriter.println("==> suspend testedThread...");
+ debuggeeWrapper.vmMirror.suspendThread(testedThreadID);
+
+ // Compose the ForceEarlyReturn command
+ CommandPacket forceEarlyReturnPacket = new CommandPacket(
+ JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
+ JDWPCommands.ThreadReferenceCommandSet.ForceEarlyReturnCommand);
+ forceEarlyReturnPacket.setNextValueAsThreadID(testedThreadID);
+ forceEarlyReturnPacket.setNextValueAsValue(new Value(EXPECTED_FLOAT));
+
+ // Perform the command
+ logWriter.println("==> Perform " + thisCommandName);
+ ReplyPacket forceEarlyReturnReply = debuggeeWrapper.vmMirror
+ .performCommand(forceEarlyReturnPacket);
+ forceEarlyReturnPacket = null;
+
+ checkReplyPacket(forceEarlyReturnReply,
+ "ThreadReference::ForceEarlyReturn command");
+
+ // Resume the thread
+ logWriter.println("==> testedThreadID = " + testedThreadID);
+ logWriter.println("==> resume testedThread...");
+ debuggeeWrapper.vmMirror.resumeThread(testedThreadID);
+
+ String actualValue = synchronizer.receiveMessage();
+ // Check the early returned value
+ if (!actualValue.equals(new Float(EXPECTED_FLOAT).toString())) {
+ printErrorAndFail(thisCommandName
+ + "returned value is not set by ForceEarlyReturn command"
+ + " expected:<" + EXPECTED_FLOAT + "> but was:<"
+ + actualValue + ">");
+ }
+ logWriter
+ .println("==> CHECK: PASSED: returned value does set by ForceEarlyReturn command.");
+ logWriter.println("==> Returned value: " + actualValue);
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(ForceEarlyReturn003Test.class);
+ }
+
+}
Propchange: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturn003Test.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturn004Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturn004Test.java?rev=641236&view=auto
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturn004Test.java (added)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturn004Test.java Wed Mar 26 03:28:02 2008
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.jpda.tests.jdwp.ThreadReference;
+
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
+import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.Value;
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+public class ForceEarlyReturn004Test extends JDWPSyncTestCase {
+
+ static final String thisCommandName = "ThreadReference.ForceEarlyReturn command ";
+
+ static final double EXPECTED_DOUBLE = 2.4;
+
+ protected String getDebuggeeClassName() {
+ return "org.apache.harmony.jpda.tests.jdwp.ThreadReference.ForceEarlyReturnDebuggee";
+ }
+
+ // ForceEarlyReturn needs canForceEarlyReturn VM capability support
+ private boolean isCapability() {
+ // check capability, relevant for this test
+ logWriter.println("=> Check capability: canForceEarlyReturn");
+ debuggeeWrapper.vmMirror.capabilities();
+ boolean isCapability = debuggeeWrapper.vmMirror.targetVMCapabilities.canForceEarlyReturn;
+ return isCapability;
+ }
+
+ /**
+ * This testcase exercises ThreadReference.ForceEarlyReturn command. <BR>
+ * At first the test starts ForceEarlyReturnDebuggee and send it the thread
+ * name through which to start a specific thread. Then the test performs the
+ * ThreadReference.ForceEarlyReturn command for the tested thread and gets
+ * the returned value of the called method. The returned value should be
+ * equal to the value which is used in ForceEarlyReturn Command. In this
+ * testcase, an Double value is returned.
+ */
+ public void testForceEarlyReturn_ReturnDouble() {
+ String thisTestName = "testForceEarlyReturn_ReturnDouble";
+ logWriter.println("==> " + thisTestName + " for " + thisCommandName
+ + ": START...");
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ if (!isCapability()) {
+ logWriter
+ .println("##WARNING: this VM dosn't possess capability:canForceEarlyReturn");
+ return;
+ }
+ // Tell debuggee to start a thread named THREAD_DOUBLE
+ synchronizer.sendMessage(ForceEarlyReturnDebuggee.THREAD_DOUBLE);
+
+ // Wait until the func_Double is processing.
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ // Getting ID of the tested thread
+ logWriter.println("==> testedThreadName = "
+ + ForceEarlyReturnDebuggee.THREAD_DOUBLE);
+ logWriter.println("==> Get testedThreadID...");
+ long testedThreadID = debuggeeWrapper.vmMirror
+ .getThreadID(ForceEarlyReturnDebuggee.THREAD_DOUBLE);
+ logWriter.println("==> Get testedThreadID is" + testedThreadID);
+
+ // Suspend the VM before perform command
+ logWriter.println("==> testedThreadID = " + testedThreadID);
+ logWriter.println("==> suspend testedThread...");
+ debuggeeWrapper.vmMirror.suspendThread(testedThreadID);
+
+ // Compose the ForceEarlyReturn command
+ CommandPacket forceEarlyReturnPacket = new CommandPacket(
+ JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
+ JDWPCommands.ThreadReferenceCommandSet.ForceEarlyReturnCommand);
+ forceEarlyReturnPacket.setNextValueAsThreadID(testedThreadID);
+ forceEarlyReturnPacket.setNextValueAsValue(new Value(EXPECTED_DOUBLE));
+
+ // Perform the command
+ logWriter.println("==> Perform " + thisCommandName);
+ ReplyPacket forceEarlyReturnReply = debuggeeWrapper.vmMirror
+ .performCommand(forceEarlyReturnPacket);
+ forceEarlyReturnPacket = null;
+
+ checkReplyPacket(forceEarlyReturnReply,
+ "ThreadReference::ForceEarlyReturn command");
+
+ // Resume the thread
+ logWriter.println("==> testedThreadID = " + testedThreadID);
+ logWriter.println("==> resume testedThread...");
+ debuggeeWrapper.vmMirror.resumeThread(testedThreadID);
+
+ String actualValue = synchronizer.receiveMessage();
+ // Check the early returned value
+ if (!actualValue.equals(new Double(EXPECTED_DOUBLE).toString())) {
+ printErrorAndFail(thisCommandName
+ + "returned value is not set by ForceEarlyReturn command"
+ + " expected:<" + EXPECTED_DOUBLE + "> but was:<"
+ + actualValue + ">");
+ }
+ logWriter
+ .println("==> CHECK: PASSED: returned value does set by ForceEarlyReturn command.");
+ logWriter.println("==> Returned value: " + actualValue);
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(ForceEarlyReturn004Test.class);
+
+ }
+
+}
Propchange: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturn004Test.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturn005Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturn005Test.java?rev=641236&view=auto
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturn005Test.java (added)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturn005Test.java Wed Mar 26 03:28:02 2008
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.jpda.tests.jdwp.ThreadReference;
+
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
+import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.Value;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants.Tag;
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+public class ForceEarlyReturn005Test extends JDWPSyncTestCase {
+
+ static final String thisCommandName = "ThreadReference.ForceEarlyReturn command ";
+
+ protected String getDebuggeeClassName() {
+ return "org.apache.harmony.jpda.tests.jdwp.ThreadReference.ForceEarlyReturnDebuggee";
+ }
+
+ // ForceEarlyReturn needs canForceEarlyReturn VM capability support
+ private boolean isCapability() {
+ // check capability, relevant for this test
+ logWriter.println("=> Check capability: canForceEarlyReturn");
+ debuggeeWrapper.vmMirror.capabilities();
+ boolean isCapability = debuggeeWrapper.vmMirror.targetVMCapabilities.canForceEarlyReturn;
+ return isCapability;
+ }
+
+ /**
+ * This testcase exercises ThreadReference.ForceEarlyReturn command. <BR>
+ * At first the test starts ForceEarlyReturnDebuggee and send it the thread
+ * name through which to start a specific thread. Then the test performs the
+ * ThreadReference.ForceEarlyReturn command for the tested thread and gets
+ * the returned value of the called method. The returned value should be
+ * equal to the value which is used in ForceEarlyReturn Command. In this
+ * testcase, an Void value is returned.
+ */
+ public void testForceEarlyReturn_ReturnVoid() {
+ String thisTestName = "testForceEarlyReturn_ReturnVoid";
+ logWriter.println("==> " + thisTestName + " for " + thisCommandName
+ + ": START...");
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ if (!isCapability()) {
+ logWriter
+ .println("##WARNING: this VM dosn't possess capability:canForceEarlyReturn");
+ return;
+ }
+
+ // Tell debuggee to start a thread named THREAD_VOID
+ synchronizer.sendMessage(ForceEarlyReturnDebuggee.THREAD_VOID);
+
+ // Wait until the func_Void is processing.
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ // Getting ID of the tested thread
+ logWriter.println("==> testedThreadName = "
+ + ForceEarlyReturnDebuggee.THREAD_VOID);
+ logWriter.println("==> Get testedThreadID...");
+ long testedThreadID = debuggeeWrapper.vmMirror
+ .getThreadID(ForceEarlyReturnDebuggee.THREAD_VOID);
+ logWriter.println("==> Get testedThreadID is" + testedThreadID);
+
+ // Suspend the VM before perform command
+ logWriter.println("==> testedThreadID = " + testedThreadID);
+ logWriter.println("==> suspend testedThread...");
+ debuggeeWrapper.vmMirror.suspendThread(testedThreadID);
+
+ // Compose the ForceEarlyReturn command
+ CommandPacket forceEarlyReturnPacket = new CommandPacket(
+ JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
+ JDWPCommands.ThreadReferenceCommandSet.ForceEarlyReturnCommand);
+ forceEarlyReturnPacket.setNextValueAsThreadID(testedThreadID);
+ forceEarlyReturnPacket.setNextValueAsValue(new Value(Tag.VOID_TAG, 0));
+
+ // Perform the command
+ logWriter.println("==> Perform " + thisCommandName);
+ ReplyPacket forceEarlyReturnReply = debuggeeWrapper.vmMirror
+ .performCommand(forceEarlyReturnPacket);
+ forceEarlyReturnPacket = null;
+
+ checkReplyPacket(forceEarlyReturnReply,
+ "ThreadReference::ForceEarlyReturn command");
+
+ // Resume the thread
+ logWriter.println("==> testedThreadID = " + testedThreadID);
+ logWriter.println("==> resume testedThread...");
+ debuggeeWrapper.vmMirror.resumeThread(testedThreadID);
+
+ String isBreak = synchronizer.receiveMessage();
+ // Check the early returned value
+ if (!isBreak.equals("TRUE")) {
+ printErrorAndFail(thisCommandName
+ + "returned value is not void set by ForceEarlyReturn command");
+ }
+ logWriter
+ .println("==> CHECK: PASSED: returned value does set by ForceEarlyReturn command.");
+ logWriter.println("==> Returned value: " + "void");
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(ForceEarlyReturn005Test.class);
+
+ }
+
+}
Propchange: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturn005Test.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturn006Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturn006Test.java?rev=641236&view=auto
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturn006Test.java (added)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturn006Test.java Wed Mar 26 03:28:02 2008
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.jpda.tests.jdwp.ThreadReference;
+
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
+import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.Value;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants.Tag;
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+public class ForceEarlyReturn006Test extends JDWPSyncTestCase {
+
+ static final String thisCommandName = "ThreadReference.ForceEarlyReturn command ";
+
+ static final String testObjSignature = "Lorg/apache/harmony/jpda/tests/jdwp/ThreadReference/TestObject;";
+
+ protected String getDebuggeeClassName() {
+ return "org.apache.harmony.jpda.tests.jdwp.ThreadReference.ForceEarlyReturnDebuggee";
+ }
+
+ // ForceEarlyReturn needs canForceEarlyReturn VM capability support
+ private boolean isCapability() {
+ // check capability, relevant for this test
+ logWriter.println("=> Check capability: canForceEarlyReturn");
+ debuggeeWrapper.vmMirror.capabilities();
+ boolean isCapability = debuggeeWrapper.vmMirror.targetVMCapabilities.canForceEarlyReturn;
+ return isCapability;
+ }
+
+ // Get the objectID of test thread
+ private long getObjectID() {
+ // Compose Instances command to get tested thread objectID
+ CommandPacket InstancesCommand = new CommandPacket(
+ JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
+ JDWPCommands.ReferenceTypeCommandSet.InstancesCommand);
+
+ long testThreadTypeID = getClassIDBySignature(testObjSignature);
+ InstancesCommand.setNextValueAsReferenceTypeID(testThreadTypeID);
+ InstancesCommand.setNextValueAsInt(1);
+
+ ReplyPacket checkedReply = debuggeeWrapper.vmMirror
+ .performCommand(InstancesCommand);
+ InstancesCommand = null;
+
+ // Get the number of instances that returned.
+ int objNum = checkedReply.getNextValueAsInt();
+ // Get the tagged-objectID
+ byte tag = checkedReply.getNextValueAsByte();
+ long objectID = checkedReply.getNextValueAsObjectID();
+ return objectID;
+ }
+
+ /**
+ * This testcase exercises ThreadReference.ForceEarlyReturn command. <BR>
+ * At first the test starts ForceEarlyReturnDebuggee and send it the thread
+ * name through which to start a specific thread. Then the test performs the
+ * ThreadReference.ForceEarlyReturn command for the tested thread and gets
+ * the returned value of the called method. The returned value should be
+ * equal to the value which is used in ForceEarlyReturn Command. In this
+ * testcase, an Object value is returned.
+ */
+ public void testForceEarlyReturn_ReturnObject() {
+ String thisTestName = "testForceEarlyReturn_ReturnObject";
+ logWriter.println("==> " + thisTestName + " for " + thisCommandName
+ + ": START...");
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ if (!isCapability()) {
+ logWriter
+ .println("##WARNING: this VM dosn't possess capability:canForceEarlyReturn");
+ return;
+ }
+
+ // Get test object id
+ long testObjID = getObjectID();
+ logWriter.println("==> test object id is: " + testObjID);
+
+ // Tell debuggee to start a thread named THREAD_OBJECT
+ synchronizer.sendMessage(ForceEarlyReturnDebuggee.THREAD_OBJECT);
+
+ // Wait until the func_Object is processing.
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ // Getting ID of the tested thread
+ logWriter.println("==> testedThreadName = "
+ + ForceEarlyReturnDebuggee.THREAD_OBJECT);
+ logWriter.println("==> Get testedThreadID...");
+ long testedThreadID = debuggeeWrapper.vmMirror
+ .getThreadID(ForceEarlyReturnDebuggee.THREAD_OBJECT);
+ logWriter.println("==> Get testedThreadID is" + testedThreadID);
+
+ // Suspend the VM before perform command
+ logWriter.println("==> testedThreadID = " + testedThreadID);
+ logWriter.println("==> suspend testedThread...");
+ debuggeeWrapper.vmMirror.suspendThread(testedThreadID);
+
+ // Compose the ForceEarlyReturn command
+ CommandPacket forceEarlyReturnPacket = new CommandPacket(
+ JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
+ JDWPCommands.ThreadReferenceCommandSet.ForceEarlyReturnCommand);
+ forceEarlyReturnPacket.setNextValueAsThreadID(testedThreadID);
+ forceEarlyReturnPacket.setNextValueAsValue(new Value(Tag.OBJECT_TAG,
+ testObjID));
+
+ // Perform the command
+ logWriter.println("==> Perform " + thisCommandName);
+ ReplyPacket forceEarlyReturnReply = debuggeeWrapper.vmMirror
+ .performCommand(forceEarlyReturnPacket);
+ forceEarlyReturnPacket = null;
+
+ checkReplyPacket(forceEarlyReturnReply,
+ "ThreadReference::ForceEarlyReturn command");
+
+ // Resume the thread
+ logWriter.println("==> testedThreadID = " + testedThreadID);
+ logWriter.println("==> resume testedThread...");
+ debuggeeWrapper.vmMirror.resumeThread(testedThreadID);
+
+ String isTestObj = synchronizer.receiveMessage();
+ // Check the early returned value
+ if (!isTestObj.equals("TRUE")) {
+ printErrorAndFail(thisCommandName
+ + "returned value is not test object set by ForceEarlyReturn command");
+ }
+ logWriter
+ .println("==> CHECK: PASSED: returned value does set by ForceEarlyReturn command.");
+ logWriter.println("==> Returned value: " + "void");
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(ForceEarlyReturn006Test.class);
+ }
+
+}
Propchange: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturn006Test.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturnDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturnDebuggee.java?rev=641236&view=auto
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturnDebuggee.java (added)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturnDebuggee.java Wed Mar 26 03:28:02 2008
@@ -0,0 +1,276 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.jpda.tests.jdwp.ThreadReference;
+
+import org.apache.harmony.jpda.tests.framework.DebuggeeSynchronizer;
+import org.apache.harmony.jpda.tests.framework.LogWriter;
+import org.apache.harmony.jpda.tests.framework.jdwp.Value;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+import org.apache.harmony.jpda.tests.share.SyncDebuggee;
+
+/**
+ * The class specifies debuggee for
+ * <code>org.apache.harmony.jpda.tests.jdwp.ThreadReference.ForceEarlyReturnTest</code>.
+ * This debuggee starts the tested thread which name is supplied by test and
+ * synchronized with test via the <code>SGNL_READY</code> and
+ * <code>SGNL_CONTINUE</code> signals.
+ */
+public class ForceEarlyReturnDebuggee extends SyncDebuggee {
+
+ public static String threadName;
+
+ static boolean isFuncVoidBreak = true;
+
+ static TestObject testObj = new TestObject();
+
+ public static final String THREAD_VOID = "THREAD_VOID";
+
+ public static final String THREAD_OBJECT = "THREAD_OBJECT";
+
+ public static final String THREAD_INT = "THREAD_INT";
+
+ public static final String THREAD_SHORT = "THREAD_SHORT";
+
+ public static final String THREAD_BYTE = "THREAD_BYTE";
+
+ public static final String THREAD_CHAR = "THREAD_CHAR";
+
+ public static final String THREAD_BOOLEAN = "THREAD_BOOLEAN";
+
+ public static final String THREAD_LONG = "THREAD_LONG";
+
+ public static final String THREAD_FLOAT = "THREAD_FLOAT";
+
+ public static final String THREAD_DOUBLE = "THREAD_DOUBLE";
+
+ public static boolean condition = true;
+
+ static Object waitForStart = new Object();
+
+ static Object waitForFinish = new Object();
+
+ public void run() {
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ threadName = synchronizer.receiveMessage();
+ DebuggeeThread thrd = new DebuggeeThread(threadName, logWriter,
+ synchronizer);
+ synchronized (waitForStart) {
+ thrd.start();
+ try {
+ waitForStart.wait();
+ } catch (InterruptedException e) {
+
+ }
+ }
+ synchronized (waitForFinish) {
+ logWriter.println("thread is finished");
+ }
+
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ }
+
+ public Object func_Object() {
+ logWriter.println("In func_Object");
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ while (condition)
+ ;
+ return new Object();
+ }
+
+ public int func_Int() {
+ logWriter.println("In func_Int");
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ while (condition)
+ ;
+ return -1;
+ }
+
+ public short func_Short() {
+ logWriter.println("In func_Short");
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ while (condition)
+ ;
+ return -1;
+ }
+
+ public byte func_Byte() {
+ logWriter.println("In func_Byte");
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ while (condition)
+ ;
+ return -1;
+ }
+
+ public char func_Char() {
+ logWriter.println("In func_Char");
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ while (condition)
+ ;
+ return 'Z';
+ }
+
+ public boolean func_Boolean() {
+ logWriter.println("In func_Boolean");
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ while (condition)
+ ;
+ return false;
+ }
+
+ public long func_Long() {
+ logWriter.println("In func_Long");
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ while (condition)
+ ;
+ return -1;
+ }
+
+ public float func_Float() {
+ logWriter.println("In func_Float");
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ while (condition)
+ ;
+ return -1;
+ }
+
+ public double func_Double() {
+ logWriter.println("In func_Double");
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ while (condition)
+ ;
+ return -1;
+ }
+
+ public void func_Void() {
+ logWriter.println("In func_Void");
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ while (condition)
+ ;
+ isFuncVoidBreak = false;
+ return;
+ }
+
+ class DebuggeeThread extends Thread {
+
+ LogWriter logWriter;
+
+ DebuggeeSynchronizer synchronizer;
+
+ public DebuggeeThread(String name, LogWriter logWriter,
+ DebuggeeSynchronizer synchronizer) {
+ super(name);
+ this.logWriter = logWriter;
+ this.synchronizer = synchronizer;
+ }
+
+ public void run() {
+
+ synchronized (ForceEarlyReturnDebuggee.waitForFinish) {
+
+ synchronized (ForceEarlyReturnDebuggee.waitForStart) {
+
+ ForceEarlyReturnDebuggee.waitForStart.notifyAll();
+
+ logWriter.println(getName() + ": started");
+
+ if (getName().equals(THREAD_OBJECT)) {
+ Object result = func_Object();
+ logWriter.println(getName() + ": " + "Object");
+ if (result instanceof TestObject) {
+ synchronizer.sendMessage("TRUE");
+ } else {
+ synchronizer.sendMessage("FALSE");
+ }
+ logWriter
+ .println(getName() + ": func_Object returned.");
+
+ } else if (getName().equals(THREAD_INT)) {
+ int result = func_Int();
+ logWriter.println(getName() + ": " + result);
+ synchronizer
+ .sendMessage(new Integer(result).toString());
+ logWriter.println(getName() + ": func_Int returned.");
+ } else if (getName().equals(THREAD_SHORT)) {
+ short result = func_Short();
+ logWriter.println(getName() + ": " + result);
+ synchronizer
+ .sendMessage(new Integer(result).toString());
+ logWriter.println(getName() + ": func_Short returned.");
+ } else if (getName().equals(THREAD_BYTE)) {
+ byte result = func_Byte();
+ logWriter.println(getName() + ": " + result);
+ synchronizer
+ .sendMessage(new Integer(result).toString());
+ logWriter.println(getName() + ": func_Byte returned.");
+ } else if (getName().equals(THREAD_CHAR)) {
+ char result = func_Char();
+ logWriter.println(getName() + ": " + result);
+ synchronizer.sendMessage(new Character(result)
+ .toString());
+ logWriter.println(getName() + ": func_Char returned.");
+ } else if (getName().equals(THREAD_BOOLEAN)) {
+ Boolean result = func_Boolean();
+ logWriter.println(getName() + ": " + result);
+ synchronizer
+ .sendMessage(new Boolean(result).toString());
+ logWriter.println(getName()
+ + ": func_Boolean returned.");
+ } else if (getName().equals(THREAD_LONG)) {
+ long result = func_Long();
+ logWriter.println(getName() + ": " + result);
+ synchronizer.sendMessage(new Long(result).toString());
+ logWriter.println(getName() + ": func_Long returned.");
+ } else if (getName().equals(THREAD_FLOAT)) {
+ float result = func_Float();
+ logWriter.println(getName() + ": " + result);
+ synchronizer.sendMessage(new Float(result).toString());
+ logWriter.println(getName() + ": func_Float returned.");
+ } else if (getName().equals(THREAD_DOUBLE)) {
+ double result = func_Double();
+ logWriter.println(getName() + ": " + result);
+ synchronizer.sendMessage(new Double(result).toString());
+ logWriter
+ .println(getName() + ": func_Double returned.");
+ } else {
+ func_Void();
+ logWriter.println(getName() + ": " + "void");
+ if (isFuncVoidBreak) {
+ synchronizer.sendMessage("TRUE");
+ } else {
+ synchronizer.sendMessage("FALSE");
+ }
+ logWriter.println(getName() + ": func_Void returned.");
+ }
+
+ logWriter.println(getName() + ": finished");
+
+ }
+ }
+ }
+ }
+
+ public static void main(String[] args) {
+ runDebuggee(ForceEarlyReturnDebuggee.class);
+ }
+
+}
+
+class TestObject {
+
+}
Propchange: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturnDebuggee.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturnTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturnTest.java?rev=641236&view=auto
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturnTest.java (added)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturnTest.java Wed Mar 26 03:28:02 2008
@@ -0,0 +1,234 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.jpda.tests.jdwp.ThreadReference;
+
+import org.apache.harmony.jpda.tests.framework.TestErrorException;
+import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands;
+import org.apache.harmony.jpda.tests.framework.jdwp.JDWPConstants;
+import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket;
+import org.apache.harmony.jpda.tests.framework.jdwp.Value;
+import org.apache.harmony.jpda.tests.jdwp.share.JDWPSyncTestCase;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+/**
+ * JDWP Unit test for ThreadReference.ForceEarlyReturn command.
+ */
+public class ForceEarlyReturnTest extends JDWPSyncTestCase {
+
+ static final String thisCommandName = "ThreadReference.ForceEarlyReturn command ";
+
+ static String thisTestName;
+
+ static String testThreadName;
+
+ static final int EXPECTED_INT = 5;
+
+ static final short EXPECTED_SHORT = 20;
+
+ static final char EXPECTED_CHAR = 'A';
+
+ static final byte EXPECTED_BYTE = 30;
+
+ static final boolean EXPECTED_BOOLEAN = true;
+
+ static Value expectedValue;
+
+ static final String debuggeeSignature = "Lorg/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturnDebuggee;";
+
+ protected String getDebuggeeClassName() {
+ return "org.apache.harmony.jpda.tests.jdwp.ThreadReference.ForceEarlyReturnDebuggee";
+ }
+
+ // ForceEarlyReturn needs canForceEarlyReturn VM capability support
+ private boolean isCapability() {
+ // check capability, relevant for this test
+ logWriter.println("=> Check capability: canForceEarlyReturn");
+ debuggeeWrapper.vmMirror.capabilities();
+ boolean isCapability = debuggeeWrapper.vmMirror.targetVMCapabilities.canForceEarlyReturn;
+ return isCapability;
+ }
+
+ private String toString(Value value) {
+
+ switch (value.getTag()) {
+ case JDWPConstants.Tag.BOOLEAN_TAG:
+ return (new Boolean(value.getBooleanValue())).toString();
+ case JDWPConstants.Tag.BYTE_TAG:
+ return (new Byte(value.getByteValue())).toString();
+ case JDWPConstants.Tag.CHAR_TAG:
+ return (new Character(value.getCharValue())).toString();
+ case JDWPConstants.Tag.INT_TAG:
+ return (new Integer(value.getIntValue())).toString();
+ case JDWPConstants.Tag.SHORT_TAG:
+ return (new Short(value.getShortValue())).toString();
+ }
+ return "";
+ }
+
+ public void RunTestForceEarlyReturn() {
+ logWriter.println("==> " + thisTestName + " for " + thisCommandName
+ + ": START...");
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ if (!isCapability()) {
+ logWriter
+ .println("##WARNING: this VM dosn't possess capability: canForceEarlyReturn");
+ return;
+ }
+ // Tell debuggee to start a thread
+ synchronizer.sendMessage(testThreadName);
+
+ // Wait until the func_Int is processing.
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ // Getting ID of the tested thread
+ logWriter.println("==> testedThreadName = " + testThreadName);
+ logWriter.println("==> Get testedThreadID...");
+ long testedThreadID = debuggeeWrapper.vmMirror
+ .getThreadID(testThreadName);
+ logWriter.println("==> Get testedThreadID is" + testedThreadID);
+
+ // Suspend the VM before perform command
+ logWriter.println("==> testedThreadID = " + testedThreadID);
+ logWriter.println("==> suspend testedThread...");
+ debuggeeWrapper.vmMirror.suspendThread(testedThreadID);
+
+ // Compose the ForceEarlyReturn command
+ CommandPacket forceEarlyReturnPacket = new CommandPacket(
+ JDWPCommands.ThreadReferenceCommandSet.CommandSetID,
+ JDWPCommands.ThreadReferenceCommandSet.ForceEarlyReturnCommand);
+ forceEarlyReturnPacket.setNextValueAsThreadID(testedThreadID);
+ forceEarlyReturnPacket.setNextValueAsValue(expectedValue);
+
+ // Perform the command
+ logWriter.println("==> Perform " + thisCommandName);
+ ReplyPacket forceEarlyReturnReply = debuggeeWrapper.vmMirror
+ .performCommand(forceEarlyReturnPacket);
+ forceEarlyReturnPacket = null;
+
+ checkReplyPacket(forceEarlyReturnReply,
+ "ThreadReference::ForceEarlyReturn command");
+
+ // Resume the thread
+ logWriter.println("==> testedThreadID = " + testedThreadID);
+ logWriter.println("==> resume testedThread...");
+ debuggeeWrapper.vmMirror.resumeThread(testedThreadID);
+
+ String actualValue = synchronizer.receiveMessage();
+ // Check the early returned value
+ if (!actualValue.equals(toString(expectedValue))) {
+ printErrorAndFail(thisCommandName
+ + "returned value is not set by ForceEarlyReturn command"
+ + " expected:<" + expectedValue.toString() + "> but was:<"
+ + actualValue + ">");
+ }
+ logWriter
+ .println("==> CHECK: PASSED: returned value does set by ForceEarlyReturn command.");
+ logWriter.println("==> Returned value: " + actualValue);
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ }
+
+ /**
+ * This testcase exercises ThreadReference.ForceEarlyReturn command. <BR>
+ * At first the test starts ForceEarlyReturnDebuggee and send it the thread
+ * name through which to start a specific thread. Then the test performs the
+ * ThreadReference.ForceEarlyReturn command for the tested thread and gets
+ * the returned value of the called method. The returned value should be
+ * equal to the value which is used in ForceEarlyReturn Command. In this
+ * testcase, an Int value is returned.
+ */
+ public void testForceEarlyReturn_ReturnInt() {
+ thisTestName = "testForceEarlyReturn_ReturnInt";
+ testThreadName = ForceEarlyReturnDebuggee.THREAD_INT;
+ expectedValue = new Value(EXPECTED_INT);
+ RunTestForceEarlyReturn();
+ }
+
+ /**
+ * This testcase exercises ThreadReference.ForceEarlyReturn command. <BR>
+ * At first the test starts ForceEarlyReturnDebuggee and send it the thread
+ * name through which to start a specific thread. Then the test performs the
+ * ThreadReference.ForceEarlyReturn command for the tested thread and gets
+ * the returned value of the called method. The returned value should be
+ * equal to the value which is used in ForceEarlyReturn Command. In this
+ * testcase, an Short value is returned.
+ */
+ public void testForceEarlyReturn_ReturnShort() {
+ thisTestName = "testForceEarlyReturn_ReturnShort";
+ testThreadName = ForceEarlyReturnDebuggee.THREAD_SHORT;
+ expectedValue = new Value(EXPECTED_SHORT);
+ RunTestForceEarlyReturn();
+ }
+
+ /**
+ * This testcase exercises ThreadReference.ForceEarlyReturn command. <BR>
+ * At first the test starts ForceEarlyReturnDebuggee and send it the thread
+ * name through which to start a specific thread. Then the test performs the
+ * ThreadReference.ForceEarlyReturn command for the tested thread and gets
+ * the returned value of the called method. The returned value should be
+ * equal to the value which is used in ForceEarlyReturn Command. In this
+ * testcase, an Byte value is returned.
+ */
+ public void testForceEarlyReturn_ReturnByte() {
+ thisTestName = "testForceEarlyReturn_ReturnByte";
+ testThreadName = ForceEarlyReturnDebuggee.THREAD_BYTE;
+ expectedValue = new Value(EXPECTED_BYTE);
+ RunTestForceEarlyReturn();
+ }
+
+ /**
+ * This testcase exercises ThreadReference.ForceEarlyReturn command. <BR>
+ * At first the test starts ForceEarlyReturnDebuggee and send it the thread
+ * name through which to start a specific thread. Then the test performs the
+ * ThreadReference.ForceEarlyReturn command for the tested thread and gets
+ * the returned value of the called method. The returned value should be
+ * equal to the value which is used in ForceEarlyReturn Command. In this
+ * testcase, an Char value is returned.
+ */
+ public void testForceEarlyReturn_ReturnChar() {
+ thisTestName = "testForceEarlyReturn_ReturnChar";
+ testThreadName = ForceEarlyReturnDebuggee.THREAD_CHAR;
+ expectedValue = new Value(EXPECTED_CHAR);
+ RunTestForceEarlyReturn();
+ }
+
+ /**
+ * This testcase exercises ThreadReference.ForceEarlyReturn command. <BR>
+ * At first the test starts ForceEarlyReturnDebuggee and send it the thread
+ * name through which to start a specific thread. Then the test performs the
+ * ThreadReference.ForceEarlyReturn command for the tested thread and gets
+ * the returned value of the called method. The returned value should be
+ * equal to the value which is used in ForceEarlyReturn Command. In this
+ * testcase, an Boolean value is returned.
+ */
+ public void testForceEarlyReturn_ReturnBoolean() {
+ thisTestName = "testForceEarlyReturn_ReturnBoolean";
+ testThreadName = ForceEarlyReturnDebuggee.THREAD_BOOLEAN;
+ expectedValue = new Value(EXPECTED_BOOLEAN);
+ RunTestForceEarlyReturn();
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(ForceEarlyReturnTest.class);
+
+ }
+
+}
Propchange: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ThreadReference/ForceEarlyReturnTest.java
------------------------------------------------------------------------------
svn:eol-style = native