changeset 5295:b98ebb94940c

8009857: Problem with plugin Reviewed-by: jdn, mchung
author smarks
date Mon, 18 Mar 2013 18:05:31 -0700
parents 50e9123bc958
children 010dc791dc14
files src/share/classes/sun/reflect/misc/MethodUtil.java
diffstat 1 files changed, 25 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/reflect/misc/MethodUtil.java	Sat Mar 16 10:08:14 2013 -0400
+++ b/src/share/classes/sun/reflect/misc/MethodUtil.java	Mon Mar 18 18:05:31 2013 -0700
@@ -50,8 +50,28 @@
 
 
 class Trampoline {
+    static {
+        if (Trampoline.class.getClassLoader() == null) {
+            throw new Error(
+                "Trampoline must not be defined by the bootstrap classloader");
+        }
+    }
+
+    private static void ensureInvocableMethod(Method m)
+        throws InvocationTargetException
+    {
+        Class<?> clazz = m.getDeclaringClass();
+        if (clazz.equals(AccessController.class) ||
+            clazz.equals(Method.class) ||
+            clazz.getName().startsWith("java.lang.invoke."))
+            throw new InvocationTargetException(
+                new UnsupportedOperationException("invocation not supported"));
+    }
+
     private static Object invoke(Method m, Object obj, Object[] params)
-        throws InvocationTargetException, IllegalAccessException {
+        throws InvocationTargetException, IllegalAccessException
+    {
+        ensureInvocableMethod(m);
         return m.invoke(obj, params);
     }
 }
@@ -255,16 +275,6 @@
      */
     public static Object invoke(Method m, Object obj, Object[] params)
         throws InvocationTargetException, IllegalAccessException {
-        if (m.getDeclaringClass().equals(AccessController.class) ||
-           (m.getDeclaringClass().equals(java.lang.invoke.MethodHandles.class)
-            && m.getName().equals("lookup")) ||
-           (m.getDeclaringClass().equals(java.lang.invoke.MethodHandles.Lookup.class)
-            && (m.getName().startsWith("find") ||
-                m.getName().startsWith("bind") ||
-                m.getName().startsWith("unreflect"))) ||
-            m.getDeclaringClass().equals(Method.class))
-            throw new InvocationTargetException(
-                new UnsupportedOperationException("invocation not supported"));
         try {
             return bounce.invoke(null, new Object[] {m, obj, params});
         } catch (InvocationTargetException ie) {
@@ -297,10 +307,10 @@
                             Method.class, Object.class, Object[].class
                         };
                         Method b = t.getDeclaredMethod("invoke", types);
-                    ((AccessibleObject)b).setAccessible(true);
-                    return b;
-                }
-            });
+                        b.setAccessible(true);
+                        return b;
+                    }
+                });
         } catch (Exception e) {
             throw new InternalError("bouncer cannot be found");
         }