harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r449631 - /incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/vm/JarRunner.java
Date Mon, 25 Sep 2006 10:16:58 GMT
Author: geirm
Date: Mon Sep 25 03:16:58 2006
New Revision: 449631

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

Fix to JarRunner - jar has already been placed on classpath, and what I had there
was all wrong as I didn't let it do proper delegatoin.  Result was messes like shown
in the JIRA.

Thanks to Alexey Petrenko for the hint.




Modified:
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/vm/JarRunner.java

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/vm/JarRunner.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/vm/JarRunner.java?view=diff&rev=449631&r1=449630&r2=449631
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/vm/JarRunner.java
(original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/vm/JarRunner.java
Mon Sep 25 03:16:58 2006
@@ -21,9 +21,6 @@
 
 import java.lang.reflect.Method;
 
-import java.net.URLClassLoader;
-import java.net.URL;
-
 /**
  *  Small class to launch jars.  Used by VM for the 
  *   "java -jar foo.jar" use case.
@@ -64,19 +61,13 @@
         }
         
         /*
-         *  now suck the jar in via a classloader, and try to invoke main
-         *  on the mainclass
+         *  load class, copy the args (skipping the first that is the jarname)
+         *  and try to invoke main on the mainclass
          */
         
-        URL[] loaderArgs = {  new URL("jar:file:"+jarName + "!/") };
-
-        MyLoader urlLoader = new MyLoader(loaderArgs);
-        Class mainClass = urlLoader.findClass(className);        
+        Class mainClass = Thread.currentThread().getContextClassLoader().loadClass(className);
              
         Method mainMethod = mainClass.getMethod("main", args.getClass());
-        
-        /*
-         *  copy the args, skipping the first which is the jarname
-         */
+
         String newArgs[] = new String[args.length - 1];
         
         for (int i=1; i < args.length; i++) {
@@ -84,16 +75,5 @@
         }
             
         mainMethod.invoke(null, (java.lang.Object) newArgs);
-    }
-    
-    static class MyLoader extends URLClassLoader { 
-        
-        MyLoader(URL[] urls) {
-            super(urls);
-        }
-        
-        public Class findClass(String name) throws ClassNotFoundException { 
-            return super.findClass(name);
-        }
     }
 }



Mime
View raw message