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/03 09:55:57 UTC
svn commit: r632989 - in
/harmony/enhanced/jdktools/branches/java6/modules/jpda/src:
main/native/jdwp/common/agent/commands/ main/native/jdwp/common/agent/core/
main/native/jdwp/common/generic/
test/java/org/apache/harmony/jpda/tests/framework/jdwp/ te...
Author: lvjing
Date: Mon Mar 3 00:55:56 2008
New Revision: 632989
URL: http://svn.apache.org/viewvc?rev=632989&view=rev
Log:
Apply patch for HARMONY-5549 ([jdktools][jdwp6] Add new jdwp command "ClassFileVersion" for jdwp 6)
Added:
harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ReferenceType/ClassFileVersionDebuggee.java (with props)
harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ReferenceType/ClassFileVersionTest.java (with props)
Modified:
harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ReferenceType.cpp
harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ReferenceType.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/JDWPCommands.java
Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ReferenceType.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ReferenceType.cpp?rev=632989&r1=632988&r2=632989&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ReferenceType.cpp (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ReferenceType.cpp Mon Mar 3 00:55:56 2008
@@ -848,4 +848,46 @@
} // SourceDebugExtensionHandler::Execute()
+// New commands for Java 6
+
//------------------------------------------------------------------------------
+// ClassFileVersionHandler(17)-----------------------------------------------
+
+void
+ReferenceType::ClassFileVersionHandler::Execute(JNIEnv *jni)
+ throw (AgentException)
+{
+ jclass jvmClass = m_cmdParser->command.ReadReferenceTypeID(jni);
+ // Can be: InternalErrorException, OutOfMemoryException,
+ // JDWP_ERROR_INVALID_CLASS, JDWP_ERROR_INVALID_OBJECT
+#ifndef NDEBUG
+ if (JDWP_TRACE_ENABLED(LOG_KIND_DATA)) {
+ jvmtiError err;
+ char* signature = 0;
+ JVMTI_TRACE(err, GetJvmtiEnv()->GetClassSignature(jvmClass, &signature, 0));
+ JvmtiAutoFree afcs(signature);
+ JDWP_TRACE_DATA("SourceDebugExtension: received: refTypeID=" << jvmClass
+ << ", classSignature=" << JDWP_CHECK_NULL(signature));
+ }
+#endif
+
+ jint minorVersion = -1;
+ jint majorVersion = -1;
+ jvmtiError err;
+ JVMTI_TRACE(err, GetJvmtiEnv()->GetClassVersionNumbers(jvmClass, &minorVersion, &majorVersion));
+
+ if (err != JVMTI_ERROR_NONE) {
+ // Can be: JVMTI_ERROR_ABSENT_INFORMATION, JVMTI_ERROR_INVALID_CLASS,
+ // JVMTI_ERROR_NULL_POINTER
+ throw AgentException(err);
+ }
+
+ m_cmdParser->reply.WriteInt(majorVersion);
+ JDWP_TRACE_DATA("ClassFileVersion: send: majorVersion="
+ << majorVersion);
+
+ m_cmdParser->reply.WriteInt(minorVersion);
+ JDWP_TRACE_DATA("ClassFileVersion: send: minorVersion="
+ << minorVersion);
+
+}
Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ReferenceType.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ReferenceType.h?rev=632989&r1=632988&r2=632989&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ReferenceType.h (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/main/native/jdwp/common/agent/commands/ReferenceType.h Mon Mar 3 00:55:56 2008
@@ -346,8 +346,26 @@
}; // MethodsWithGenericHandler class
+ //New commands for Java 6
+
// =========================================================================
+ /**
+ * The class implements the <code> ClassFileVersion(17)</code>
+ * command from the <code>ReferenceType</code> command set.
+ */
+ class ClassFileVersionHandler : public SyncCommandHandler {
+ protected:
+
+ /**
+ * Executes the <code>ClassFileVersion</code> JDWP command for the
+ * <code>ReferenceType</code> command set.
+ *
+ * @param jni - the JNI interface pointer
+ */
+ virtual void Execute(JNIEnv *jni) throw(AgentException);
+ };// ClassFileVersionHandler class
+ // =========================================================================
} // ReferenceType namespace
} // jdwp namesoace
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=632989&r1=632988&r2=632989&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 Mon Mar 3 00:55:56 2008
@@ -249,6 +249,11 @@
case JDWP_COMMAND_RT_METHODS_WITH_GENERIC:
return new ReferenceType::MethodsWithGenericHandler();
+
+ //New commands for Java 6
+ case JDWP_COMMAND_RT_CLASS_FILE_VERSION:
+ return new ReferenceType::ClassFileVersionHandler();
+
}//JDWP_COMMAND_SET_REFERENCE_TYPE
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=632989&r1=632988&r2=632989&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 Mon Mar 3 00:55:56 2008
@@ -100,6 +100,10 @@
JDWP_COMMAND_RT_SIGNATURE_WITH_GENERIC = 13,
JDWP_COMMAND_RT_FIELDS_WITH_GENERIC = 14,
JDWP_COMMAND_RT_METHODS_WITH_GENERIC = 15,
+ //New commands for Java 6
+ JDWP_COMMAND_RT_INSTANCES = 16,
+ JDWP_COMMAND_RT_CLASS_FILE_VERSION = 17,
+ JDWP_COMMAND_RT_CONSTANT_POOL = 18,
/* Commands ClassType */
JDWP_COMMAND_CT_SUPERCLASS = 1,
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=632989&r1=632988&r2=632989&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 Mon Mar 3 00:55:56 2008
@@ -115,6 +115,13 @@
public static final byte FieldsWithGenericCommand = 14;
public static final byte MethodsWithGenericCommand = 15;
+
+ //New commands for Java 6
+ public static final byte InstancesCommand = 16;
+
+ public static final byte ClassFileVersionCommand = 17;
+
+ public static final byte ConstantPoolCommand = 18;
}
/**
Added: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ReferenceType/ClassFileVersionDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ReferenceType/ClassFileVersionDebuggee.java?rev=632989&view=auto
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ReferenceType/ClassFileVersionDebuggee.java (added)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ReferenceType/ClassFileVersionDebuggee.java Mon Mar 3 00:55:56 2008
@@ -0,0 +1,38 @@
+/*
+ * 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.ReferenceType;
+
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+import org.apache.harmony.jpda.tests.share.SyncDebuggee;
+
+public class ClassFileVersionDebuggee extends SyncDebuggee {
+
+ @Override
+ public void run() {
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+ logWriter.println("--> Debuggee: ClassFileVersionDebuggee...");
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ }
+
+ public static void main(String[] args) {
+ runDebuggee(ClassFileVersionDebuggee.class);
+
+ }
+
+}
Propchange: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ReferenceType/ClassFileVersionDebuggee.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ReferenceType/ClassFileVersionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ReferenceType/ClassFileVersionTest.java?rev=632989&view=auto
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ReferenceType/ClassFileVersionTest.java (added)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ReferenceType/ClassFileVersionTest.java Mon Mar 3 00:55:56 2008
@@ -0,0 +1,114 @@
+/*
+ * 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.ReferenceType;
+
+import java.io.DataInputStream;
+import java.io.FileInputStream;
+
+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.jdwp.share.JDWPSyncTestCase;
+import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
+
+public class ClassFileVersionTest extends JDWPSyncTestCase {
+
+ static final int testStatusPassed = 0;
+
+ static final int testStatusFailed = -1;
+
+ static final String thisCommandName = "ReferenceType.ClassFileVersion command";
+
+ static final String debuggeeSignature = "Lorg/apache/harmony/jpda/tests/jdwp/ReferenceType/ClassFileVersionDebuggee;";
+
+ static final String debuggeeClass = "org\\apache\\harmony\\jpda\\tests\\jdwp\\ReferenceType\\ClassFileVersionDebuggee.class";
+
+ @Override
+ protected String getDebuggeeClassName() {
+ return "org.apache.harmony.jpda.tests.jdwp.ReferenceType.ClassFileVersionDebuggee";
+ }
+
+ /**
+ * This testcase exercises ReferenceType.ClassFileVersion command. <BR>
+ * The test starts ClassFileVersionDebuggee class, requests referenceTypeId
+ * for this class by VirtualMachine.ClassesBySignature command, then
+ * performs ReferenceType.ClassFileVersion command and checks that returned
+ * majorVersion and minorVersion are equal to expected values.
+ */
+ public void testClassFileVersion001() {
+ String thisTestName = "testClassFileVersion001";
+ logWriter.println("==> " + thisTestName + " for " + thisCommandName
+ + ": START...");
+ synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+
+ long refTypeID = getClassIDBySignature(debuggeeSignature);
+
+ logWriter.println("=> Debuggee class = " + getDebuggeeClassName());
+ logWriter.println("=> referenceTypeID for Debuggee class = "
+ + refTypeID);
+ logWriter.println("=> CHECK: send " + thisCommandName
+ + " and check reply...");
+
+ CommandPacket classFileVersionCommand = new CommandPacket(
+ JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
+ JDWPCommands.ReferenceTypeCommandSet.ClassFileVersionCommand);
+ classFileVersionCommand.setNextValueAsReferenceTypeID(refTypeID);
+
+ ReplyPacket classFileVersionReply = debuggeeWrapper.vmMirror
+ .performCommand(classFileVersionCommand);
+ classFileVersionCommand = null;
+ checkReplyPacket(classFileVersionReply, thisCommandName);
+
+ int majorVersion = classFileVersionReply.getNextValueAsInt();
+ int minorVersion = classFileVersionReply.getNextValueAsInt();
+
+ int expectedMinorVersion = -1;
+ int expectedMajorVersion = -1;
+ try {
+ DataInputStream in = new DataInputStream(new FileInputStream(
+ debuggeeClass));
+ int magic = in.readInt();
+ if (magic != 0xcafebabe) {
+ printErrorAndFail(debuggeeClass + " is not a valid class!");
+ }
+ expectedMinorVersion = in.readUnsignedShort();
+ expectedMajorVersion = in.readUnsignedShort();
+ in.close();
+ } catch (Exception e) {
+ printErrorAndFail(thisCommandName + "has error in reading target class file!");
+ }
+
+ assertEquals(thisCommandName + "returned invalid majorVersion,", expectedMajorVersion, majorVersion, null, null);
+ assertEquals(thisCommandName + "returned invalid minorVersion,", expectedMinorVersion, minorVersion, null, null);
+
+ logWriter.println("=> CHECK: PASSED: expected majorVersion and minorVersion are returned:");
+ logWriter.println("=> majorVersion = " + majorVersion);
+ logWriter.println("=> minorVersion = " + minorVersion);
+
+ synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+ logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": FINISH");
+
+ assertAllDataRead(classFileVersionReply);
+
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(ClassFileVersionTest.class);
+ }
+}
Propchange: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ReferenceType/ClassFileVersionTest.java
------------------------------------------------------------------------------
svn:eol-style = native