8017260: adjust lookup code in objects.* classes
authorsundar
Fri, 21 Jun 2013 16:55:18 +0530
changeset 18610 9a052996a7b7
parent 18608 cb5ba414975f
child 18611 7f9b03afc408
child 18612 14c3175f6ce1
8017260: adjust lookup code in objects.* classes Reviewed-by: hannesw, jlaskey
nashorn/src/jdk/nashorn/internal/objects/Global.java
nashorn/src/jdk/nashorn/internal/objects/NativeArguments.java
nashorn/src/jdk/nashorn/internal/objects/NativeError.java
nashorn/src/jdk/nashorn/internal/objects/NativeStrictArguments.java
nashorn/src/jdk/nashorn/internal/objects/PrototypeObject.java
--- a/nashorn/src/jdk/nashorn/internal/objects/Global.java	Thu Jun 20 13:45:38 2013 +0530
+++ b/nashorn/src/jdk/nashorn/internal/objects/Global.java	Fri Jun 21 16:55:18 2013 +0530
@@ -25,9 +25,9 @@
 
 package jdk.nashorn.internal.objects;
 
+import static jdk.nashorn.internal.lookup.Lookup.MH;
 import static jdk.nashorn.internal.runtime.ECMAErrors.typeError;
 import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED;
-import static jdk.nashorn.internal.lookup.Lookup.MH;
 
 import java.io.IOException;
 import java.io.PrintWriter;
@@ -43,6 +43,7 @@
 import java.util.Map;
 import jdk.internal.dynalink.linker.GuardedInvocation;
 import jdk.internal.dynalink.linker.LinkRequest;
+import jdk.nashorn.internal.lookup.MethodHandleFactory;
 import jdk.nashorn.internal.objects.annotations.Attribute;
 import jdk.nashorn.internal.objects.annotations.Property;
 import jdk.nashorn.internal.objects.annotations.ScriptClass;
@@ -1780,7 +1781,11 @@
 
 
     private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) {
-        return MH.findStatic(MethodHandles.publicLookup(), Global.class, name, MH.type(rtype, types));
+        try {
+            return MethodHandles.lookup().findStatic(Global.class, name, MH.type(rtype, types));
+        } catch (final NoSuchMethodException | IllegalAccessException e) {
+            throw new MethodHandleFactory.LookupException(e);
+        }
     }
 
     RegExpResult getLastRegExpResult() {
--- a/nashorn/src/jdk/nashorn/internal/objects/NativeArguments.java	Thu Jun 20 13:45:38 2013 +0530
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeArguments.java	Fri Jun 21 16:55:18 2013 +0530
@@ -25,9 +25,9 @@
 
 package jdk.nashorn.internal.objects;
 
+import static jdk.nashorn.internal.lookup.Lookup.MH;
 import static jdk.nashorn.internal.runtime.ECMAErrors.typeError;
 import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED;
-import static jdk.nashorn.internal.lookup.Lookup.MH;
 
 import java.lang.invoke.MethodHandle;
 import java.lang.invoke.MethodHandles;
@@ -42,6 +42,7 @@
 import jdk.nashorn.internal.runtime.arrays.ArrayData;
 import jdk.nashorn.internal.runtime.arrays.ArrayIndex;
 import jdk.nashorn.internal.lookup.Lookup;
+import jdk.nashorn.internal.lookup.MethodHandleFactory;
 
 /**
  * ECMA 10.6 Arguments Object.
@@ -624,7 +625,11 @@
     }
 
     private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) {
-        return MH.findStatic(MethodHandles.publicLookup(), NativeArguments.class, name, MH.type(rtype, types));
+        try {
+            return MethodHandles.lookup().findStatic(NativeArguments.class, name, MH.type(rtype, types));
+        } catch (final NoSuchMethodException | IllegalAccessException e) {
+            throw new MethodHandleFactory.LookupException(e);
+        }
     }
 
 }
--- a/nashorn/src/jdk/nashorn/internal/objects/NativeError.java	Thu Jun 20 13:45:38 2013 +0530
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeError.java	Fri Jun 21 16:55:18 2013 +0530
@@ -33,6 +33,7 @@
 import java.util.ArrayList;
 import java.util.List;
 import jdk.nashorn.internal.codegen.CompilerConstants;
+import jdk.nashorn.internal.lookup.MethodHandleFactory;
 import jdk.nashorn.internal.objects.annotations.Attribute;
 import jdk.nashorn.internal.objects.annotations.Constructor;
 import jdk.nashorn.internal.objects.annotations.Function;
@@ -328,6 +329,10 @@
     }
 
     private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) {
-        return MH.findStatic(MethodHandles.publicLookup(), NativeError.class, name, MH.type(rtype, types));
+        try {
+            return MethodHandles.lookup().findStatic(NativeError.class, name, MH.type(rtype, types));
+        } catch (final NoSuchMethodException | IllegalAccessException e) {
+            throw new MethodHandleFactory.LookupException(e);
+        }
     }
 }
--- a/nashorn/src/jdk/nashorn/internal/objects/NativeStrictArguments.java	Thu Jun 20 13:45:38 2013 +0530
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeStrictArguments.java	Fri Jun 21 16:55:18 2013 +0530
@@ -37,6 +37,7 @@
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.runtime.arrays.ArrayData;
 import jdk.nashorn.internal.lookup.Lookup;
+import jdk.nashorn.internal.lookup.MethodHandleFactory;
 
 /**
  * ECMA 10.6 Arguments Object.
@@ -142,6 +143,10 @@
     }
 
     private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) {
-        return MH.findStatic(MethodHandles.publicLookup(), NativeStrictArguments.class, name, MH.type(rtype, types));
+        try {
+            return MethodHandles.lookup().findStatic(NativeStrictArguments.class, name, MH.type(rtype, types));
+        } catch (final NoSuchMethodException | IllegalAccessException e) {
+            throw new MethodHandleFactory.LookupException(e);
+        }
     }
 }
--- a/nashorn/src/jdk/nashorn/internal/objects/PrototypeObject.java	Thu Jun 20 13:45:38 2013 +0530
+++ b/nashorn/src/jdk/nashorn/internal/objects/PrototypeObject.java	Fri Jun 21 16:55:18 2013 +0530
@@ -35,6 +35,7 @@
 import jdk.nashorn.internal.runtime.ScriptFunction;
 import jdk.nashorn.internal.runtime.ScriptObject;
 import jdk.nashorn.internal.lookup.Lookup;
+import jdk.nashorn.internal.lookup.MethodHandleFactory;
 
 /**
  * Instances of this class serve as "prototype" object for script functions.
@@ -106,6 +107,10 @@
     }
 
     private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) {
-        return MH.findStatic(MethodHandles.publicLookup(), PrototypeObject.class, name, MH.type(rtype, types));
+        try {
+            return MethodHandles.lookup().findStatic(PrototypeObject.class, name, MH.type(rtype, types));
+        } catch (final NoSuchMethodException | IllegalAccessException e) {
+            throw new MethodHandleFactory.LookupException(e);
+        }
     }
 }