Java Code Examples for jdk.internal.dynalink.beans.BeansLinker#isDynamicMethod()
The following examples show how to use
jdk.internal.dynalink.beans.BeansLinker#isDynamicMethod() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Bootstrap.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Returns if the given object is a "callable" * @param obj object to be checked for callability * @return true if the obj is callable */ public static boolean isCallable(final Object obj) { if (obj == ScriptRuntime.UNDEFINED || obj == null) { return false; } return obj instanceof ScriptFunction || isJSObjectFunction(obj) || BeansLinker.isDynamicMethod(obj) || obj instanceof BoundCallable || isFunctionalInterfaceObject(obj) || obj instanceof StaticClass; }
Example 2
Source File: Bootstrap.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Returns if the given object is a "callable" * @param obj object to be checked for callability * @return true if the obj is callable */ public static boolean isCallable(final Object obj) { if (obj == ScriptRuntime.UNDEFINED || obj == null) { return false; } return obj instanceof ScriptFunction || isJSObjectFunction(obj) || BeansLinker.isDynamicMethod(obj) || obj instanceof BoundCallable || isFunctionalInterfaceObject(obj) || obj instanceof StaticClass; }
Example 3
Source File: Bootstrap.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Returns true if the given object is a strict callable * @param callable the callable object to be checked for strictness * @return true if the obj is a strict callable, false if it is a non-strict callable. * @throws ECMAException with {@code TypeError} if the object is not a callable. */ public static boolean isStrictCallable(final Object callable) { if (callable instanceof ScriptFunction) { return ((ScriptFunction)callable).isStrict(); } else if (isJSObjectFunction(callable)) { return ((JSObject)callable).isStrictFunction(); } else if (callable instanceof BoundCallable) { return isStrictCallable(((BoundCallable)callable).getCallable()); } else if (BeansLinker.isDynamicMethod(callable) || callable instanceof StaticClass) { return false; } throw notFunction(callable); }
Example 4
Source File: Bootstrap.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Returns true if the given object is a strict callable * @param callable the callable object to be checked for strictness * @return true if the obj is a strict callable, false if it is a non-strict callable. * @throws ECMAException with {@code TypeError} if the object is not a callable. */ public static boolean isStrictCallable(final Object callable) { if (callable instanceof ScriptFunction) { return ((ScriptFunction)callable).isStrict(); } else if (isJSObjectFunction(callable)) { return ((JSObject)callable).isStrictFunction(); } else if (callable instanceof BoundCallable) { return isStrictCallable(((BoundCallable)callable).getCallable()); } else if (BeansLinker.isDynamicMethod(callable) || callable instanceof StaticClass) { return false; } throw notFunction(callable); }
Example 5
Source File: Bootstrap.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Returns if the given object is a "callable" * @param obj object to be checked for callability * @return true if the obj is callable */ public static boolean isCallable(final Object obj) { if (obj == ScriptRuntime.UNDEFINED || obj == null) { return false; } return obj instanceof ScriptFunction || isJSObjectFunction(obj) || BeansLinker.isDynamicMethod(obj) || obj instanceof BoundCallable || isFunctionalInterfaceObject(obj) || obj instanceof StaticClass; }
Example 6
Source File: Bootstrap.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
/** * Returns true if the given object is a strict callable * @param callable the callable object to be checked for strictness * @return true if the obj is a strict callable, false if it is a non-strict callable. * @throws ECMAException with {@code TypeError} if the object is not a callable. */ public static boolean isStrictCallable(final Object callable) { if (callable instanceof ScriptFunction) { return ((ScriptFunction)callable).isStrict(); } else if (isJSObjectFunction(callable)) { return ((JSObject)callable).isStrictFunction(); } else if (callable instanceof BoundCallable) { return isStrictCallable(((BoundCallable)callable).getCallable()); } else if (BeansLinker.isDynamicMethod(callable) || callable instanceof StaticClass || isFunctionalInterfaceObject(callable)) { return false; } throw notFunction(callable); }
Example 7
Source File: Bootstrap.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Returns true if the given object is a strict callable * @param callable the callable object to be checked for strictness * @return true if the obj is a strict callable, false if it is a non-strict callable. * @throws ECMAException with {@code TypeError} if the object is not a callable. */ public static boolean isStrictCallable(final Object callable) { if (callable instanceof ScriptFunction) { return ((ScriptFunction)callable).isStrict(); } else if (isJSObjectFunction(callable)) { return ((JSObject)callable).isStrictFunction(); } else if (callable instanceof BoundCallable) { return isStrictCallable(((BoundCallable)callable).getCallable()); } else if (BeansLinker.isDynamicMethod(callable) || callable instanceof StaticClass || isFunctionalInterfaceObject(callable)) { return false; } throw notFunction(callable); }
Example 8
Source File: Bootstrap.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Returns true if the given object is a strict callable * @param callable the callable object to be checked for strictness * @return true if the obj is a strict callable, false if it is a non-strict callable. * @throws ECMAException with {@code TypeError} if the object is not a callable. */ public static boolean isStrictCallable(final Object callable) { if (callable instanceof ScriptFunction) { return ((ScriptFunction)callable).isStrict(); } else if (isJSObjectFunction(callable)) { return ((JSObject)callable).isStrictFunction(); } else if (callable instanceof BoundCallable) { return isStrictCallable(((BoundCallable)callable).getCallable()); } else if (BeansLinker.isDynamicMethod(callable) || callable instanceof StaticClass || isFunctionalInterfaceObject(callable)) { return false; } throw notFunction(callable); }
Example 9
Source File: NashornBottomLinker.java From nashorn with GNU General Public License v2.0 | 4 votes |
private static GuardedInvocation linkBean(final LinkRequest linkRequest, final LinkerServices linkerServices) throws Exception { final NashornCallSiteDescriptor desc = (NashornCallSiteDescriptor)linkRequest.getCallSiteDescriptor(); final Object self = linkRequest.getReceiver(); final String operator = desc.getFirstOperator(); switch (operator) { case "new": if(BeansLinker.isDynamicMethod(self)) { throw typeError("method.not.constructor", ScriptRuntime.safeToString(self)); } throw typeError("not.a.function", ScriptRuntime.safeToString(self)); case "call": // Support dyn:call on any object that supports some @FunctionalInterface // annotated interface. This way Java method, constructor references or // implementations of java.util.function.* interfaces can be called as though // those are script functions. final Method m = getFunctionalInterfaceMethod(self.getClass()); if (m != null) { final MethodType callType = desc.getMethodType(); // 'callee' and 'thiz' passed from script + actual arguments //if (callType.parameterCount() != m.getParameterCount() + 2) { if (callType.parameterCount() != m.getParameterTypes().length + 2) { throw typeError("no.method.matches.args", ScriptRuntime.safeToString(self)); } return new GuardedInvocation( // drop 'thiz' passed from the script. MH.dropArguments(desc.getLookup().unreflect(m), 1, callType.parameterType(1)), Guards.getInstanceOfGuard(m.getDeclaringClass())).asType(callType); } if(BeansLinker.isDynamicMethod(self)) { throw typeError("no.method.matches.args", ScriptRuntime.safeToString(self)); } throw typeError("not.a.function", ScriptRuntime.safeToString(self)); case "callMethod": case "getMethod": throw typeError("no.such.function", getArgument(linkRequest), ScriptRuntime.safeToString(self)); case "getProp": case "getElem": if (desc.getOperand() != null) { return getInvocation(EMPTY_PROP_GETTER, self, linkerServices, desc); } return getInvocation(EMPTY_ELEM_GETTER, self, linkerServices, desc); case "setProp": case "setElem": if (desc.getOperand() != null) { return getInvocation(EMPTY_PROP_SETTER, self, linkerServices, desc); } return getInvocation(EMPTY_ELEM_SETTER, self, linkerServices, desc); default: break; } throw new AssertionError("unknown call type " + desc); }
Example 10
Source File: NashornBottomLinker.java From hottub with GNU General Public License v2.0 | 4 votes |
private static GuardedInvocation linkBean(final LinkRequest linkRequest, final LinkerServices linkerServices) throws Exception { final NashornCallSiteDescriptor desc = (NashornCallSiteDescriptor)linkRequest.getCallSiteDescriptor(); final Object self = linkRequest.getReceiver(); final String operator = desc.getFirstOperator(); switch (operator) { case "new": if(BeansLinker.isDynamicConstructor(self)) { throw typeError("no.constructor.matches.args", ScriptRuntime.safeToString(self)); } if(BeansLinker.isDynamicMethod(self)) { throw typeError("method.not.constructor", ScriptRuntime.safeToString(self)); } throw typeError("not.a.function", desc.getFunctionErrorMessage(self)); case "call": if(BeansLinker.isDynamicConstructor(self)) { throw typeError("constructor.requires.new", ScriptRuntime.safeToString(self)); } if(BeansLinker.isDynamicMethod(self)) { throw typeError("no.method.matches.args", ScriptRuntime.safeToString(self)); } throw typeError("not.a.function", desc.getFunctionErrorMessage(self)); case "callMethod": throw typeError("no.such.function", getArgument(linkRequest), ScriptRuntime.safeToString(self)); case "getMethod": // evaluate to undefined, later on Undefined will take care of throwing TypeError return getInvocation(MH.dropArguments(GET_UNDEFINED.get(TYPE_OBJECT_INDEX), 0, Object.class), self, linkerServices, desc); case "getProp": case "getElem": if(NashornCallSiteDescriptor.isOptimistic(desc)) { throw new UnwarrantedOptimismException(UNDEFINED, NashornCallSiteDescriptor.getProgramPoint(desc), Type.OBJECT); } if (desc.getOperand() != null) { return getInvocation(EMPTY_PROP_GETTER, self, linkerServices, desc); } return getInvocation(EMPTY_ELEM_GETTER, self, linkerServices, desc); case "setProp": case "setElem": { final boolean strict = NashornCallSiteDescriptor.isStrict(desc); if (strict) { throw typeError("cant.set.property", getArgument(linkRequest), ScriptRuntime.safeToString(self)); } if (desc.getOperand() != null) { return getInvocation(EMPTY_PROP_SETTER, self, linkerServices, desc); } return getInvocation(EMPTY_ELEM_SETTER, self, linkerServices, desc); } default: break; } throw new AssertionError("unknown call type " + desc); }
Example 11
Source File: NashornBottomLinker.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
private static GuardedInvocation linkBean(final LinkRequest linkRequest, final LinkerServices linkerServices) throws Exception { final NashornCallSiteDescriptor desc = (NashornCallSiteDescriptor)linkRequest.getCallSiteDescriptor(); final Object self = linkRequest.getReceiver(); final String operator = desc.getFirstOperator(); switch (operator) { case "new": if(BeansLinker.isDynamicMethod(self)) { throw typeError("method.not.constructor", ScriptRuntime.safeToString(self)); } throw typeError("not.a.function", ScriptRuntime.safeToString(self)); case "call": // Support dyn:call on any object that supports some @FunctionalInterface // annotated interface. This way Java method, constructor references or // implementations of java.util.function.* interfaces can be called as though // those are script functions. final Method m = getFunctionalInterfaceMethod(self.getClass()); if (m != null) { final MethodType callType = desc.getMethodType(); // 'callee' and 'thiz' passed from script + actual arguments if (callType.parameterCount() != m.getParameterCount() + 2) { throw typeError("no.method.matches.args", ScriptRuntime.safeToString(self)); } return new GuardedInvocation( // drop 'thiz' passed from the script. MH.dropArguments(desc.getLookup().unreflect(m), 1, callType.parameterType(1)), Guards.getInstanceOfGuard(m.getDeclaringClass())).asType(callType); } if(BeansLinker.isDynamicMethod(self)) { throw typeError("no.method.matches.args", ScriptRuntime.safeToString(self)); } throw typeError("not.a.function", ScriptRuntime.safeToString(self)); case "callMethod": case "getMethod": throw typeError("no.such.function", getArgument(linkRequest), ScriptRuntime.safeToString(self)); case "getProp": case "getElem": if (desc.getOperand() != null) { return getInvocation(EMPTY_PROP_GETTER, self, linkerServices, desc); } return getInvocation(EMPTY_ELEM_GETTER, self, linkerServices, desc); case "setProp": case "setElem": if (desc.getOperand() != null) { return getInvocation(EMPTY_PROP_SETTER, self, linkerServices, desc); } return getInvocation(EMPTY_ELEM_SETTER, self, linkerServices, desc); default: break; } throw new AssertionError("unknown call type " + desc); }
Example 12
Source File: NashornBottomLinker.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
private static GuardedInvocation linkBean(final LinkRequest linkRequest, final LinkerServices linkerServices) throws Exception { final NashornCallSiteDescriptor desc = (NashornCallSiteDescriptor)linkRequest.getCallSiteDescriptor(); final Object self = linkRequest.getReceiver(); final String operator = desc.getFirstOperator(); switch (operator) { case "new": if(BeansLinker.isDynamicConstructor(self)) { throw typeError("no.constructor.matches.args", ScriptRuntime.safeToString(self)); } if(BeansLinker.isDynamicMethod(self)) { throw typeError("method.not.constructor", ScriptRuntime.safeToString(self)); } throw typeError("not.a.function", desc.getFunctionErrorMessage(self)); case "call": if(BeansLinker.isDynamicConstructor(self)) { throw typeError("constructor.requires.new", ScriptRuntime.safeToString(self)); } if(BeansLinker.isDynamicMethod(self)) { throw typeError("no.method.matches.args", ScriptRuntime.safeToString(self)); } throw typeError("not.a.function", desc.getFunctionErrorMessage(self)); case "callMethod": throw typeError("no.such.function", getArgument(linkRequest), ScriptRuntime.safeToString(self)); case "getMethod": // evaluate to undefined, later on Undefined will take care of throwing TypeError return getInvocation(MH.dropArguments(GET_UNDEFINED.get(TYPE_OBJECT_INDEX), 0, Object.class), self, linkerServices, desc); case "getProp": case "getElem": if(NashornCallSiteDescriptor.isOptimistic(desc)) { throw new UnwarrantedOptimismException(UNDEFINED, NashornCallSiteDescriptor.getProgramPoint(desc), Type.OBJECT); } if (desc.getOperand() != null) { return getInvocation(EMPTY_PROP_GETTER, self, linkerServices, desc); } return getInvocation(EMPTY_ELEM_GETTER, self, linkerServices, desc); case "setProp": case "setElem": { final boolean strict = NashornCallSiteDescriptor.isStrict(desc); if (strict) { throw typeError("cant.set.property", getArgument(linkRequest), ScriptRuntime.safeToString(self)); } if (desc.getOperand() != null) { return getInvocation(EMPTY_PROP_SETTER, self, linkerServices, desc); } return getInvocation(EMPTY_ELEM_SETTER, self, linkerServices, desc); } default: break; } throw new AssertionError("unknown call type " + desc); }
Example 13
Source File: NashornBottomLinker.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
private static GuardedInvocation linkBean(final LinkRequest linkRequest, final LinkerServices linkerServices) throws Exception { final NashornCallSiteDescriptor desc = (NashornCallSiteDescriptor)linkRequest.getCallSiteDescriptor(); final Object self = linkRequest.getReceiver(); final String operator = desc.getFirstOperator(); switch (operator) { case "new": if(BeansLinker.isDynamicMethod(self)) { throw typeError("method.not.constructor", ScriptRuntime.safeToString(self)); } throw typeError("not.a.function", ScriptRuntime.safeToString(self)); case "call": // Support dyn:call on any object that supports some @FunctionalInterface // annotated interface. This way Java method, constructor references or // implementations of java.util.function.* interfaces can be called as though // those are script functions. final Method m = getFunctionalInterfaceMethod(self.getClass()); if (m != null) { final MethodType callType = desc.getMethodType(); // 'callee' and 'thiz' passed from script + actual arguments if (callType.parameterCount() != m.getParameterCount() + 2) { throw typeError("no.method.matches.args", ScriptRuntime.safeToString(self)); } return new GuardedInvocation( // drop 'thiz' passed from the script. MH.dropArguments(desc.getLookup().unreflect(m), 1, callType.parameterType(1)), Guards.getInstanceOfGuard(m.getDeclaringClass())).asType(callType); } if(BeansLinker.isDynamicMethod(self)) { throw typeError("no.method.matches.args", ScriptRuntime.safeToString(self)); } throw typeError("not.a.function", ScriptRuntime.safeToString(self)); case "callMethod": case "getMethod": throw typeError("no.such.function", getArgument(linkRequest), ScriptRuntime.safeToString(self)); case "getProp": case "getElem": if (desc.getOperand() != null) { return getInvocation(EMPTY_PROP_GETTER, self, linkerServices, desc); } return getInvocation(EMPTY_ELEM_GETTER, self, linkerServices, desc); case "setProp": case "setElem": if (desc.getOperand() != null) { return getInvocation(EMPTY_PROP_SETTER, self, linkerServices, desc); } return getInvocation(EMPTY_ELEM_SETTER, self, linkerServices, desc); default: break; } throw new AssertionError("unknown call type " + desc); }
Example 14
Source File: NashornBottomLinker.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
private static GuardedInvocation linkBean(final LinkRequest linkRequest, final LinkerServices linkerServices) throws Exception { final NashornCallSiteDescriptor desc = (NashornCallSiteDescriptor)linkRequest.getCallSiteDescriptor(); final Object self = linkRequest.getReceiver(); final String operator = desc.getFirstOperator(); switch (operator) { case "new": if(BeansLinker.isDynamicConstructor(self)) { throw typeError("no.constructor.matches.args", ScriptRuntime.safeToString(self)); } if(BeansLinker.isDynamicMethod(self)) { throw typeError("method.not.constructor", ScriptRuntime.safeToString(self)); } throw typeError("not.a.function", ScriptRuntime.safeToString(self)); case "call": if(BeansLinker.isDynamicConstructor(self)) { throw typeError("constructor.requires.new", ScriptRuntime.safeToString(self)); } if(BeansLinker.isDynamicMethod(self)) { throw typeError("no.method.matches.args", ScriptRuntime.safeToString(self)); } throw typeError("not.a.function", ScriptRuntime.safeToString(self)); case "callMethod": case "getMethod": throw typeError("no.such.function", getArgument(linkRequest), ScriptRuntime.safeToString(self)); case "getProp": case "getElem": if(NashornCallSiteDescriptor.isOptimistic(desc)) { throw new UnwarrantedOptimismException(UNDEFINED, NashornCallSiteDescriptor.getProgramPoint(desc), Type.OBJECT); } if (desc.getOperand() != null) { return getInvocation(EMPTY_PROP_GETTER, self, linkerServices, desc); } return getInvocation(EMPTY_ELEM_GETTER, self, linkerServices, desc); case "setProp": case "setElem": { final boolean strict = NashornCallSiteDescriptor.isStrict(desc); if (strict) { throw typeError("cant.set.property", getArgument(linkRequest), ScriptRuntime.safeToString(self)); } if (desc.getOperand() != null) { return getInvocation(EMPTY_PROP_SETTER, self, linkerServices, desc); } return getInvocation(EMPTY_ELEM_SETTER, self, linkerServices, desc); } default: break; } throw new AssertionError("unknown call type " + desc); }
Example 15
Source File: NashornBottomLinker.java From jdk8u_nashorn with GNU General Public License v2.0 | 4 votes |
private static GuardedInvocation linkBean(final LinkRequest linkRequest, final LinkerServices linkerServices) throws Exception { final NashornCallSiteDescriptor desc = (NashornCallSiteDescriptor)linkRequest.getCallSiteDescriptor(); final Object self = linkRequest.getReceiver(); final String operator = desc.getFirstOperator(); switch (operator) { case "new": if(BeansLinker.isDynamicConstructor(self)) { throw typeError("no.constructor.matches.args", ScriptRuntime.safeToString(self)); } if(BeansLinker.isDynamicMethod(self)) { throw typeError("method.not.constructor", ScriptRuntime.safeToString(self)); } throw typeError("not.a.function", desc.getFunctionErrorMessage(self)); case "call": if(BeansLinker.isDynamicConstructor(self)) { throw typeError("constructor.requires.new", ScriptRuntime.safeToString(self)); } if(BeansLinker.isDynamicMethod(self)) { throw typeError("no.method.matches.args", ScriptRuntime.safeToString(self)); } throw typeError("not.a.function", desc.getFunctionErrorMessage(self)); case "callMethod": throw typeError("no.such.function", getArgument(linkRequest), ScriptRuntime.safeToString(self)); case "getMethod": // evaluate to undefined, later on Undefined will take care of throwing TypeError return getInvocation(MH.dropArguments(GET_UNDEFINED.get(TYPE_OBJECT_INDEX), 0, Object.class), self, linkerServices, desc); case "getProp": case "getElem": if(NashornCallSiteDescriptor.isOptimistic(desc)) { throw new UnwarrantedOptimismException(UNDEFINED, NashornCallSiteDescriptor.getProgramPoint(desc), Type.OBJECT); } if (desc.getOperand() != null) { return getInvocation(EMPTY_PROP_GETTER, self, linkerServices, desc); } return getInvocation(EMPTY_ELEM_GETTER, self, linkerServices, desc); case "setProp": case "setElem": { final boolean strict = NashornCallSiteDescriptor.isStrict(desc); if (strict) { throw typeError("cant.set.property", getArgument(linkRequest), ScriptRuntime.safeToString(self)); } if (desc.getOperand() != null) { return getInvocation(EMPTY_PROP_SETTER, self, linkerServices, desc); } return getInvocation(EMPTY_ELEM_SETTER, self, linkerServices, desc); } default: break; } throw new AssertionError("unknown call type " + desc); }
Example 16
Source File: Bootstrap.java From openjdk-8 with GNU General Public License v2.0 | 2 votes |
/** * Returns if the given object is a dynalink Dynamic method * @param obj object to be checked * @return true if the obj is a dynamic method */ public static boolean isDynamicMethod(final Object obj) { return obj instanceof BoundDynamicMethod || BeansLinker.isDynamicMethod(obj); }
Example 17
Source File: Bootstrap.java From openjdk-jdk8u with GNU General Public License v2.0 | 2 votes |
/** * Returns if the given object is a dynalink Dynamic method * @param obj object to be checked * @return true if the obj is a dynamic method */ public static boolean isDynamicMethod(final Object obj) { return BeansLinker.isDynamicMethod(obj instanceof BoundCallable ? ((BoundCallable)obj).getCallable() : obj); }
Example 18
Source File: Bootstrap.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 2 votes |
/** * Returns if the given object is a dynalink Dynamic method * @param obj object to be checked * @return true if the obj is a dynamic method */ public static boolean isDynamicMethod(final Object obj) { return BeansLinker.isDynamicMethod(obj instanceof BoundCallable ? ((BoundCallable)obj).getCallable() : obj); }
Example 19
Source File: Bootstrap.java From jdk8u60 with GNU General Public License v2.0 | 2 votes |
/** * Returns if the given object is a dynalink Dynamic method * @param obj object to be checked * @return true if the obj is a dynamic method */ public static boolean isDynamicMethod(final Object obj) { return BeansLinker.isDynamicMethod(obj instanceof BoundCallable ? ((BoundCallable)obj).getCallable() : obj); }
Example 20
Source File: Bootstrap.java From openjdk-8-source with GNU General Public License v2.0 | 2 votes |
/** * Returns if the given object is a dynalink Dynamic method * @param obj object to be checked * @return true if the obj is a dynamic method */ public static boolean isDynamicMethod(final Object obj) { return obj instanceof BoundDynamicMethod || BeansLinker.isDynamicMethod(obj); }