Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 90400 invoked from network); 2 Jun 2010 10:45:18 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 2 Jun 2010 10:45:18 -0000 Received: (qmail 83516 invoked by uid 500); 2 Jun 2010 10:45:18 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 83448 invoked by uid 500); 2 Jun 2010 10:45:17 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 83441 invoked by uid 99); 2 Jun 2010 10:45:16 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Jun 2010 10:45:16 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Jun 2010 10:45:14 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 7637B23889C5; Wed, 2 Jun 2010 10:44:52 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r950482 - in /harmony/enhanced/java/trunk/classlib/modules/instrument/src: main/native/instrument/shared/ test/java/org/apache/harmony/tests/java/lang/instrument/ test/resources/jars/org/apache/harmony/tests/instrument/ Date: Wed, 02 Jun 2010 10:44:52 -0000 To: commits@harmony.apache.org From: odeakin@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100602104452.7637B23889C5@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: odeakin Date: Wed Jun 2 10:44:52 2010 New Revision: 950482 URL: http://svn.apache.org/viewvc?rev=950482&view=rev Log: The spec says that if the Boot-Class-Path entry in a java agent manifest specifies a relative path, that path should be taken relative to the location of the agent jar. Also adding a regression test case for this fix. Added: harmony/enhanced/java/trunk/classlib/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/BCP.jar (with props) harmony/enhanced/java/trunk/classlib/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/BCPTest.jar (with props) Modified: harmony/enhanced/java/trunk/classlib/modules/instrument/src/main/native/instrument/shared/inst_agt.c harmony/enhanced/java/trunk/classlib/modules/instrument/src/test/java/org/apache/harmony/tests/java/lang/instrument/InstrumentTest.java Modified: harmony/enhanced/java/trunk/classlib/modules/instrument/src/main/native/instrument/shared/inst_agt.c URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/instrument/src/main/native/instrument/shared/inst_agt.c?rev=950482&r1=950481&r2=950482&view=diff ============================================================================== --- harmony/enhanced/java/trunk/classlib/modules/instrument/src/main/native/instrument/shared/inst_agt.c (original) +++ harmony/enhanced/java/trunk/classlib/modules/instrument/src/main/native/instrument/shared/inst_agt.c Wed Jun 2 10:44:52 2010 @@ -380,10 +380,35 @@ jint Parse_Options(JavaVM *vm, JNIEnv *e //add bootclasspath bootclasspath = read_attribute(vm, manifest, lwrmanifest,"boot-class-path"); - if(NULL != bootclasspath){ + if (NULL != bootclasspath){ + +#if defined(WIN32) || defined(WIN64) + // On Windows the agent jar path can have a mixture of forward and back slashes. + // For ease, convert forward slashes to back slashes + char *currentSlash = strchr(jar_name, '/'); + while (currentSlash) { + *currentSlash = '\\'; + currentSlash = strchr(currentSlash, '/'); + } +#endif + bootclasspath_item = strtok(bootclasspath, " "); while(NULL != bootclasspath_item){ - check_jvmti_error(env, (*jvmti)->AddToBootstrapClassLoaderSearch(jvmti, bootclasspath_item),"Failed to add bootstrap classpath."); + if ((bootclasspath_item[0] != DIR_SEPARATOR) && (strrchr(jar_name, DIR_SEPARATOR))) { + // This is not an absolute path, so add this relative path to the path of the agent library + int lastSeparatorOff = strrchr(jar_name, DIR_SEPARATOR) - jar_name + 1; + int size = lastSeparatorOff + strlen(bootclasspath_item) + 1; + char *jarPath = (char *)hymem_allocate_memory(size); + + memcpy(jarPath, jar_name, lastSeparatorOff); + strcpy(jarPath + lastSeparatorOff, bootclasspath_item); + check_jvmti_error(env, (*jvmti)->AddToBootstrapClassLoaderSearch(jvmti, jarPath),"Failed to add bootstrap classpath."); + hymem_free_memory(jarPath); + } else { + // This is either an absolute path of jar_name has not path before the filename + check_jvmti_error(env, (*jvmti)->AddToBootstrapClassLoaderSearch(jvmti, bootclasspath_item),"Failed to add bootstrap classpath."); + } + bootclasspath_item = strtok(NULL, " "); } hymem_free_memory(bootclasspath); Modified: harmony/enhanced/java/trunk/classlib/modules/instrument/src/test/java/org/apache/harmony/tests/java/lang/instrument/InstrumentTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/instrument/src/test/java/org/apache/harmony/tests/java/lang/instrument/InstrumentTest.java?rev=950482&r1=950481&r2=950482&view=diff ============================================================================== --- harmony/enhanced/java/trunk/classlib/modules/instrument/src/test/java/org/apache/harmony/tests/java/lang/instrument/InstrumentTest.java (original) +++ harmony/enhanced/java/trunk/classlib/modules/instrument/src/test/java/org/apache/harmony/tests/java/lang/instrument/InstrumentTest.java Wed Jun 2 10:44:52 2010 @@ -205,4 +205,16 @@ public class InstrumentTest extends Test String result = Support_Exec.execJava(arg, path, true); assertEquals("", result); } + + /** + * @tests test manifest Boot-Class-Path property is treated + * correctly + */ + public void test_boot_class_path() throws Exception { + String[] arg = new String[2]; + arg[0] = "-javaagent:resources/jars/org/apache/harmony/tests/instrument/BCPTest.jar"; + arg[1] = "org/apache/harmony/tests/java/lang/instrument/TestMain"; + String result = Support_Exec.execJava(arg, null, true); + assertEquals("Hello World", result.trim()); + } } Added: harmony/enhanced/java/trunk/classlib/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/BCP.jar URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/BCP.jar?rev=950482&view=auto ============================================================================== Binary file - no diff available. Propchange: harmony/enhanced/java/trunk/classlib/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/BCP.jar ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: harmony/enhanced/java/trunk/classlib/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/BCPTest.jar URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/BCPTest.jar?rev=950482&view=auto ============================================================================== Binary file - no diff available. Propchange: harmony/enhanced/java/trunk/classlib/modules/instrument/src/test/resources/jars/org/apache/harmony/tests/instrument/BCPTest.jar ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream