8017260: adjust lookup code in objects.* classes

Fri, 21 Jun 2013 16:55:18 +0530

author
sundar
date
Fri, 21 Jun 2013 16:55:18 +0530
changeset 372
8e03121cc286
parent 370
ac404bf3f8c8
child 373
b4e2bccf9598
child 374
c30beaf3c42a

8017260: adjust lookup code in objects.* classes
Reviewed-by: hannesw, jlaskey

src/jdk/nashorn/internal/objects/Global.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/objects/NativeArguments.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/objects/NativeError.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/objects/NativeStrictArguments.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/objects/PrototypeObject.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/jdk/nashorn/internal/objects/Global.java	Thu Jun 20 13:45:38 2013 +0530
     1.2 +++ b/src/jdk/nashorn/internal/objects/Global.java	Fri Jun 21 16:55:18 2013 +0530
     1.3 @@ -25,9 +25,9 @@
     1.4  
     1.5  package jdk.nashorn.internal.objects;
     1.6  
     1.7 +import static jdk.nashorn.internal.lookup.Lookup.MH;
     1.8  import static jdk.nashorn.internal.runtime.ECMAErrors.typeError;
     1.9  import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED;
    1.10 -import static jdk.nashorn.internal.lookup.Lookup.MH;
    1.11  
    1.12  import java.io.IOException;
    1.13  import java.io.PrintWriter;
    1.14 @@ -43,6 +43,7 @@
    1.15  import java.util.Map;
    1.16  import jdk.internal.dynalink.linker.GuardedInvocation;
    1.17  import jdk.internal.dynalink.linker.LinkRequest;
    1.18 +import jdk.nashorn.internal.lookup.MethodHandleFactory;
    1.19  import jdk.nashorn.internal.objects.annotations.Attribute;
    1.20  import jdk.nashorn.internal.objects.annotations.Property;
    1.21  import jdk.nashorn.internal.objects.annotations.ScriptClass;
    1.22 @@ -1780,7 +1781,11 @@
    1.23  
    1.24  
    1.25      private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) {
    1.26 -        return MH.findStatic(MethodHandles.publicLookup(), Global.class, name, MH.type(rtype, types));
    1.27 +        try {
    1.28 +            return MethodHandles.lookup().findStatic(Global.class, name, MH.type(rtype, types));
    1.29 +        } catch (final NoSuchMethodException | IllegalAccessException e) {
    1.30 +            throw new MethodHandleFactory.LookupException(e);
    1.31 +        }
    1.32      }
    1.33  
    1.34      RegExpResult getLastRegExpResult() {
     2.1 --- a/src/jdk/nashorn/internal/objects/NativeArguments.java	Thu Jun 20 13:45:38 2013 +0530
     2.2 +++ b/src/jdk/nashorn/internal/objects/NativeArguments.java	Fri Jun 21 16:55:18 2013 +0530
     2.3 @@ -25,9 +25,9 @@
     2.4  
     2.5  package jdk.nashorn.internal.objects;
     2.6  
     2.7 +import static jdk.nashorn.internal.lookup.Lookup.MH;
     2.8  import static jdk.nashorn.internal.runtime.ECMAErrors.typeError;
     2.9  import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED;
    2.10 -import static jdk.nashorn.internal.lookup.Lookup.MH;
    2.11  
    2.12  import java.lang.invoke.MethodHandle;
    2.13  import java.lang.invoke.MethodHandles;
    2.14 @@ -42,6 +42,7 @@
    2.15  import jdk.nashorn.internal.runtime.arrays.ArrayData;
    2.16  import jdk.nashorn.internal.runtime.arrays.ArrayIndex;
    2.17  import jdk.nashorn.internal.lookup.Lookup;
    2.18 +import jdk.nashorn.internal.lookup.MethodHandleFactory;
    2.19  
    2.20  /**
    2.21   * ECMA 10.6 Arguments Object.
    2.22 @@ -624,7 +625,11 @@
    2.23      }
    2.24  
    2.25      private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) {
    2.26 -        return MH.findStatic(MethodHandles.publicLookup(), NativeArguments.class, name, MH.type(rtype, types));
    2.27 +        try {
    2.28 +            return MethodHandles.lookup().findStatic(NativeArguments.class, name, MH.type(rtype, types));
    2.29 +        } catch (final NoSuchMethodException | IllegalAccessException e) {
    2.30 +            throw new MethodHandleFactory.LookupException(e);
    2.31 +        }
    2.32      }
    2.33  
    2.34  }
     3.1 --- a/src/jdk/nashorn/internal/objects/NativeError.java	Thu Jun 20 13:45:38 2013 +0530
     3.2 +++ b/src/jdk/nashorn/internal/objects/NativeError.java	Fri Jun 21 16:55:18 2013 +0530
     3.3 @@ -33,6 +33,7 @@
     3.4  import java.util.ArrayList;
     3.5  import java.util.List;
     3.6  import jdk.nashorn.internal.codegen.CompilerConstants;
     3.7 +import jdk.nashorn.internal.lookup.MethodHandleFactory;
     3.8  import jdk.nashorn.internal.objects.annotations.Attribute;
     3.9  import jdk.nashorn.internal.objects.annotations.Constructor;
    3.10  import jdk.nashorn.internal.objects.annotations.Function;
    3.11 @@ -328,6 +329,10 @@
    3.12      }
    3.13  
    3.14      private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) {
    3.15 -        return MH.findStatic(MethodHandles.publicLookup(), NativeError.class, name, MH.type(rtype, types));
    3.16 +        try {
    3.17 +            return MethodHandles.lookup().findStatic(NativeError.class, name, MH.type(rtype, types));
    3.18 +        } catch (final NoSuchMethodException | IllegalAccessException e) {
    3.19 +            throw new MethodHandleFactory.LookupException(e);
    3.20 +        }
    3.21      }
    3.22  }
     4.1 --- a/src/jdk/nashorn/internal/objects/NativeStrictArguments.java	Thu Jun 20 13:45:38 2013 +0530
     4.2 +++ b/src/jdk/nashorn/internal/objects/NativeStrictArguments.java	Fri Jun 21 16:55:18 2013 +0530
     4.3 @@ -37,6 +37,7 @@
     4.4  import jdk.nashorn.internal.runtime.ScriptObject;
     4.5  import jdk.nashorn.internal.runtime.arrays.ArrayData;
     4.6  import jdk.nashorn.internal.lookup.Lookup;
     4.7 +import jdk.nashorn.internal.lookup.MethodHandleFactory;
     4.8  
     4.9  /**
    4.10   * ECMA 10.6 Arguments Object.
    4.11 @@ -142,6 +143,10 @@
    4.12      }
    4.13  
    4.14      private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) {
    4.15 -        return MH.findStatic(MethodHandles.publicLookup(), NativeStrictArguments.class, name, MH.type(rtype, types));
    4.16 +        try {
    4.17 +            return MethodHandles.lookup().findStatic(NativeStrictArguments.class, name, MH.type(rtype, types));
    4.18 +        } catch (final NoSuchMethodException | IllegalAccessException e) {
    4.19 +            throw new MethodHandleFactory.LookupException(e);
    4.20 +        }
    4.21      }
    4.22  }
     5.1 --- a/src/jdk/nashorn/internal/objects/PrototypeObject.java	Thu Jun 20 13:45:38 2013 +0530
     5.2 +++ b/src/jdk/nashorn/internal/objects/PrototypeObject.java	Fri Jun 21 16:55:18 2013 +0530
     5.3 @@ -35,6 +35,7 @@
     5.4  import jdk.nashorn.internal.runtime.ScriptFunction;
     5.5  import jdk.nashorn.internal.runtime.ScriptObject;
     5.6  import jdk.nashorn.internal.lookup.Lookup;
     5.7 +import jdk.nashorn.internal.lookup.MethodHandleFactory;
     5.8  
     5.9  /**
    5.10   * Instances of this class serve as "prototype" object for script functions.
    5.11 @@ -106,6 +107,10 @@
    5.12      }
    5.13  
    5.14      private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) {
    5.15 -        return MH.findStatic(MethodHandles.publicLookup(), PrototypeObject.class, name, MH.type(rtype, types));
    5.16 +        try {
    5.17 +            return MethodHandles.lookup().findStatic(PrototypeObject.class, name, MH.type(rtype, types));
    5.18 +        } catch (final NoSuchMethodException | IllegalAccessException e) {
    5.19 +            throw new MethodHandleFactory.LookupException(e);
    5.20 +        }
    5.21      }
    5.22  }

mercurial