jdk.internal.dynalink.support.Lookup Java Examples

The following examples show how to use jdk.internal.dynalink.support.Lookup. 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: CallerSensitiveDynamicMethod.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
MethodHandle getTarget(final MethodHandles.Lookup lookup) {
    if(target instanceof Method) {
        final MethodHandle mh = Lookup.unreflect(lookup, (Method)target);
        if(Modifier.isStatic(((Member)target).getModifiers())) {
            return StaticClassIntrospector.editStaticMethodHandle(mh);
        }
        return mh;
    }
    return StaticClassIntrospector.editConstructorMethodHandle(Lookup.unreflectConstructor(lookup,
            (Constructor<?>)target));
}
 
Example #2
Source File: AbstractJavaLinker.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Unreflects a method handle from a Method or a Constructor using safe (zero-privilege) unreflection. Should be
 * only used for methods and constructors that are not caller sensitive. If a caller sensitive method were
 * unreflected through this mechanism, it would not be a security issue, but would be bound to the zero-privilege
 * unreflector as its caller, and thus completely useless.
 * @param m the method or constructor
 * @return the method handle
 */
private static MethodHandle unreflectSafely(final AccessibleObject m) {
    if(m instanceof Method) {
        final Method reflMethod = (Method)m;
        final MethodHandle handle = Lookup.PUBLIC.unreflect(reflMethod);
        if(Modifier.isStatic(reflMethod.getModifiers())) {
            return StaticClassIntrospector.editStaticMethodHandle(handle);
        }
        return handle;
    }
    return StaticClassIntrospector.editConstructorMethodHandle(Lookup.PUBLIC.unreflectConstructor((Constructor<?>)m));
}
 
Example #3
Source File: CallerSensitiveDynamicMethod.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
MethodHandle getTarget(final MethodHandles.Lookup lookup) {
    if(target instanceof Method) {
        final MethodHandle mh = Lookup.unreflect(lookup, (Method)target);
        if(Modifier.isStatic(((Member)target).getModifiers())) {
            return StaticClassIntrospector.editStaticMethodHandle(mh);
        }
        return mh;
    }
    return StaticClassIntrospector.editConstructorMethodHandle(Lookup.unreflectConstructor(lookup,
            (Constructor<?>)target));
}
 
Example #4
Source File: CallerSensitiveDynamicMethod.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
@Override
MethodHandle getTarget(final MethodHandles.Lookup lookup) {
    if(target instanceof Method) {
        final MethodHandle mh = Lookup.unreflect(lookup, (Method)target);
        if(Modifier.isStatic(((Member)target).getModifiers())) {
            return StaticClassIntrospector.editStaticMethodHandle(mh);
        }
        return mh;
    }
    return StaticClassIntrospector.editConstructorMethodHandle(Lookup.unreflectConstructor(lookup,
            (Constructor<?>)target));
}
 
Example #5
Source File: NashornLinker.java    From jdk8u60 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 #6
Source File: CallerSensitiveDynamicMethod.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
MethodHandle getTarget(final MethodHandles.Lookup lookup) {
    if(target instanceof Method) {
        final MethodHandle mh = Lookup.unreflect(lookup, (Method)target);
        if(Modifier.isStatic(((Member)target).getModifiers())) {
            return StaticClassIntrospector.editStaticMethodHandle(mh);
        }
        return mh;
    }
    return StaticClassIntrospector.editConstructorMethodHandle(Lookup.unreflectConstructor(lookup,
            (Constructor<?>)target));
}
 
Example #7
Source File: AbstractJavaLinker.java    From nashorn with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Unreflects a method handle from a Method or a Constructor using safe (zero-privilege) unreflection. Should be
 * only used for methods and constructors that are not caller sensitive. If a caller sensitive method were
 * unreflected through this mechanism, it would not be a security issue, but would be bound to the zero-privilege
 * unreflector as its caller, and thus completely useless.
 * @param m the method or constructor
 * @return the method handle
 */
private static MethodHandle unreflectSafely(AccessibleObject m) {
    if(m instanceof Method) {
        final Method reflMethod = (Method)m;
        final MethodHandle handle = Lookup.PUBLIC.unreflect(reflMethod);
        if(Modifier.isStatic(reflMethod.getModifiers())) {
            return StaticClassIntrospector.editStaticMethodHandle(handle);
        }
        return handle;
    }
    return StaticClassIntrospector.editConstructorMethodHandle(Lookup.PUBLIC.unreflectConstructor((Constructor<?>)m));
}
 
Example #8
Source File: AbstractJavaLinker.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Unreflects a method handle from a Method or a Constructor using safe (zero-privilege) unreflection. Should be
 * only used for methods and constructors that are not caller sensitive. If a caller sensitive method were
 * unreflected through this mechanism, it would not be a security issue, but would be bound to the zero-privilege
 * unreflector as its caller, and thus completely useless.
 * @param m the method or constructor
 * @return the method handle
 */
private static MethodHandle unreflectSafely(final AccessibleObject m) {
    if(m instanceof Method) {
        final Method reflMethod = (Method)m;
        final MethodHandle handle = Lookup.PUBLIC.unreflect(reflMethod);
        if(Modifier.isStatic(reflMethod.getModifiers())) {
            return StaticClassIntrospector.editStaticMethodHandle(handle);
        }
        return handle;
    }
    return StaticClassIntrospector.editConstructorMethodHandle(Lookup.PUBLIC.unreflectConstructor((Constructor<?>)m));
}
 
Example #9
Source File: CallerSensitiveDynamicMethod.java    From nashorn with GNU General Public License v2.0 5 votes vote down vote up
@Override
MethodHandle getTarget(MethodHandles.Lookup lookup) {
    if(target instanceof Method) {
        final MethodHandle mh = Lookup.unreflect(lookup, (Method)target);
        if(Modifier.isStatic(((Member)target).getModifiers())) {
            return StaticClassIntrospector.editStaticMethodHandle(mh);
        }
        return mh;
    }
    return StaticClassIntrospector.editConstructorMethodHandle(Lookup.unreflectConstructor(lookup,
            (Constructor<?>)target));
}
 
Example #10
Source File: AbstractJavaLinker.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Unreflects a method handle from a Method or a Constructor using safe (zero-privilege) unreflection. Should be
 * only used for methods and constructors that are not caller sensitive. If a caller sensitive method were
 * unreflected through this mechanism, it would not be a security issue, but would be bound to the zero-privilege
 * unreflector as its caller, and thus completely useless.
 * @param m the method or constructor
 * @return the method handle
 */
private static MethodHandle unreflectSafely(final AccessibleObject m) {
    if(m instanceof Method) {
        final Method reflMethod = (Method)m;
        final MethodHandle handle = Lookup.PUBLIC.unreflect(reflMethod);
        if(Modifier.isStatic(reflMethod.getModifiers())) {
            return StaticClassIntrospector.editStaticMethodHandle(handle);
        }
        return handle;
    }
    return StaticClassIntrospector.editConstructorMethodHandle(Lookup.PUBLIC.unreflectConstructor((Constructor<?>)m));
}
 
Example #11
Source File: NashornLinker.java    From openjdk-jdk8u 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 #12
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 #13
Source File: CallerSensitiveDynamicMethod.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
MethodHandle getTarget(final MethodHandles.Lookup lookup) {
    if(target instanceof Method) {
        final MethodHandle mh = Lookup.unreflect(lookup, (Method)target);
        if(Modifier.isStatic(((Member)target).getModifiers())) {
            return StaticClassIntrospector.editStaticMethodHandle(mh);
        }
        return mh;
    }
    return StaticClassIntrospector.editConstructorMethodHandle(Lookup.unreflectConstructor(lookup,
            (Constructor<?>)target));
}
 
Example #14
Source File: AbstractJavaLinker.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Unreflects a method handle from a Method or a Constructor using safe (zero-privilege) unreflection. Should be
 * only used for methods and constructors that are not caller sensitive. If a caller sensitive method were
 * unreflected through this mechanism, it would not be a security issue, but would be bound to the zero-privilege
 * unreflector as its caller, and thus completely useless.
 * @param m the method or constructor
 * @return the method handle
 */
private static MethodHandle unreflectSafely(final AccessibleObject m) {
    if(m instanceof Method) {
        final Method reflMethod = (Method)m;
        final MethodHandle handle = Lookup.PUBLIC.unreflect(reflMethod);
        if(Modifier.isStatic(reflMethod.getModifiers())) {
            return StaticClassIntrospector.editStaticMethodHandle(handle);
        }
        return handle;
    }
    return StaticClassIntrospector.editConstructorMethodHandle(Lookup.PUBLIC.unreflectConstructor((Constructor<?>)m));
}
 
Example #15
Source File: AbstractJavaLinker.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Unreflects a method handle from a Method or a Constructor using safe (zero-privilege) unreflection. Should be
 * only used for methods and constructors that are not caller sensitive. If a caller sensitive method were
 * unreflected through this mechanism, it would not be a security issue, but would be bound to the zero-privilege
 * unreflector as its caller, and thus completely useless.
 * @param m the method or constructor
 * @return the method handle
 */
private static MethodHandle unreflectSafely(AccessibleObject m) {
    if(m instanceof Method) {
        final Method reflMethod = (Method)m;
        final MethodHandle handle = Lookup.PUBLIC.unreflect(reflMethod);
        if(Modifier.isStatic(reflMethod.getModifiers())) {
            return StaticClassIntrospector.editStaticMethodHandle(handle);
        }
        return handle;
    }
    return StaticClassIntrospector.editConstructorMethodHandle(Lookup.PUBLIC.unreflectConstructor((Constructor<?>)m));
}
 
Example #16
Source File: AbstractJavaLinker.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Unreflects a method handle from a Method or a Constructor using safe (zero-privilege) unreflection. Should be
 * only used for methods and constructors that are not caller sensitive. If a caller sensitive method were
 * unreflected through this mechanism, it would not be a security issue, but would be bound to the zero-privilege
 * unreflector as its caller, and thus completely useless.
 * @param m the method or constructor
 * @return the method handle
 */
private static MethodHandle unreflectSafely(final AccessibleObject m) {
    if(m instanceof Method) {
        final Method reflMethod = (Method)m;
        final MethodHandle handle = Lookup.PUBLIC.unreflect(reflMethod);
        if(Modifier.isStatic(reflMethod.getModifiers())) {
            return StaticClassIntrospector.editStaticMethodHandle(handle);
        }
        return handle;
    }
    return StaticClassIntrospector.editConstructorMethodHandle(Lookup.PUBLIC.unreflectConstructor((Constructor<?>)m));
}
 
Example #17
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 #18
Source File: NashornLinker.java    From hottub 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 #19
Source File: CallerSensitiveDynamicMethod.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
MethodHandle getTarget(final MethodHandles.Lookup lookup) {
    if(target instanceof Method) {
        final MethodHandle mh = Lookup.unreflect(lookup, (Method)target);
        if(Modifier.isStatic(((Member)target).getModifiers())) {
            return StaticClassIntrospector.editStaticMethodHandle(mh);
        }
        return mh;
    }
    return StaticClassIntrospector.editConstructorMethodHandle(Lookup.unreflectConstructor(lookup,
            (Constructor<?>)target));
}
 
Example #20
Source File: CallerSensitiveDynamicMethod.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
MethodHandle getTarget(MethodHandles.Lookup lookup) {
    if(target instanceof Method) {
        final MethodHandle mh = Lookup.unreflect(lookup, (Method)target);
        if(Modifier.isStatic(((Member)target).getModifiers())) {
            return StaticClassIntrospector.editStaticMethodHandle(mh);
        }
        return mh;
    }
    return StaticClassIntrospector.editConstructorMethodHandle(Lookup.unreflectConstructor(lookup,
            (Constructor<?>)target));
}
 
Example #21
Source File: AbstractJavaLinker.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Unreflects a method handle from a Method or a Constructor using safe (zero-privilege) unreflection. Should be
 * only used for methods and constructors that are not caller sensitive. If a caller sensitive method were
 * unreflected through this mechanism, it would not be a security issue, but would be bound to the zero-privilege
 * unreflector as its caller, and thus completely useless.
 * @param m the method or constructor
 * @return the method handle
 */
private static MethodHandle unreflectSafely(final AccessibleObject m) {
    if(m instanceof Method) {
        final Method reflMethod = (Method)m;
        final MethodHandle handle = Lookup.PUBLIC.unreflect(reflMethod);
        if(Modifier.isStatic(reflMethod.getModifiers())) {
            return StaticClassIntrospector.editStaticMethodHandle(handle);
        }
        return handle;
    }
    return StaticClassIntrospector.editConstructorMethodHandle(Lookup.PUBLIC.unreflectConstructor((Constructor<?>)m));
}
 
Example #22
Source File: AbstractJavaLinker.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Unreflects a method handle from a Method or a Constructor using safe (zero-privilege) unreflection. Should be
 * only used for methods and constructors that are not caller sensitive. If a caller sensitive method were
 * unreflected through this mechanism, it would not be a security issue, but would be bound to the zero-privilege
 * unreflector as its caller, and thus completely useless.
 * @param m the method or constructor
 * @return the method handle
 */
private static MethodHandle unreflectSafely(AccessibleObject m) {
    if(m instanceof Method) {
        final Method reflMethod = (Method)m;
        final MethodHandle handle = Lookup.PUBLIC.unreflect(reflMethod);
        if(Modifier.isStatic(reflMethod.getModifiers())) {
            return StaticClassIntrospector.editStaticMethodHandle(handle);
        }
        return handle;
    }
    return StaticClassIntrospector.editConstructorMethodHandle(Lookup.PUBLIC.unreflectConstructor((Constructor<?>)m));
}
 
Example #23
Source File: NashornLinker.java    From openjdk-jdk8u-backup 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 #24
Source File: CallerSensitiveDynamicMethod.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
MethodHandle getTarget(MethodHandles.Lookup lookup) {
    if(target instanceof Method) {
        final MethodHandle mh = Lookup.unreflect(lookup, (Method)target);
        if(Modifier.isStatic(((Member)target).getModifiers())) {
            return StaticClassIntrospector.editStaticMethodHandle(mh);
        }
        return mh;
    }
    return StaticClassIntrospector.editConstructorMethodHandle(Lookup.unreflectConstructor(lookup,
            (Constructor<?>)target));
}
 
Example #25
Source File: FacetIntrospector.java    From jdk8u_nashorn with GNU General Public License v2.0 4 votes vote down vote up
MethodHandle unreflectGetter(final Field field) {
    return editMethodHandle(Lookup.PUBLIC.unreflectGetter(field));
}
 
Example #26
Source File: FacetIntrospector.java    From nashorn with GNU General Public License v2.0 4 votes vote down vote up
MethodHandle unreflectSetter(Field field) {
    return editMethodHandle(Lookup.PUBLIC.unreflectSetter(field));
}
 
Example #27
Source File: BeanLinker.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private static MethodHandle findRangeCheck(Class<?> collectionType) {
    return Lookup.findOwnStatic(MethodHandles.lookup(), "rangeCheck", boolean.class, collectionType, Object.class);
}
 
Example #28
Source File: FacetIntrospector.java    From jdk8u_nashorn with GNU General Public License v2.0 4 votes vote down vote up
MethodHandle unreflectSetter(final Field field) {
    return editMethodHandle(Lookup.PUBLIC.unreflectSetter(field));
}
 
Example #29
Source File: BeanLinker.java    From nashorn with GNU General Public License v2.0 4 votes vote down vote up
private static MethodHandle findRangeCheck(Class<?> collectionType) {
    return Lookup.findOwnStatic(MethodHandles.lookup(), "rangeCheck", boolean.class, collectionType, Object.class);
}
 
Example #30
Source File: FacetIntrospector.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
MethodHandle unreflectSetter(Field field) {
    return editMethodHandle(Lookup.PUBLIC.unreflectSetter(field));
}