44 import jdk.nashorn.internal.codegen.RuntimeCallSite; 45 import jdk.nashorn.internal.runtime.JSType; 46 import jdk.nashorn.internal.runtime.ScriptFunction; 47 import jdk.nashorn.internal.runtime.ScriptRuntime; 48 import jdk.nashorn.internal.runtime.options.Options; 49 50 /** 51 * This class houses bootstrap method for invokedynamic instructions generated by compiler. 52 */ 53 public final class Bootstrap { 54 /** Reference to the seed boostrap function */ 55 public static final Call BOOTSTRAP = staticCallNoLookup(Bootstrap.class, "bootstrap", CallSite.class, Lookup.class, String.class, MethodType.class, int.class); 56 57 // do not create me!! 58 private Bootstrap() { 59 } 60 61 private static final DynamicLinker dynamicLinker; 62 static { 63 final DynamicLinkerFactory factory = new DynamicLinkerFactory(); 64 factory.setPrioritizedLinkers(new NashornLinker(), new NashornPrimitiveLinker(), new NashornStaticClassLinker(), 65 new BoundDynamicMethodLinker(), new JavaSuperAdapterLinker(), new JSObjectLinker(), new ReflectionCheckLinker()); 66 factory.setFallbackLinkers(new NashornBeansLinker(), new NashornBottomLinker()); 67 factory.setSyncOnRelink(true); 68 final int relinkThreshold = Options.getIntProperty("nashorn.unstable.relink.threshold", -1); 69 if (relinkThreshold > -1) { 70 factory.setUnstableRelinkThreshold(relinkThreshold); 71 } 72 73 // Linkers for any additional language runtimes deployed alongside Nashorn will be picked up by the factory. 74 factory.setClassLoader(Bootstrap.class.getClassLoader()); 75 76 dynamicLinker = factory.createLinker(); 77 } 78 79 /** 80 * Returns if the given object is a "callable" 81 * @param obj object to be checked for callability 82 * @return true if the obj is callable 83 */ 84 public static boolean isCallable(final Object obj) { 85 if (obj == ScriptRuntime.UNDEFINED || obj == null) { 86 return false; | 44 import jdk.nashorn.internal.codegen.RuntimeCallSite; 45 import jdk.nashorn.internal.runtime.JSType; 46 import jdk.nashorn.internal.runtime.ScriptFunction; 47 import jdk.nashorn.internal.runtime.ScriptRuntime; 48 import jdk.nashorn.internal.runtime.options.Options; 49 50 /** 51 * This class houses bootstrap method for invokedynamic instructions generated by compiler. 52 */ 53 public final class Bootstrap { 54 /** Reference to the seed boostrap function */ 55 public static final Call BOOTSTRAP = staticCallNoLookup(Bootstrap.class, "bootstrap", CallSite.class, Lookup.class, String.class, MethodType.class, int.class); 56 57 // do not create me!! 58 private Bootstrap() { 59 } 60 61 private static final DynamicLinker dynamicLinker; 62 static { 63 final DynamicLinkerFactory factory = new DynamicLinkerFactory(); 64 final NashornBeansLinker nashornBeansLinker = new NashornBeansLinker(); 65 final JSObjectLinker jsObjectLinker = new JSObjectLinker(nashornBeansLinker); 66 factory.setPrioritizedLinkers( 67 new NashornLinker(), 68 new NashornPrimitiveLinker(), 69 new NashornStaticClassLinker(), 70 new BoundDynamicMethodLinker(), 71 new JavaSuperAdapterLinker(), 72 jsObjectLinker, 73 new ReflectionCheckLinker()); 74 factory.setFallbackLinkers(nashornBeansLinker, new NashornBottomLinker()); 75 factory.setSyncOnRelink(true); 76 final int relinkThreshold = Options.getIntProperty("nashorn.unstable.relink.threshold", -1); 77 if (relinkThreshold > -1) { 78 factory.setUnstableRelinkThreshold(relinkThreshold); 79 } 80 81 // Linkers for any additional language runtimes deployed alongside Nashorn will be picked up by the factory. 82 factory.setClassLoader(Bootstrap.class.getClassLoader()); 83 84 dynamicLinker = factory.createLinker(); 85 } 86 87 /** 88 * Returns if the given object is a "callable" 89 * @param obj object to be checked for callability 90 * @return true if the obj is callable 91 */ 92 public static boolean isCallable(final Object obj) { 93 if (obj == ScriptRuntime.UNDEFINED || obj == null) { 94 return false; |