harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lvj...@apache.org
Subject svn commit: r635455 - in /harmony/enhanced/jdktools/branches/java6/modules/jpda: ./ make/ src/main/native/jdwp/common/agent/commands/ src/main/native/jdwp/common/agent/core/ src/test/java/org/apache/harmony/jpda/tests/framework/jdwp/ src/test/java/org/...
Date Mon, 10 Mar 2008 06:43:00 GMT
Author: lvjing
Date: Sun Mar  9 23:42:58 2008
New Revision: 635455

URL: http://svn.apache.org/viewvc?rev=635455&view=rev
Log:
Apply patch for HARMONY-5587,[jdktools][jdwp6] Add new command ConstantPool Command for Java
6

Added:
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ReferenceType/ConstantPoolDebuggee.java
  (with props)
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ReferenceType/ConstantPoolTest.java
  (with props)
Modified:
    harmony/enhanced/jdktools/branches/java6/modules/jpda/build.xml
    harmony/enhanced/jdktools/branches/java6/modules/jpda/make/exclude.common
    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/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/VmMirror.java
    harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ReferenceType/ClassFileVersionTest.java

Modified: harmony/enhanced/jdktools/branches/java6/modules/jpda/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/build.xml?rev=635455&r1=635454&r2=635455&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/build.xml (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/build.xml Sun Mar  9 23:42:58 2008
@@ -233,7 +233,7 @@
                        errorproperty="test.errors"
                        failureproperty="test.failures"
                        showoutput="off"
-                       dir="${hy.tests.reports}"
+                       dir="${tests.build.output}/classes"
                        jvm="${test.debugger.jvm}">
 
             <!-- JVM arguments for debugger process -->

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=635455&r1=635454&r2=635455&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/make/exclude.common (original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/make/exclude.common Sun Mar  9 23:42:58
2008
@@ -9,4 +9,6 @@
 org/apache/harmony/jpda/tests/jdwp/ReferenceType/ClassFileVersionDebuggee.java
 org/apache/harmony/jpda/tests/jdwp/ReferenceType/ClassFileVersionTest.java
 #5564
-org/apache/harmony/jpda/tests/jdwp/ReferenceType/InstancesTest.java
\ No newline at end of file
+org/apache/harmony/jpda/tests/jdwp/ReferenceType/InstancesTest.java
+#5587
+org/apache/harmony/jpda/tests/jdwp/ReferenceType/ConstantPoolTest
\ No newline at end of file

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=635455&r1=635454&r2=635455&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
Sun Mar  9 23:42:58 2008
@@ -972,6 +972,55 @@
     
 }
 
+//------------------------------------------------------------------------------
+// ConstantPoolHandler(18)-----------------------------------------------
+
+void
+ReferenceType::ConstantPoolHandler::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
+    jvmtiError err;
+    jint count = 0;
+    jint bytes = 0;
+    unsigned char* cpbytes = 0;
+    // Return the raw bytes of the constant pool 
+    JVMTI_TRACE(err, GetJvmtiEnv()->GetConstantPool(jvmClass, &count, &bytes,
&cpbytes));
+    JvmtiAutoFree afCpbytes(cpbytes);
+
+    if (err != JVMTI_ERROR_NONE) {
+        // Can be: JVMTI_ERROR_MUST_POSSESS_CAPABILITY, JVMTI_ERROR_ABSENT_INFORMATION
+        // JVMTI_ERROR_INVALID_CLASS, JVMTI_ERROR_INVALID_OBJECT
+        // JVMTI_ERROR_NULL_POINTER 
+        throw AgentException(err);
+     }
+
+    m_cmdParser->reply.WriteInt(count);
+    JDWP_TRACE_DATA("ConstantPool: send: count=" 
+        << count);
+
+    m_cmdParser->reply.WriteInt(bytes);
+     JDWP_TRACE_DATA("ConstantPool: send: bytes=" 
+        << bytes);
+
+    for (int i = 0; i < bytes; i++) {
+        m_cmdParser->reply.WriteByte(cpbytes[i]);
+    }
+
+}
+
 //-----------------------------------------------------------------------------
 // Heap callbacks, used in Instances command
 //-----------------------------------------------------------------------------

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=635455&r1=635454&r2=635455&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
Sun Mar  9 23:42:58 2008
@@ -385,6 +385,22 @@
             virtual void Execute(JNIEnv *jni) throw(AgentException);
         };// ClassFileVersionHandler class
 
+    // =========================================================================
+        /**
+        * The class implements the <code> ConstantPool(18)</code>
+         * command from the <code>ReferenceType</code> command set.
+         */
+        class ConstantPoolHandler : public SyncCommandHandler {
+        protected:
+
+            /**
+             * Executes the <code>ConstantPool</code> JDWP command for the
+             * <code>ReferenceType</code> command set.
+             *
+             * @param jni - the JNI interface pointer
+             */
+            virtual void Execute(JNIEnv *jni) throw(AgentException);
+        };//ConstantPoolHandler class
 
    // =========================================================================
    //-----------------------------------------------------------------------------

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=635455&r1=635454&r2=635455&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
Sun Mar  9 23:42:58 2008
@@ -257,6 +257,8 @@
         case JDWP_COMMAND_RT_CLASS_FILE_VERSION:
             return new ReferenceType::ClassFileVersionHandler();
 
+        case JDWP_COMMAND_RT_CONSTANT_POOL:
+            return new ReferenceType::ConstantPoolHandler();
         }//JDWP_COMMAND_SET_REFERENCE_TYPE
         break;
 

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=635455&r1=635454&r2=635455&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
Sun Mar  9 23:42:58 2008
@@ -69,7 +69,7 @@
 
     public boolean reserved19                       = false;
 
-    public boolean reserved20                       = false;
+    public boolean canGetConstantPool               = false;
 
     public boolean reserved21                       = false;
 

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=635455&r1=635454&r2=635455&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
Sun Mar  9 23:42:58 2008
@@ -415,7 +415,8 @@
         targetVMCapabilities.reserved17 = replyPacket.getNextValueAsBoolean();
         targetVMCapabilities.reserved18 = replyPacket.getNextValueAsBoolean();
         targetVMCapabilities.reserved19 = replyPacket.getNextValueAsBoolean();
-        targetVMCapabilities.reserved20 = replyPacket.getNextValueAsBoolean();
+        targetVMCapabilities.canGetConstantPool = replyPacket
+                .getNextValueAsBoolean();
         targetVMCapabilities.reserved21 = replyPacket.getNextValueAsBoolean();
         targetVMCapabilities.reserved22 = replyPacket.getNextValueAsBoolean();
         targetVMCapabilities.reserved23 = replyPacket.getNextValueAsBoolean();

Modified: 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=635455&r1=635454&r2=635455&view=diff
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ReferenceType/ClassFileVersionTest.java
(original)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ReferenceType/ClassFileVersionTest.java
Sun Mar  9 23:42:58 2008
@@ -37,7 +37,7 @@
 
 	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";
+	static final String debuggeeClass = "org/apache/harmony/jpda/tests/jdwp/ReferenceType/ClassFileVersionDebuggee.class";
 
 	@Override
 	protected String getDebuggeeClassName() {

Added: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ReferenceType/ConstantPoolDebuggee.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ReferenceType/ConstantPoolDebuggee.java?rev=635455&view=auto
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ReferenceType/ConstantPoolDebuggee.java
(added)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ReferenceType/ConstantPoolDebuggee.java
Sun Mar  9 23:42:58 2008
@@ -0,0 +1,36 @@
+/*
+ * 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 ConstantPoolDebuggee extends SyncDebuggee {
+
+    public void run() {
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+        logWriter.println("--> Debuggee: ContantPoolDebuggee...");
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+    }
+
+    public static void main(String [] args) {
+        runDebuggee(ConstantPoolDebuggee.class);
+    }
+
+}
\ No newline at end of file

Propchange: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ReferenceType/ConstantPoolDebuggee.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ReferenceType/ConstantPoolTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ReferenceType/ConstantPoolTest.java?rev=635455&view=auto
==============================================================================
--- harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ReferenceType/ConstantPoolTest.java
(added)
+++ harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ReferenceType/ConstantPoolTest.java
Sun Mar  9 23:42:58 2008
@@ -0,0 +1,141 @@
+/*
+ * 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.BufferedInputStream;
+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;
+
+
+/**
+ * JDWP Unit test for ReferenceType.ConstantPool command.
+ */
+public class ConstantPoolTest extends JDWPSyncTestCase {
+
+    static final int testStatusPassed = 0;
+    
+    static final int testStatusFailed = -1;
+    
+    static final String thisCommandName = "ReferenceType.ConstantPool command";
+    
+    static final String debuggeeSignature = "Lorg/apache/harmony/jpda/tests/jdwp/ReferenceType/ConstantPoolDebuggee;";
+    
+    static final String debuggeeClass = "org/apache/harmony/jpda/tests/jdwp/ReferenceType/ConstantPoolDebuggee.class";
+
+
+    protected String getDebuggeeClassName() {
+        return "org.apache.harmony.jpda.tests.jdwp.ReferenceType.ConstantPoolDebuggee";
+    }
+
+    /**
+     * This testcase exercises ReferenceType.ConstantPool command.
+     * <BR>The test starts ConstantPoolDebuggee class, requests referenceTypeId
+     * for this class by VirtualMachine.ClassesBySignature command, then
+     * performs ReferenceType.ConstantPool command and checks that returned
+     * constant entry count and costant pool bytes are expected.
+     */
+    public void testConstantPool001() {
+        String thisTestName = "testConstantPool001";
+        
+        // Check capability, relevant for this test
+        logWriter.println("=> Check capability: canGetConstantPool");
+        debuggeeWrapper.vmMirror.capabilities();
+        boolean isCapability = debuggeeWrapper.vmMirror.targetVMCapabilities.canGetConstantPool;
+        if (!isCapability) {
+            logWriter
+                    .println("##WARNING: this VM dosn't possess capability: canGetConstantPool");
+            return;
+        }
+        
+        logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": START...");
+        synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY);
+   
+        // Compose ConstantPool command 
+        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 ConstantPoolCommand = new CommandPacket(
+                JDWPCommands.ReferenceTypeCommandSet.CommandSetID,
+                JDWPCommands.ReferenceTypeCommandSet.ConstantPoolCommand);
+        ConstantPoolCommand.setNextValueAsReferenceTypeID(refTypeID);
+
+        // Perform ConstantPool command and get reply package 
+        ReplyPacket ConstantPoolReply = debuggeeWrapper.vmMirror.performCommand(ConstantPoolCommand);
+        ConstantPoolCommand = null;
+        checkReplyPacket(ConstantPoolReply, thisCommandName);
+        
+        // Attain entry count and constant pool byte size from reply package
+        int returnedEntryCount = ConstantPoolReply.getNextValueAsInt();
+        int returnedCpByteCount = ConstantPoolReply.getNextValueAsInt();
+
+        // Attain entry count and constant pool content from class file
+        
+        // Read constant pool content from class file
+        // length = magic num(4b) + major(2b) + minor(2b) + entry count(2b) + returnedCpByteCount
+        int length = 10 + returnedCpByteCount;
+        byte[] bytes = new byte[length];
+        
+        try {
+            BufferedInputStream in = new BufferedInputStream(new FileInputStream(debuggeeClass));
+            int count = -1;
+            while(count != 0){
+                count = in.read(bytes,0,length);
+                count = length - count;
+            }
+        } catch (Exception e) {
+            printErrorAndFail(thisCommandName + "has error in reading target class file!");
+        }
+        
+        // Entry count is placed in byte 8 and byte 9 of class file
+        short expectedEntryCount = (short)(bytes[8] << 8 | bytes[9]);
+        
+        // Compare entry count
+        assertEquals(thisCommandName + "returned invalid entry count,", expectedEntryCount,
returnedEntryCount, null, null);
+        logWriter.println("=> CHECK: PASSED: expected entry count is returned:");
+        logWriter.println("=> Signature = " + returnedEntryCount);
+
+        int startIndex = 10;
+        // Compare constant pool content
+        for (int i = 0; i < returnedCpByteCount; i++){
+            byte returnedCpByte = ConstantPoolReply.getNextValueAsByte();
+            assertEquals(thisCommandName + "returned invalid entry count,", bytes[startIndex+i],
returnedCpByte, null, null);
+        }
+        
+        logWriter.println("=> CHECK: PASSED: expected constant pool bytes are returned:");
+        logWriter.println("=> Constant Pool Byte Count = " + returnedCpByteCount);
+
+        synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
+        logWriter.println("==> " + thisTestName + " for " + thisCommandName + ": FINISH");
+
+        assertAllDataRead(ConstantPoolReply);
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(ConstantPoolTest.class);
+    }
+}

Propchange: harmony/enhanced/jdktools/branches/java6/modules/jpda/src/test/java/org/apache/harmony/jpda/tests/jdwp/ReferenceType/ConstantPoolTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message