jdk.internal.dynalink.linker.LinkRequest Java Examples

The following examples show how to use jdk.internal.dynalink.linker.LinkRequest. 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: BrowserJSObjectLinker.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public GuardedInvocation getGuardedInvocation(final LinkRequest request, final LinkerServices linkerServices) throws Exception {
    final LinkRequest requestWithoutContext = request.withoutRuntimeContext(); // Nashorn has no runtime context
    final Object self = requestWithoutContext.getReceiver();
    final CallSiteDescriptor desc = requestWithoutContext.getCallSiteDescriptor();
    checkJSObjectClass();

    if (desc.getNameTokenCount() < 2 || !"dyn".equals(desc.getNameToken(CallSiteDescriptor.SCHEME))) {
        // We only support standard "dyn:*[:*]" operations
        return null;
    }

    GuardedInvocation inv;
    if (jsObjectClass.isInstance(self)) {
        inv = lookup(desc, request, linkerServices);
        inv = inv.replaceMethods(linkerServices.filterInternalObjects(inv.getInvocation()), inv.getGuard());
    } else {
        throw new AssertionError(); // Should never reach here.
    }

    return Bootstrap.asTypeSafeReturn(inv, linkerServices, desc);
}
 
Example #2
Source File: JSObjectLinker.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public GuardedInvocation getGuardedInvocation(final LinkRequest request, final LinkerServices linkerServices) throws Exception {
    final LinkRequest requestWithoutContext = request.withoutRuntimeContext(); // Nashorn has no runtime context
    final Object self = requestWithoutContext.getReceiver();
    final CallSiteDescriptor desc = requestWithoutContext.getCallSiteDescriptor();

    if (desc.getNameTokenCount() < 2 || !"dyn".equals(desc.getNameToken(CallSiteDescriptor.SCHEME))) {
        // We only support standard "dyn:*[:*]" operations
        return null;
    }

    final GuardedInvocation inv;
    if (self instanceof JSObject) {
        inv = lookup(desc);
    } else {
        throw new AssertionError(); // Should never reach here.
    }

    return Bootstrap.asType(inv, linkerServices, desc);
}
 
Example #3
Source File: JSObjectLinker.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private GuardedInvocation lookup(final CallSiteDescriptor desc, final LinkRequest request, final LinkerServices linkerServices) throws Exception {
    final String operator = CallSiteDescriptorFactory.tokenizeOperators(desc).get(0);
    final int c = desc.getNameTokenCount();

    switch (operator) {
        case "getProp":
        case "getElem":
        case "getMethod":
            if (c > 2) {
                return findGetMethod(desc);
            }
        // For indexed get, we want get GuardedInvocation beans linker and pass it.
        // JSObjectLinker.get uses this fallback getter for explicit signature method access.
        return findGetIndexMethod(nashornBeansLinker.getGuardedInvocation(request, linkerServices));
        case "setProp":
        case "setElem":
            return c > 2 ? findSetMethod(desc) : findSetIndexMethod();
        case "call":
            return findCallMethod(desc);
        case "new":
            return findNewMethod(desc);
        default:
            return null;
    }
}
 
Example #4
Source File: Global.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Override
public GuardedInvocation findGetMethod(final CallSiteDescriptor desc, final LinkRequest request, final String operator) {
    final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND);
    final boolean isScope = NashornCallSiteDescriptor.isScope(desc);

    if (lexicalScope != null && isScope && !NashornCallSiteDescriptor.isApplyToCall(desc)) {
        if (lexicalScope.hasOwnProperty(name)) {
            return lexicalScope.findGetMethod(desc, request, operator);
        }
    }

    final GuardedInvocation invocation =  super.findGetMethod(desc, request, operator);

    // We want to avoid adding our generic lexical scope switchpoint to global constant invocations,
    // because those are invalidated per-key in the addBoundProperties method above.
    // We therefore check if the invocation does already have a switchpoint and the property is non-inherited,
    // assuming this only applies to global constants. If other non-inherited properties will
    // start using switchpoints some time in the future we'll have to revisit this.
    if (isScope && context.getEnv()._es6 && (invocation.getSwitchPoints() == null || !hasOwnProperty(name))) {
        return invocation.addSwitchPoint(getLexicalScopeSwitchPoint());
    }

    return invocation;
}
 
Example #5
Source File: ContinuousArrayData.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return a fast linked array setter, or null if we have to dispatch to super class
 * @param desc     descriptor
 * @param request  link request
 * @return invocation or null if needs to be sent to slow relink
 */
@Override
public GuardedInvocation findFastSetIndexMethod(final Class<? extends ArrayData> clazz, final CallSiteDescriptor desc, final LinkRequest request) { // array, index, value
    final MethodType callType    = desc.getMethodType();
    final Class<?>   indexType   = callType.parameterType(1);
    final Class<?>   elementType = callType.parameterType(2);

    if (ContinuousArrayData.class.isAssignableFrom(clazz) && indexType == int.class) {
        final Object[]        args  = request.getArguments();
        final int             index = (int)args[args.length - 2];

        if (hasRoomFor(index)) {
            MethodHandle setElement = getElementSetter(elementType); //Z(continuousarraydata, int, int), return true if successful
            if (setElement != null) {
                //else we are dealing with a wider type than supported by this callsite
                MethodHandle getArray = ScriptObject.GET_ARRAY.methodHandle();
                getArray   = MH.asType(getArray, getArray.type().changeReturnType(getClass()));
                setElement = MH.filterArguments(setElement, 0, getArray);
                final MethodHandle guard = MH.insertArguments(FAST_ACCESS_GUARD, 0, clazz);
                return new GuardedInvocation(setElement, guard, (SwitchPoint)null, ClassCastException.class); //CCE if not a scriptObject anymore
            }
        }
    }

    return null;
}
 
Example #6
Source File: Global.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public GuardedInvocation findGetMethod(final CallSiteDescriptor desc, final LinkRequest request, final String operator) {
    final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND);
    final boolean isScope = NashornCallSiteDescriptor.isScope(desc);

    if (lexicalScope != null && isScope && !NashornCallSiteDescriptor.isApplyToCall(desc)) {
        if (lexicalScope.hasOwnProperty(name)) {
            return lexicalScope.findGetMethod(desc, request, operator);
        }
    }

    final GuardedInvocation invocation =  super.findGetMethod(desc, request, operator);

    // We want to avoid adding our generic lexical scope switchpoint to global constant invocations,
    // because those are invalidated per-key in the addBoundProperties method above.
    // We therefor check if the invocation does already have a switchpoint and the property is non-inherited,
    // assuming this only applies to global constants. If other non-inherited properties will
    // start using switchpoints some time in the future we'll have to revisit this.
    if (isScope && context.getEnv()._es6 && (invocation.getSwitchPoints() == null || !hasOwnProperty(name))) {
        return invocation.addSwitchPoint(getLexicalScopeSwitchPoint());
    }

    return invocation;
}
 
Example #7
Source File: StaticClassLinker.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
public GuardedInvocation getGuardedInvocation(final LinkRequest request, final LinkerServices linkerServices)
        throws Exception {
    final GuardedInvocation gi = super.getGuardedInvocation(request, linkerServices);
    if(gi != null) {
        return gi;
    }
    final CallSiteDescriptor desc = request.getCallSiteDescriptor();
    final String op = desc.getNameToken(CallSiteDescriptor.OPERATOR);
    if("new" == op && constructor != null) {
        final MethodHandle ctorInvocation = constructor.getInvocation(desc, linkerServices);
        if(ctorInvocation != null) {
            return new GuardedInvocation(ctorInvocation, getClassGuard(desc.getMethodType()));
        }
    }
    return null;
}
 
Example #8
Source File: StaticClassLinker.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@Override
public GuardedInvocation getGuardedInvocation(LinkRequest request, LinkerServices linkerServices)
        throws Exception {
    final GuardedInvocation gi = super.getGuardedInvocation(request, linkerServices);
    if(gi != null) {
        return gi;
    }
    final CallSiteDescriptor desc = request.getCallSiteDescriptor();
    final String op = desc.getNameToken(CallSiteDescriptor.OPERATOR);
    if("new" == op && constructor != null) {
        final MethodHandle ctorInvocation = constructor.getInvocation(desc, linkerServices);
        if(ctorInvocation != null) {
            return new GuardedInvocation(ctorInvocation, getClassGuard(desc.getMethodType()));
        }
    }
    return null;
}
 
Example #9
Source File: ContinuousArrayData.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return a fast linked array setter, or null if we have to dispatch to super class
 * @param desc     descriptor
 * @param request  link request
 * @return invocation or null if needs to be sent to slow relink
 */
@Override
public GuardedInvocation findFastSetIndexMethod(final Class<? extends ArrayData> clazz, final CallSiteDescriptor desc, final LinkRequest request) { // array, index, value
    final MethodType callType    = desc.getMethodType();
    final Class<?>   indexType   = callType.parameterType(1);
    final Class<?>   elementType = callType.parameterType(2);

    if (ContinuousArrayData.class.isAssignableFrom(clazz) && indexType == int.class) {
        final Object[]        args  = request.getArguments();
        final int             index = (int)args[args.length - 2];

        if (hasRoomFor(index)) {
            MethodHandle setElement = getElementSetter(elementType); //Z(continuousarraydata, int, int), return true if successful
            if (setElement != null) {
                //else we are dealing with a wider type than supported by this callsite
                MethodHandle getArray = ScriptObject.GET_ARRAY.methodHandle();
                getArray   = MH.asType(getArray, getArray.type().changeReturnType(getClass()));
                setElement = MH.filterArguments(setElement, 0, getArray);
                final MethodHandle guard = MH.insertArguments(FAST_ACCESS_GUARD, 0, clazz);
                return new GuardedInvocation(setElement, guard, (SwitchPoint)null, ClassCastException.class); //CCE if not a scriptObject anymore
            }
        }
    }

    return null;
}
 
Example #10
Source File: Global.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public GuardedInvocation findSetMethod(final CallSiteDescriptor desc, final LinkRequest request) {
    final boolean isScope = NashornCallSiteDescriptor.isScope(desc);

    if (lexicalScope != null && isScope) {
        final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND);
        if (lexicalScope.hasOwnProperty(name)) {
            return lexicalScope.findSetMethod(desc, request);
        }
    }

    final GuardedInvocation invocation = super.findSetMethod(desc, request);

    if (isScope && context.getEnv()._es6) {
        return invocation.addSwitchPoint(getLexicalScopeSwitchPoint());
    }

    return invocation;
}
 
Example #11
Source File: NativeArray.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected GuardedInvocation findGetIndexMethod(final CallSiteDescriptor desc, final LinkRequest request) {
    final GuardedInvocation inv = getArray().findFastGetIndexMethod(getArray().getClass(), desc, request);
    if (inv != null) {
        return inv;
    }
    return super.findGetIndexMethod(desc, request);
}
 
Example #12
Source File: NashornLinker.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static java.lang.invoke.MethodHandles.Lookup getCurrentLookup() {
    final LinkRequest currentRequest = AccessController.doPrivileged(new PrivilegedAction<LinkRequest>() {
        @Override
        public LinkRequest run() {
            return LinkerServicesImpl.getCurrentLinkRequest();
        }
    });
    return currentRequest == null ? MethodHandles.publicLookup() : currentRequest.getCallSiteDescriptor().getLookup();
}
 
Example #13
Source File: ReflectionCheckLinker.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public GuardedInvocation getGuardedInvocation(final LinkRequest origRequest, final LinkerServices linkerServices)
        throws Exception {
    checkLinkRequest(origRequest);
    // let the next linker deal with actual linking
    return null;
}
 
Example #14
Source File: ArrayBufferView.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected GuardedInvocation findSetIndexMethod(final CallSiteDescriptor desc, final LinkRequest request) {
    final GuardedInvocation inv = getArray().findFastSetIndexMethod(getArray().getClass(), desc, request);
    if (inv != null) {
        return inv;
    }
    return super.findSetIndexMethod(desc, request);
}
 
Example #15
Source File: NashornPrimitiveLinker.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public GuardedInvocation getGuardedInvocation(final LinkRequest origRequest, final LinkerServices linkerServices)
        throws Exception {
    final LinkRequest request = origRequest.withoutRuntimeContext(); // Nashorn has no runtime context

    final Object self = request.getReceiver();
    final NashornCallSiteDescriptor desc = (NashornCallSiteDescriptor) request.getCallSiteDescriptor();

    return Bootstrap.asTypeSafeReturn(Global.primitiveLookup(request, self), linkerServices, desc);
}
 
Example #16
Source File: ReflectionCheckLinker.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public GuardedInvocation getGuardedInvocation(final LinkRequest origRequest, final LinkerServices linkerServices)
        throws Exception {
    checkLinkRequest(origRequest);
    // let the next linker deal with actual linking
    return null;
}
 
Example #17
Source File: NashornBottomLinker.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public GuardedInvocation getGuardedInvocation(final LinkRequest linkRequest, final LinkerServices linkerServices)
        throws Exception {
    final Object self = linkRequest.getReceiver();

    if (self == null) {
        return linkNull(linkRequest);
    }

    // None of the objects that can be linked by NashornLinker should ever reach here. Basically, anything below
    // this point is a generic Java bean. Therefore, reaching here with a ScriptObject is a Nashorn bug.
    assert isExpectedObject(self) : "Couldn't link " + linkRequest.getCallSiteDescriptor() + " for " + self.getClass().getName();

    return linkBean(linkRequest, linkerServices);
}
 
Example #18
Source File: ArrayBufferView.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected GuardedInvocation findGetIndexMethod(final CallSiteDescriptor desc, final LinkRequest request) {
    final GuardedInvocation inv = getArray().findFastGetIndexMethod(getArray().getClass(), desc, request);
    if (inv != null) {
        return inv;
    }
    return super.findGetIndexMethod(desc, request);
}
 
Example #19
Source File: ScriptObject.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Fall back if a function property is not found.
 * @param desc The call site descriptor
 * @param request the link request
 * @return GuardedInvocation to be invoked at call site.
 */
public GuardedInvocation noSuchMethod(final CallSiteDescriptor desc, final LinkRequest request) {
    final String       name      = desc.getNameToken(2);
    final FindProperty find      = findProperty(NO_SUCH_METHOD_NAME, true);
    final boolean      scopeCall = isScope() && NashornCallSiteDescriptor.isScope(desc);

    if (find == null) {
        return noSuchProperty(desc, request);
    }

    final boolean explicitInstanceOfCheck = explicitInstanceOfCheck(desc, request);

    final Object value = find.getObjectValue();
    if (!(value instanceof ScriptFunction)) {
        return createEmptyGetter(desc, explicitInstanceOfCheck, name);
    }

    final ScriptFunction func = (ScriptFunction)value;
    final Object         thiz = scopeCall && func.isStrict() ? UNDEFINED : this;
    // TODO: It'd be awesome if we could bind "name" without binding "this".
    // Since we're binding this we must use an identity guard here.
    return new GuardedInvocation(
            MH.dropArguments(
                    MH.constant(
                            ScriptFunction.class,
                            func.makeBoundFunction(thiz, new Object[] { name })),
                    0,
                    Object.class),
            NashornGuards.combineGuards(
                    NashornGuards.getIdentityGuard(this),
                    NashornGuards.getMapGuard(getMap(), true)));
}
 
Example #20
Source File: ArrayBufferView.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected GuardedInvocation findGetIndexMethod(final CallSiteDescriptor desc, final LinkRequest request) {
    final GuardedInvocation inv = getArray().findFastGetIndexMethod(getArray().getClass(), desc, request);
    if (inv != null) {
        return inv;
    }
    return super.findGetIndexMethod(desc, request);
}
 
Example #21
Source File: NashornPrimitiveLinker.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public GuardedInvocation getGuardedInvocation(final LinkRequest origRequest, final LinkerServices linkerServices)
        throws Exception {
    final LinkRequest request = origRequest.withoutRuntimeContext(); // Nashorn has no runtime context

    final Object self = request.getReceiver();
    final GlobalObject global = (GlobalObject) Context.getGlobal();
    final NashornCallSiteDescriptor desc = (NashornCallSiteDescriptor) request.getCallSiteDescriptor();

    return Bootstrap.asType(global.primitiveLookup(request, self), linkerServices, desc);
}
 
Example #22
Source File: NashornLinker.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
private static java.lang.invoke.MethodHandles.Lookup getCurrentLookup() {
    final LinkRequest currentRequest = AccessController.doPrivileged(new PrivilegedAction<LinkRequest>() {
        @Override
        public LinkRequest run() {
            return LinkerServicesImpl.getCurrentLinkRequest();
        }
    });
    return currentRequest == null ? MethodHandles.publicLookup() : currentRequest.getCallSiteDescriptor().getLookup();
}
 
Example #23
Source File: CompositeGuardingDynamicLinker.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public GuardedInvocation getGuardedInvocation(final LinkRequest linkRequest, final LinkerServices linkerServices)
        throws Exception {
    for(final GuardingDynamicLinker linker: linkers) {
        final GuardedInvocation invocation = linker.getGuardedInvocation(linkRequest, linkerServices);
        if(invocation != null) {
            return invocation;
        }
    }
    return null;
}
 
Example #24
Source File: NashornStaticClassLinker.java    From nashorn with GNU General Public License v2.0 5 votes vote down vote up
@Override
public GuardedInvocation getGuardedInvocation(LinkRequest linkRequest, LinkerServices linkerServices) throws Exception {
    final LinkRequest request = linkRequest.withoutRuntimeContext(); // Nashorn has no runtime context
    final Object self = request.getReceiver();
    if (self.getClass() != StaticClass.class) {
        return null;
    }
    final Class<?> receiverClass = ((StaticClass) self).getRepresentedClass();
    Bootstrap.checkReflectionAccess(receiverClass);
    final CallSiteDescriptor desc = request.getCallSiteDescriptor();
    // We intercept "new" on StaticClass instances to provide additional capabilities
    if ("new".equals(desc.getNameToken(CallSiteDescriptor.OPERATOR))) {
        // make sure new is on accessible Class
        Context.checkPackageAccess(receiverClass.getName());

        // Is the class abstract? (This includes interfaces.)
        if (NashornLinker.isAbstractClass(receiverClass)) {
            // Change this link request into a link request on the adapter class.
            final Object[] args = request.getArguments();
            args[0] = JavaAdapterFactory.getAdapterClassFor(new Class<?>[] { receiverClass }, null);
            final LinkRequest adapterRequest = request.replaceArguments(request.getCallSiteDescriptor(), args);
            final GuardedInvocation gi = checkNullConstructor(delegate(linkerServices, adapterRequest), receiverClass);
            // Finally, modify the guard to test for the original abstract class.
            return gi.replaceMethods(gi.getInvocation(), Guards.getIdentityGuard(self));
        }
        // If the class was not abstract, just delegate linking to the standard StaticClass linker. Make an
        // additional check to ensure we have a constructor. We could just fall through to the next "return"
        // statement, except we also insert a call to checkNullConstructor() which throws an ECMAScript TypeError
        // with a more intuitive message when no suitable constructor is found.
        return checkNullConstructor(delegate(linkerServices, request), receiverClass);
    }
    // In case this was not a "new" operation, just delegate to the the standard StaticClass linker.
    return delegate(linkerServices, request);
}
 
Example #25
Source File: ReflectionCheckLinker.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void checkLinkRequest(final LinkRequest origRequest) {
    final Global global = Context.getGlobal();
    final ClassFilter cf = global.getClassFilter();
    if (cf != null) {
        throw typeError("no.reflection.with.classfilter");
    }

    final SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        final LinkRequest requestWithoutContext = origRequest.withoutRuntimeContext(); // Nashorn has no runtime context
        final Object self = requestWithoutContext.getReceiver();
        // allow 'static' access on Class objects representing public classes of non-restricted packages
        if ((self instanceof Class) && Modifier.isPublic(((Class<?>)self).getModifiers())) {
            final CallSiteDescriptor desc = requestWithoutContext.getCallSiteDescriptor();
            if(CallSiteDescriptorFactory.tokenizeOperators(desc).contains("getProp")) {
                if (desc.getNameTokenCount() > CallSiteDescriptor.NAME_OPERAND &&
                    "static".equals(desc.getNameToken(CallSiteDescriptor.NAME_OPERAND))) {
                    if (Context.isAccessibleClass((Class<?>)self) && !isReflectionClass((Class<?>)self)) {

                        // If "getProp:static" passes access checks, allow access.
                        return;
                    }
                }
            }
        }
        checkReflectionPermission(sm);
    }
}
 
Example #26
Source File: ScriptObject.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Fall back if a property is not found.
 * @param desc the call site descriptor.
 * @param request the link request
 * @return GuardedInvocation to be invoked at call site.
 */
@SuppressWarnings("null")
public GuardedInvocation noSuchProperty(final CallSiteDescriptor desc, final LinkRequest request) {
    final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND);
    final FindProperty find = findProperty(NO_SUCH_PROPERTY_NAME, true);
    final boolean scopeAccess = isScope() && NashornCallSiteDescriptor.isScope(desc);

    if (find != null) {
        final Object   value        = getObjectValue(find);
        ScriptFunction func         = null;
        MethodHandle   methodHandle = null;

        if (value instanceof ScriptFunction) {
            func = (ScriptFunction)value;
            methodHandle = getCallMethodHandle(func, desc.getMethodType(), name);
        }

        if (methodHandle != null) {
            if (scopeAccess && func.isStrict()) {
                methodHandle = bindTo(methodHandle, UNDEFINED);
            }
            return new GuardedInvocation(methodHandle,
                    find.isInherited()? getMap().getProtoGetSwitchPoint(proto, NO_SUCH_PROPERTY_NAME) : null,
                    getKnownFunctionPropertyGuard(getMap(), find.getGetter(Object.class), find.getOwner(), func));
        }
    }

    if (scopeAccess) {
        throw referenceError("not.defined", name);
    }

    return createEmptyGetter(desc, name);
}
 
Example #27
Source File: NativeJSAdapter.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected GuardedInvocation findCallMethodMethod(final CallSiteDescriptor desc, final LinkRequest request) {
    if (overrides && super.hasOwnProperty(desc.getNameToken(2))) {
        try {
            final GuardedInvocation inv = super.findCallMethodMethod(desc, request);
            if (inv != null) {
                return inv;
            }
        } catch (final Exception e) {
            //ignored
        }
    }

    return findHook(desc, __call__);
}
 
Example #28
Source File: NashornBottomLinker.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public GuardedInvocation getGuardedInvocation(final LinkRequest linkRequest, final LinkerServices linkerServices)
        throws Exception {
    final Object self = linkRequest.getReceiver();

    if (self == null) {
        return linkNull(linkRequest);
    }

    // None of the objects that can be linked by NashornLinker should ever reach here. Basically, anything below
    // this point is a generic Java bean. Therefore, reaching here with a ScriptObject is a Nashorn bug.
    assert isExpectedObject(self) : "Couldn't link " + linkRequest.getCallSiteDescriptor() + " for " + self.getClass().getName();

    return linkBean(linkRequest, linkerServices);
}
 
Example #29
Source File: NativeArray.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * We need to check if we are dealing with a continuous non empty array data here,
 * as pop with a primitive return value returns undefined for arrays with length 0
 */
@Override
public boolean canLink(final Object self, final CallSiteDescriptor desc, final LinkRequest request) {
    final ContinuousArrayData data = getContinuousNonEmptyArrayData(self);
    if (data != null) {
        final Class<?> elementType = data.getElementType();
        final Class<?> returnType  = desc.getMethodType().returnType();
        final boolean  typeFits    = JSType.getAccessorTypeIndex(returnType) >= JSType.getAccessorTypeIndex(elementType);
        return typeFits;
    }
    return false;
}
 
Example #30
Source File: NashornBottomLinker.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
@Override
public GuardedInvocation getGuardedInvocation(final LinkRequest linkRequest, final LinkerServices linkerServices)
        throws Exception {
    final Object self = linkRequest.getReceiver();

    if (self == null) {
        return linkNull(linkRequest);
    }

    // None of the objects that can be linked by NashornLinker should ever reach here. Basically, anything below
    // this point is a generic Java bean. Therefore, reaching here with a ScriptObject is a Nashorn bug.
    assert isExpectedObject(self) : "Couldn't link " + linkRequest.getCallSiteDescriptor() + " for " + self.getClass().getName();

    return linkBean(linkRequest, linkerServices);
}