harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gshiman...@apache.org
Subject svn commit: r591009 - /harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/lang/reflect/support/AuxiliaryLoader.java
Date Thu, 01 Nov 2007 13:55:55 GMT
Author: gshimansky
Date: Thu Nov  1 06:55:54 2007
New Revision: 591009

URL: http://svn.apache.org/viewvc?rev=591009&view=rev
Log:
Applied formatting patch from HARMONY-5005
[drlvm][kernel][geronimo] Field.getGenericType() fails on a parametrized class from custom
classloader


Modified:
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/lang/reflect/support/AuxiliaryLoader.java

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/lang/reflect/support/AuxiliaryLoader.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/lang/reflect/support/AuxiliaryLoader.java?rev=591009&r1=591008&r2=591009&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/lang/reflect/support/AuxiliaryLoader.java
(original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/org/apache/harmony/lang/reflect/support/AuxiliaryLoader.java
Thu Nov  1 06:55:54 2007
@@ -54,71 +54,72 @@
             return void.class;
         }
         ClassLoader cl = this.getClass().getClassLoader();
+
         if (cl == null) {
             cl = ClassLoader.getSystemClassLoader();
         }
+
         try {
             return cl.loadClass(classTypeName);
-        } catch (Throwable _) {
-            Class c = (Class) AccessController
-                    .doPrivileged(new java.security.PrivilegedAction<Object>() {
-                        public Object run() {
-                            // based on an empiric knowledge
-                            ClassLoader cl = ClassLoader.getSystemClassLoader();
-                            try {
-                                java.lang.reflect.Method[] ms = cl.getClass()
-                                        .getDeclaredMethods();
-                                int i = 0;
-                                for (; i < ms.length; i++) {
-                                    if (ms[i].getName().equals("loadClass")
-                                            && ms[i].getParameterTypes().length ==
2
-                                            && ms[i].getParameterTypes()[0]
-                                                    .getName().equals(
-                                                            "java.lang.String")
-                                            && ms[i].getParameterTypes()[1]
-                                                    .getName()
-                                                    .equals("boolean")) {
-                                        break;
-                                    }
-                                }
-                                ms[i].setAccessible(true);
-                                return (Object) ms[i]
-                                        .invoke(
-                                                (Object) cl,
-                                                new Object[] {
-                                                        (Object) AuxiliaryFinder
-                                                                .transform(classTypeName),
-                                                        new Boolean(false) });
-                            } catch (java.lang.IllegalAccessException e) {
-                                System.err
-                                        .println("Error: AuxiliaryLoader.findClass("
-                                                + classTypeName
-                                                + "): "
-                                                + e.toString());
-                                e.printStackTrace();
-                            } catch (java.lang.reflect.InvocationTargetException e) {
-                                System.err
-                                        .println("Error: AuxiliaryLoader.findClass("
-                                                + classTypeName
-                                                + "): "
-                                                + e.getTargetException()
-                                                        .toString());
-                                e.getTargetException().printStackTrace();
-                            } catch (Exception e) {
-                                System.err
-                                        .println("Error: AuxiliaryLoader.findClass("
-                                                + classTypeName
-                                                + "): "
-                                                + e.toString());
-                                e.printStackTrace();
-                            }
-                            return null;
+        } catch (Throwable _) {} // ignore
+
+        Class c = (Class) AccessController.doPrivileged(
+                new java.security.PrivilegedAction<Object>() {
+            public Object run() {
+
+                // based on an empiric knowledge
+                ClassLoader cl = ClassLoader.getSystemClassLoader();
+
+                try {
+                    java.lang.reflect.Method[] ms = 
+                            cl.getClass().getDeclaredMethods();
+                    int i = 0;
+
+                    for (; i < ms.length; i++) {
+                        if (!ms[i].getName().equals("loadClass")) {
+                            continue;
                         }
-                    });
-            if (c == null)
-                throw new ClassNotFoundException(classTypeName);
-            return c;
+
+                        if (ms[i].getParameterTypes().length != 2) {
+                            continue;
+                        }
+
+                        if (!ms[i].getParameterTypes()[0].getName().equals(
+                                    "java.lang.String")) {
+                             continue;
+                        }
+
+                        if (!ms[i].getParameterTypes()[1].getName().equals(
+                                    "boolean")) {
+                            continue;
+                        }
+                        break;
+                    }
+                    ms[i].setAccessible(true);
+                    return (Object) ms[i].invoke((Object) cl, new Object[] {
+                            (Object) AuxiliaryFinder.transform(classTypeName),
+                            new Boolean(false) });
+                } catch (java.lang.IllegalAccessException e) {
+                    System.err.println("Error: AuxiliaryLoader.findClass(" +
+                            classTypeName + "): " + e.toString());
+                    e.printStackTrace();
+                } catch (java.lang.reflect.InvocationTargetException e) {
+                    System.err.println("Error: AuxiliaryLoader.findClass(" +
+                            classTypeName + "): " + e.getTargetException());
+                    e.getTargetException().printStackTrace();
+                } catch (Exception e) {
+                    System.err.println("Error: AuxiliaryLoader.findClass(" +
+                            classTypeName + "): " + e.toString());
+                    e.printStackTrace();
+                }
+                return null;
+            }
+        });
+
+        if (c == null) {
+            throw new ClassNotFoundException(classTypeName);
         }
+        return c;
     }
 
     public void resolve(final Class c) {



Mime
View raw message