You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ge...@apache.org on 2006/10/07 20:12:25 UTC

svn commit: r453976 - in /incubator/harmony/enhanced/drlvm/trunk: build/make/deploy.xml vm/vmcore/src/class_support/classloader.cpp vm/vmcore/src/init/parse_arguments.cpp vm/vmcore/src/init/properties.cpp

Author: geirm
Date: Sat Oct  7 11:12:25 2006
New Revision: 453976

URL: http://svn.apache.org/viewvc?view=rev&rev=453976
Log:
HARMONY-1626

This combines ideas from both patches.  Upshot : 

- delay setting up boot.class.path until boot classloader
  so we can use what luni sets for us anyway
- have any bootclasspath commandlines dealt with then
  as well
- depend on the kernel.jar being in bin/default with the
  rest of drlvm, to make it cleaner to deploy multiple
  versions

Ubuntu 6 - passes smoke, c-unit, ~kernel


Modified:
    incubator/harmony/enhanced/drlvm/trunk/build/make/deploy.xml
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/parse_arguments.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/properties.cpp

Modified: incubator/harmony/enhanced/drlvm/trunk/build/make/deploy.xml
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/build/make/deploy.xml?view=diff&rev=453976&r1=453975&r2=453976
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/build/make/deploy.xml (original)
+++ incubator/harmony/enhanced/drlvm/trunk/build/make/deploy.xml Sat Oct  7 11:12:25 2006
@@ -55,7 +55,7 @@
         </vmi>
 
         <kernel_classes>
-            <jar>lib/boot:kernel</jar>
+            <jar>bin/default:kernel</jar>
         </kernel_classes>
 
         <hythr>

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp?view=diff&rev=453976&r1=453975&r2=453976
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/classloader.cpp Sat Oct  7 11:12:25 2006
@@ -43,6 +43,7 @@
 #include "open/vm_util.h"
 #include "suspend_checker.h"
 #include "verifier.h"
+#include "classpath_const.h"
 
 #include "port_filepath.h"
 #include <apr_file_io.h>
@@ -1542,6 +1543,7 @@
     // separate natives libraries
     const char separator[2] = {PORT_PATH_SEPARATOR, 0};
     char *lib_name = strtok( libraries, separator );
+
     while( lib_name != NULL )
     {
         // load native library
@@ -1551,13 +1553,102 @@
         lib_name = strtok( NULL, separator );
     }
 
+    /*
+     *  at this point, LUNI is loaded, so we can use the boot classpath
+     *  generated there to set vm.boot.class.path since we didn't do
+     *  it before.  We need  to add on the kernel.jar
+     *  note that parse_arguments.cpp defers any override, postpend or 
+     *  preprend here, storing everything as properties.
+     */
+     
+    /*
+     * start with the boot classpath. If overridden, just use that as the basis
+     * and otherwise, contstruct from o.a.h.b.c.p + o.a.h.vm.vmdir to add 
+     * the kernel
+     */
+     
+    PropertiesHandle hProps = reinterpret_cast<PropertiesHandle>(&m_env->properties);
+     
+    /* strdup so that it's freeable w/o extra logic */
+
+    const char *temp = properties_get_string_property(hProps, XBOOTCLASSPATH);    
+    char *bcp_value = (temp ? strdup(temp) : NULL);
+    
+    if (bcp_value == NULL) { 
+        
+        /* not overridden, so lets build, adding the kernel to what luni made for us */
+        
+        const char *kernel_dir_path = properties_get_string_property(hProps, O_A_H_VM_VMDIR);
+    
+        char *kernel_path = (char *) malloc(strlen(kernel_dir_path) 
+                                        + strlen(PORT_FILE_SEPARATOR_STR) 
+                                        + strlen(KERNEL_JAR) + 1);
+    
+        strcpy(kernel_path, kernel_dir_path);
+        strcat(kernel_path, PORT_FILE_SEPARATOR_STR);
+        strcat(kernel_path, KERNEL_JAR);
+        
+        const char *luni_path = properties_get_string_property(hProps,O_A_H_BOOT_CLASS_PATH);
+        
+        char *vmboot = (char *) malloc(strlen(luni_path) + strlen(kernel_path) + strlen(PORT_PATH_SEPARATOR_STR) + 1);
+        
+        strcpy(vmboot, kernel_path);
+        strcat(vmboot, PORT_PATH_SEPARATOR_STR);
+        strcat(vmboot, luni_path);
+
+        free(kernel_path);
+        bcp_value = vmboot;
+    }
+    
+    /*
+     *  now if there a pre or post bootclasspath, add those
+     */
+     
+    const char *prepend = properties_get_string_property(hProps, XBOOTCLASSPATH_P);
+    const char *append = properties_get_string_property(hProps, XBOOTCLASSPATH_A);
+    
+    if (prepend || append) {
+        
+        char *temp = (char *) malloc(strlen(bcp_value) 
+                                    + (prepend ? strlen(prepend) + strlen(PORT_PATH_SEPARATOR_STR) : 0 )
+                                    + (append  ? strlen(append) + strlen(PORT_PATH_SEPARATOR_STR) : 0 ) + 1);
+       
+       if (prepend) { 
+            strcpy(temp, prepend);
+            strcat(temp, PORT_PATH_SEPARATOR_STR);
+            strcat(temp, bcp_value);
+       }
+       else {
+            strcpy(temp, bcp_value);
+       }
+       
+       if (append) {
+            strcat(temp, PORT_PATH_SEPARATOR_STR);
+            strcat(temp, append);
+       }
+       
+       free(bcp_value);
+       bcp_value = temp;
+    }
+    
+    /*
+     *  set VM_BOOT_CLASS_PATH and SUN_BOOT_CLASS_PATH for any code 
+     *  that needs it
+     */
+     
+    add_pair_to_properties(m_env->properties, VM_BOOT_CLASS_PATH, bcp_value);
+    add_pair_to_properties(m_env->properties, SUN_BOOT_CLASS_PATH, bcp_value);
+    
+    free(bcp_value);
+    
     // create temp pool for apr functions
     apr_pool_t *tmp_pool;
     apr_pool_create(&tmp_pool, NULL);
 
     // create a bootclasspath collection
-    SetClasspathFromProperty("vm.boot.class.path", tmp_pool);
 
+    SetClasspathFromProperty(VM_BOOT_CLASS_PATH, tmp_pool);
+        
     // check if vm.bootclasspath.appendclasspath property is set to true
     Boolean is_enabled =
         vm_get_boolean_property_value_with_default("vm.bootclasspath.appendclasspath");

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/parse_arguments.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/parse_arguments.cpp?view=diff&rev=453976&r1=453975&r2=453976
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/parse_arguments.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/parse_arguments.cpp Sat Oct  7 11:12:25 2006
@@ -45,6 +45,8 @@
 #include "nogc.h"
 #include "version.h"
 
+#include "classpath_const.h"
+
 // Multiple-JIT support.
 #include "jit_intf.h"
 #include "dll_jit_intf.h"
@@ -169,24 +171,83 @@
     for (int i = 0; i < p_env->vm_arguments.nOptions; i++) {
         const char* option = p_env->vm_arguments.options[i].optionString;
 
-        if (begins_with(option, "-Xbootclasspath:")) {
-            // replace boot class path by argument
-            add_pair_to_properties(p_env->properties, "vm.boot.class.path", option + 16); 
-            add_pair_to_properties(p_env->properties, "sun.boot.class.path", option + 16); 
-        } else if (begins_with(option, "-Xbootclasspath/a:")) {
-            // append argument to boot class path 
-            char *bcp_old = (char *)properties_get_string_property((PropertiesHandle)&p_env->properties, "vm.boot.class.path");
-            assert(bcp_old);
-            char *bcp_new = apr_pstrcat(pool, bcp_old, PORT_PATH_SEPARATOR_STR, option + 18, NULL);
-            add_pair_to_properties(p_env->properties, "vm.boot.class.path", bcp_new);
-            add_pair_to_properties(p_env->properties, "sun.boot.class.path", bcp_new);
-        } else if (begins_with(option, "-Xbootclasspath/p:")) {
-            // prepend argument to boot class path
-            char *bcp_old = (char*)properties_get_string_property((PropertiesHandle)&p_env->properties, "vm.boot.class.path");
-            assert(bcp_old);
-            char *bcp_new = apr_pstrcat(pool, option + 18, PORT_PATH_SEPARATOR_STR, bcp_old, NULL);
-            add_pair_to_properties(p_env->properties, "vm.boot.class.path", bcp_new);
-            add_pair_to_properties(p_env->properties, "sun.boot.class.path", bcp_new);
+        if (begins_with(option,"-Dorg.apache.harmony.vm.vmdir=")) {
+            
+            /*
+             *  This is the directory where the virtual machine artifacts are located
+             *  (vm.dll, etc) including the kernel.jar  GEIR
+             */
+            add_pair_to_properties(p_env->properties, "org.apache.harmony.vm.vmdir", 
+                        option + strlen("-Dorg.apache.harmony.vm.vmdir="));
+        }
+        else if (begins_with(option, XBOOTCLASSPATH)) {
+            /*
+             *  Override for bootclasspath - 
+             *  set in the environment- the boot classloader will be responsible for 
+             *  processing and setting up "vm.boot.class.path" and "sun.boot.class.path"
+             *  Note that in the case of multiple arguments, the last one will be used
+             */
+            add_pair_to_properties(p_env->properties, XBOOTCLASSPATH, option + strlen(XBOOTCLASSPATH));
+        }
+        else if (begins_with(option, XBOOTCLASSPATH_A)) {
+            /*
+             *  addition to append to boot classpath
+             *  set in environment - responsibility of boot classloader to process
+             *  Note that we accumulate if multiple, appending each time
+             */
+
+            const char *bcp_old = properties_get_string_property((PropertiesHandle)&p_env->properties, 
+                                XBOOTCLASSPATH_A);
+            const char *value = option + strlen(XBOOTCLASSPATH_A);
+            
+            char *bcp_new = NULL;
+            
+            if (bcp_old) { 
+                 char *tmp = (char *) malloc(strlen(bcp_old) + strlen(PORT_PATH_SEPARATOR_STR)
+                                                        + strlen(value) + 1);
+            
+                 strcpy(tmp, bcp_old);
+                 strcat(tmp, PORT_PATH_SEPARATOR_STR);
+                 strcat(tmp, value);
+                 
+                 bcp_new = tmp;
+            }
+            
+            add_pair_to_properties(p_env->properties, XBOOTCLASSPATH_A, bcp_old ? bcp_new : value); 
+                        
+            if (bcp_new) {
+                free(bcp_new);
+            }                       
+        }
+        else if (begins_with(option, XBOOTCLASSPATH_P)) {
+            /*
+             *  addition to prepend to boot classpath
+             *  set in environment - responsibility of boot classloader to process
+             *  Note that we accumulate if multiple, prepending each time
+             */
+             
+            const char *bcp_old = properties_get_string_property((PropertiesHandle)&p_env->properties, 
+                                XBOOTCLASSPATH_P);
+            const char *value = option + strlen(XBOOTCLASSPATH_P);
+            
+            char *bcp_new = NULL;
+            
+            if (bcp_old) { 
+                 char *tmp = (char *) malloc(strlen(bcp_old) + strlen(PORT_PATH_SEPARATOR_STR)
+                                                        + strlen(value) + 1);
+            
+                 strcpy(tmp, value);
+                 strcat(tmp, PORT_PATH_SEPARATOR_STR);
+                 strcat(tmp, bcp_old);
+                 
+                 bcp_new = tmp;
+            }
+            
+            add_pair_to_properties(p_env->properties, XBOOTCLASSPATH_P, bcp_old ? bcp_new : value); 
+            
+            if (bcp_new) {
+                free(bcp_new);
+            }                       
         } else if (begins_with(option, "-Xhelp:")) {
             const char* arg = option + strlen("-Xhelp:");
 

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/properties.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/properties.cpp?view=diff&rev=453976&r1=453975&r2=453976
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/properties.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/properties.cpp Sat Oct  7 11:12:25 2006
@@ -37,7 +37,6 @@
 #define PROP_FILE_NAME "vm.properties"
 #define BOOT_PROPS_FILE_NAME "bootclasspath.properties"
 #define BOOTCLASSPATH_PROP_NAME "bootclasspath"
-#define BOOTCLASSPATH_KERNEL_JAR "kernel.jar"
 
 #define MAX_PROP_LINE 5120
 
@@ -130,8 +129,8 @@
     "java.specification.vendor=Sun Microsystems Inc.",
     "java.specification.name=Java Platform API Specification",
     "java.version=11.2.0",
-    "java.vendor=Intel DRL",
-    "java.vm.vendor=Intel DRL",
+    "java.vendor=Apache Software Foundation",
+    "java.vm.vendor=Apache Software Foundation",
     "java.vm.version=11.2.0",
     "java.vm.name=DRLVM",
     "java.vm.info=no info",
@@ -189,84 +188,6 @@
     return full_name;
 }
 
-int str_compare(const void *arg1, const void *arg2) {
-    char *string1 = *(char**)arg1;
-    char *string2 = *(char**)arg2;
-    if (strlen(string1) < strlen(string2))
-        return -1;
-    if (strlen(string2) < strlen(string1))
-        return 1;
-    return strcmp(string1, string2);
-}
-
-static char *load_full_api_files_path_names_list(const char *path)
-{
-    char *full_name = "";
-    int array_size = 30;
-    char **props = (char**)STD_MALLOC(array_size*sizeof(char*));
-    char *jre_file_path = apr_pstrcat(prop_pool, path, PORT_FILE_SEPARATOR_STR BOOT_PROPS_FILE_NAME, NULL);
-    apr_file_t *f_jre;
-    if (APR_SUCCESS == apr_file_open(&f_jre, jre_file_path, APR_FOPEN_READ, 0, prop_pool))
-    {
-        char jre_file_name[MAX_PROP_LINE];
-        int props_count = 0;
-        while (!apr_file_eof(f_jre) && !apr_file_gets(jre_file_name, MAX_PROP_LINE, f_jre)) {
-	        if ((jre_file_name[0] != 0x0D || jre_file_name[0] != 0x0A)
-				&& !strncmp(jre_file_name ,BOOTCLASSPATH_PROP_NAME, strlen(BOOTCLASSPATH_PROP_NAME))) {
-                char *char_pos = jre_file_name + strlen(BOOTCLASSPATH_PROP_NAME);
-                // Check that there are digits after dots so only bootclasspath
-                // elements appear in the property
-                if (char_pos[0] != '.' || char_pos[1] < '0' || char_pos[1] > '9')
-                    continue;
-                
-                if(props_count == array_size) {
-                    array_size *= 2;
-                    props = (char**)STD_REALLOC(props, array_size*sizeof(char*));
-                }
-                unsigned length;
-                char_pos = strchr(jre_file_name, 0x0D);
-                if (!char_pos) {
-                    char_pos = strchr(jre_file_name, 0x0A);
-                }
-                if (char_pos) {
-                    *char_pos = '\0';
-                    length = char_pos - jre_file_name + 1;
-                } else {
-                    length = strlen(jre_file_name) + 1;
-                }
-                char_pos = strchr(jre_file_name, '=');
-                if (!char_pos) {
-                    DIE("Malformed bootclasspath entry: " << jre_file_name);
-                }
-                *char_pos = '\0';
-                props[props_count] = (char*)STD_MALLOC(length * sizeof(char));
-                memcpy(props[props_count], jre_file_name, length);
-                props_count++;
-            }
-	    }
-    
-		qsort(props, props_count, sizeof(char*), str_compare);
-        
-        full_name = apr_pstrcat(prop_pool, path, PORT_FILE_SEPARATOR_STR,
-            BOOTCLASSPATH_KERNEL_JAR, NULL);
-            
-        TRACE2("init", "kernel jar path : " << full_name);
-        
-        for(int i = 0; i < props_count; i++){
-            full_name = apr_pstrcat(prop_pool, full_name, PORT_PATH_SEPARATOR_STR,
-                path, PORT_FILE_SEPARATOR_STR, props[i] + strlen(props[i]) + 1, NULL);
-            STD_FREE(props[i]);
-        }
-        STD_FREE(props);
-        apr_file_close(f_jre);
-    }
-    else
-    {
-        DIE("Can't find file : " << jre_file_path);
-    }
-	return full_name;
-}
-
 
 void post_initialize_ee_dlls(PropertiesHandle ph) {
     if (!prop_pool) {
@@ -409,19 +330,6 @@
     add_pair_to_properties(properties, "java.ext.dirs", ext_path);
     TRACE( "java.ext.dirs = " << ext_path);
 
-    // vm.boot.class.path initialization. Value is
-    // java.home PATH_SEPARATOR lib PATH_SEPARATOR API_CLASSES_ARCHIVE
-    // where API_CLASSES_ARCHIVE is defined in this file
-    char *boot_path = port_filepath_merge(base_path_buf, "lib" PORT_FILE_SEPARATOR_STR "boot", prop_pool);
-	
-    path_buf = load_full_api_files_path_names_list(boot_path);
-    add_pair_to_properties(properties, "vm.boot.class.path", path_buf);
-    TRACE( "vm.boot.class.path = " << path_buf);
-
-    // Added for compatibility with a reference JDWP agent
-    add_pair_to_properties(properties, "sun.boot.class.path", path_buf);
-    TRACE( "sun.boot.class.path = " << path_buf);
-
     // user.name initialization, try to get the name from the system
     char *user_buf;
     apr_status_t status = port_user_name(&user_buf, prop_pool);
@@ -480,6 +388,8 @@
  * gregory -
  * 0. Add predefined properties from property table
  */
+     
+
     define_undefined_predefined_properties(p_env->properties);
 
     char **pp = predefined_propeties;