jdk.internal.dynalink.DynamicLinker Java Examples
The following examples show how to use
jdk.internal.dynalink.DynamicLinker.
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: Guards.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Creates a method handle that returns true if the argument in the specified position is a Java array. * * @param pos the position in the argument lit * @param type the method type of the handle * @return a method handle that returns true if the argument in the specified position is a Java array; the rest of * the arguments are ignored. */ @SuppressWarnings("boxing") public static MethodHandle isArray(final int pos, final MethodType type) { final Class<?> declaredType = type.parameterType(pos); if(declaredType.isArray()) { LOG.log(Level.WARNING, "isArrayGuardAlwaysTrue", new Object[] { pos, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantTrue(type); } if(!declaredType.isAssignableFrom(Object[].class)) { LOG.log(Level.WARNING, "isArrayGuardAlwaysFalse", new Object[] { pos, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantFalse(type); } return asType(IS_ARRAY, pos, type); }
Example #2
Source File: Guards.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Creates a method handle that returns true if the argument in the specified position is a Java array. * * @param pos the position in the argument lit * @param type the method type of the handle * @return a method handle that returns true if the argument in the specified position is a Java array; the rest of * the arguments are ignored. */ @SuppressWarnings("boxing") public static MethodHandle isArray(int pos, MethodType type) { final Class<?> declaredType = type.parameterType(pos); if(declaredType.isArray()) { LOG.log(Level.WARNING, "isArrayGuardAlwaysTrue", new Object[] { pos, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantTrue(type); } if(!declaredType.isAssignableFrom(Object[].class)) { LOG.log(Level.WARNING, "isArrayGuardAlwaysFalse", new Object[] { pos, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantFalse(type); } return asType(IS_ARRAY, pos, type); }
Example #3
Source File: Guards.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Creates a method handle with arguments of a specified type, but with boolean return value. When invoked, it * returns true if the n'th argument is instance of the specified class or its subclass). The rest of the arguments * will be ignored. * * @param clazz the class of the first argument to test for * @param pos the position on the argument list to test * @param type the method type * @return a method handle testing whether its first argument is of the specified class or subclass. */ @SuppressWarnings("boxing") public static MethodHandle isInstance(Class<?> clazz, int pos, MethodType type) { final Class<?> declaredType = type.parameterType(pos); if(clazz.isAssignableFrom(declaredType)) { LOG.log(Level.WARNING, "isInstanceGuardAlwaysTrue", new Object[] { clazz.getName(), pos, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantTrue(type); } if(!declaredType.isAssignableFrom(clazz)) { LOG.log(Level.WARNING, "isInstanceGuardAlwaysFalse", new Object[] { clazz.getName(), pos, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantFalse(type); } return getClassBoundArgumentTest(IS_INSTANCE, clazz, pos, type); }
Example #4
Source File: Guards.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Creates a guard method handle with arguments of a specified type, but with boolean return value. When invoked, it * returns true if the first argument is of the specified class (exactly of it, not a subclass). The rest of the * arguments will be ignored. * * @param clazz the class of the first argument to test for * @param type the method type * @return a method handle testing whether its first argument is of the specified class. */ @SuppressWarnings("boxing") public static MethodHandle isOfClass(Class<?> clazz, MethodType type) { final Class<?> declaredType = type.parameterType(0); if(clazz == declaredType) { LOG.log(Level.WARNING, "isOfClassGuardAlwaysTrue", new Object[] { clazz.getName(), 0, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantTrue(type); } if(!declaredType.isAssignableFrom(clazz)) { LOG.log(Level.WARNING, "isOfClassGuardAlwaysFalse", new Object[] { clazz.getName(), 0, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantFalse(type); } return getClassBoundArgumentTest(IS_OF_CLASS, clazz, 0, type); }
Example #5
Source File: Guards.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Creates a method handle that returns true if the argument in the specified position is a Java array. * * @param pos the position in the argument lit * @param type the method type of the handle * @return a method handle that returns true if the argument in the specified position is a Java array; the rest of * the arguments are ignored. */ @SuppressWarnings("boxing") public static MethodHandle isArray(final int pos, final MethodType type) { final Class<?> declaredType = type.parameterType(pos); if(declaredType.isArray()) { LOG.log(Level.WARNING, "isArrayGuardAlwaysTrue", new Object[] { pos, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantTrue(type); } if(!declaredType.isAssignableFrom(Object[].class)) { LOG.log(Level.WARNING, "isArrayGuardAlwaysFalse", new Object[] { pos, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantFalse(type); } return asType(IS_ARRAY, pos, type); }
Example #6
Source File: Guards.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Creates a method handle with arguments of a specified type, but with boolean return value. When invoked, it * returns true if the n'th argument is instance of the specified class or its subclass). The rest of the arguments * will be ignored. * * @param clazz the class of the first argument to test for * @param pos the position on the argument list to test * @param type the method type * @return a method handle testing whether its first argument is of the specified class or subclass. */ @SuppressWarnings("boxing") public static MethodHandle isInstance(final Class<?> clazz, final int pos, final MethodType type) { final Class<?> declaredType = type.parameterType(pos); if(clazz.isAssignableFrom(declaredType)) { LOG.log(Level.WARNING, "isInstanceGuardAlwaysTrue", new Object[] { clazz.getName(), pos, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantTrue(type); } if(!declaredType.isAssignableFrom(clazz)) { LOG.log(Level.WARNING, "isInstanceGuardAlwaysFalse", new Object[] { clazz.getName(), pos, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantFalse(type); } return getClassBoundArgumentTest(IS_INSTANCE, clazz, pos, type); }
Example #7
Source File: Guards.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Creates a guard method handle with arguments of a specified type, but with boolean return value. When invoked, it * returns true if the first argument is of the specified class (exactly of it, not a subclass). The rest of the * arguments will be ignored. * * @param clazz the class of the first argument to test for * @param type the method type * @return a method handle testing whether its first argument is of the specified class. */ @SuppressWarnings("boxing") public static MethodHandle isOfClass(final Class<?> clazz, final MethodType type) { final Class<?> declaredType = type.parameterType(0); if(clazz == declaredType) { LOG.log(Level.WARNING, "isOfClassGuardAlwaysTrue", new Object[] { clazz.getName(), 0, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantTrue(type); } if(!declaredType.isAssignableFrom(clazz)) { LOG.log(Level.WARNING, "isOfClassGuardAlwaysFalse", new Object[] { clazz.getName(), 0, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantFalse(type); } return getClassBoundArgumentTest(IS_OF_CLASS, clazz, 0, type); }
Example #8
Source File: Guards.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Creates a guard method handle with arguments of a specified type, but with boolean return value. When invoked, it * returns true if the first argument is of the specified class (exactly of it, not a subclass). The rest of the * arguments will be ignored. * * @param clazz the class of the first argument to test for * @param type the method type * @return a method handle testing whether its first argument is of the specified class. */ @SuppressWarnings("boxing") public static MethodHandle isOfClass(Class<?> clazz, MethodType type) { final Class<?> declaredType = type.parameterType(0); if(clazz == declaredType) { LOG.log(Level.WARNING, "isOfClassGuardAlwaysTrue", new Object[] { clazz.getName(), 0, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantTrue(type); } if(!declaredType.isAssignableFrom(clazz)) { LOG.log(Level.WARNING, "isOfClassGuardAlwaysFalse", new Object[] { clazz.getName(), 0, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantFalse(type); } return getClassBoundArgumentTest(IS_OF_CLASS, clazz, 0, type); }
Example #9
Source File: Guards.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Creates a method handle with arguments of a specified type, but with boolean return value. When invoked, it * returns true if the n'th argument is instance of the specified class or its subclass). The rest of the arguments * will be ignored. * * @param clazz the class of the first argument to test for * @param pos the position on the argument list to test * @param type the method type * @return a method handle testing whether its first argument is of the specified class or subclass. */ @SuppressWarnings("boxing") public static MethodHandle isInstance(Class<?> clazz, int pos, MethodType type) { final Class<?> declaredType = type.parameterType(pos); if(clazz.isAssignableFrom(declaredType)) { LOG.log(Level.WARNING, "isInstanceGuardAlwaysTrue", new Object[] { clazz.getName(), pos, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantTrue(type); } if(!declaredType.isAssignableFrom(clazz)) { LOG.log(Level.WARNING, "isInstanceGuardAlwaysFalse", new Object[] { clazz.getName(), pos, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantFalse(type); } return getClassBoundArgumentTest(IS_INSTANCE, clazz, pos, type); }
Example #10
Source File: Guards.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Creates a method handle that returns true if the argument in the specified position is a Java array. * * @param pos the position in the argument lit * @param type the method type of the handle * @return a method handle that returns true if the argument in the specified position is a Java array; the rest of * the arguments are ignored. */ @SuppressWarnings("boxing") public static MethodHandle isArray(final int pos, final MethodType type) { final Class<?> declaredType = type.parameterType(pos); if(declaredType.isArray()) { LOG.log(Level.WARNING, "isArrayGuardAlwaysTrue", new Object[] { pos, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantTrue(type); } if(!declaredType.isAssignableFrom(Object[].class)) { LOG.log(Level.WARNING, "isArrayGuardAlwaysFalse", new Object[] { pos, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantFalse(type); } return asType(IS_ARRAY, pos, type); }
Example #11
Source File: Guards.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Creates a method handle with arguments of a specified type, but with boolean return value. When invoked, it * returns true if the n'th argument is instance of the specified class or its subclass). The rest of the arguments * will be ignored. * * @param clazz the class of the first argument to test for * @param pos the position on the argument list to test * @param type the method type * @return a method handle testing whether its first argument is of the specified class or subclass. */ @SuppressWarnings("boxing") public static MethodHandle isInstance(final Class<?> clazz, final int pos, final MethodType type) { final Class<?> declaredType = type.parameterType(pos); if(clazz.isAssignableFrom(declaredType)) { LOG.log(Level.WARNING, "isInstanceGuardAlwaysTrue", new Object[] { clazz.getName(), pos, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantTrue(type); } if(!declaredType.isAssignableFrom(clazz)) { LOG.log(Level.WARNING, "isInstanceGuardAlwaysFalse", new Object[] { clazz.getName(), pos, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantFalse(type); } return getClassBoundArgumentTest(IS_INSTANCE, clazz, pos, type); }
Example #12
Source File: Guards.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Creates a guard method handle with arguments of a specified type, but with boolean return value. When invoked, it * returns true if the first argument is of the specified class (exactly of it, not a subclass). The rest of the * arguments will be ignored. * * @param clazz the class of the first argument to test for * @param type the method type * @return a method handle testing whether its first argument is of the specified class. */ @SuppressWarnings("boxing") public static MethodHandle isOfClass(final Class<?> clazz, final MethodType type) { final Class<?> declaredType = type.parameterType(0); if(clazz == declaredType) { LOG.log(Level.WARNING, "isOfClassGuardAlwaysTrue", new Object[] { clazz.getName(), 0, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantTrue(type); } if(!declaredType.isAssignableFrom(clazz)) { LOG.log(Level.WARNING, "isOfClassGuardAlwaysFalse", new Object[] { clazz.getName(), 0, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantFalse(type); } return getClassBoundArgumentTest(IS_OF_CLASS, clazz, 0, type); }
Example #13
Source File: Guards.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Creates a method handle that returns true if the argument in the specified position is a Java array. * * @param pos the position in the argument lit * @param type the method type of the handle * @return a method handle that returns true if the argument in the specified position is a Java array; the rest of * the arguments are ignored. */ @SuppressWarnings("boxing") public static MethodHandle isArray(int pos, MethodType type) { final Class<?> declaredType = type.parameterType(pos); if(declaredType.isArray()) { LOG.log(Level.WARNING, "isArrayGuardAlwaysTrue", new Object[] { pos, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantTrue(type); } if(!declaredType.isAssignableFrom(Object[].class)) { LOG.log(Level.WARNING, "isArrayGuardAlwaysFalse", new Object[] { pos, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantFalse(type); } return asType(IS_ARRAY, pos, type); }
Example #14
Source File: Guards.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Creates a method handle with arguments of a specified type, but with boolean return value. When invoked, it * returns true if the n'th argument is instance of the specified class or its subclass). The rest of the arguments * will be ignored. * * @param clazz the class of the first argument to test for * @param pos the position on the argument list to test * @param type the method type * @return a method handle testing whether its first argument is of the specified class or subclass. */ @SuppressWarnings("boxing") public static MethodHandle isInstance(final Class<?> clazz, final int pos, final MethodType type) { final Class<?> declaredType = type.parameterType(pos); if(clazz.isAssignableFrom(declaredType)) { LOG.log(Level.WARNING, "isInstanceGuardAlwaysTrue", new Object[] { clazz.getName(), pos, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantTrue(type); } if(!declaredType.isAssignableFrom(clazz)) { LOG.log(Level.WARNING, "isInstanceGuardAlwaysFalse", new Object[] { clazz.getName(), pos, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantFalse(type); } return getClassBoundArgumentTest(IS_INSTANCE, clazz, pos, type); }
Example #15
Source File: Guards.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Creates a guard method handle with arguments of a specified type, but with boolean return value. When invoked, it * returns true if the first argument is of the specified class (exactly of it, not a subclass). The rest of the * arguments will be ignored. * * @param clazz the class of the first argument to test for * @param type the method type * @return a method handle testing whether its first argument is of the specified class. */ @SuppressWarnings("boxing") public static MethodHandle isOfClass(final Class<?> clazz, final MethodType type) { final Class<?> declaredType = type.parameterType(0); if(clazz == declaredType) { LOG.log(Level.WARNING, "isOfClassGuardAlwaysTrue", new Object[] { clazz.getName(), 0, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantTrue(type); } if(!declaredType.isAssignableFrom(clazz)) { LOG.log(Level.WARNING, "isOfClassGuardAlwaysFalse", new Object[] { clazz.getName(), 0, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantFalse(type); } return getClassBoundArgumentTest(IS_OF_CLASS, clazz, 0, type); }
Example #16
Source File: Guards.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
/** * Creates a guard method handle with arguments of a specified type, but with boolean return value. When invoked, it * returns true if the first argument is of the specified class (exactly of it, not a subclass). The rest of the * arguments will be ignored. * * @param clazz the class of the first argument to test for * @param type the method type * @return a method handle testing whether its first argument is of the specified class. */ @SuppressWarnings("boxing") public static MethodHandle isOfClass(final Class<?> clazz, final MethodType type) { final Class<?> declaredType = type.parameterType(0); if(clazz == declaredType) { LOG.log(Level.WARNING, "isOfClassGuardAlwaysTrue", new Object[] { clazz.getName(), 0, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantTrue(type); } if(!declaredType.isAssignableFrom(clazz)) { LOG.log(Level.WARNING, "isOfClassGuardAlwaysFalse", new Object[] { clazz.getName(), 0, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantFalse(type); } return getClassBoundArgumentTest(IS_OF_CLASS, clazz, 0, type); }
Example #17
Source File: Guards.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Creates a method handle that returns true if the argument in the specified position is a Java array. * * @param pos the position in the argument lit * @param type the method type of the handle * @return a method handle that returns true if the argument in the specified position is a Java array; the rest of * the arguments are ignored. */ @SuppressWarnings("boxing") public static MethodHandle isArray(final int pos, final MethodType type) { final Class<?> declaredType = type.parameterType(pos); if(declaredType.isArray()) { LOG.log(Level.WARNING, "isArrayGuardAlwaysTrue", new Object[] { pos, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantTrue(type); } if(!declaredType.isAssignableFrom(Object[].class)) { LOG.log(Level.WARNING, "isArrayGuardAlwaysFalse", new Object[] { pos, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantFalse(type); } return asType(IS_ARRAY, pos, type); }
Example #18
Source File: Guards.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Creates a method handle with arguments of a specified type, but with boolean return value. When invoked, it * returns true if the n'th argument is instance of the specified class or its subclass). The rest of the arguments * will be ignored. * * @param clazz the class of the first argument to test for * @param pos the position on the argument list to test * @param type the method type * @return a method handle testing whether its first argument is of the specified class or subclass. */ @SuppressWarnings("boxing") public static MethodHandle isInstance(final Class<?> clazz, final int pos, final MethodType type) { final Class<?> declaredType = type.parameterType(pos); if(clazz.isAssignableFrom(declaredType)) { LOG.log(Level.WARNING, "isInstanceGuardAlwaysTrue", new Object[] { clazz.getName(), pos, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantTrue(type); } if(!declaredType.isAssignableFrom(clazz)) { LOG.log(Level.WARNING, "isInstanceGuardAlwaysFalse", new Object[] { clazz.getName(), pos, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantFalse(type); } return getClassBoundArgumentTest(IS_INSTANCE, clazz, pos, type); }
Example #19
Source File: Guards.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Creates a guard method handle with arguments of a specified type, but with boolean return value. When invoked, it * returns true if the first argument is of the specified class (exactly of it, not a subclass). The rest of the * arguments will be ignored. * * @param clazz the class of the first argument to test for * @param type the method type * @return a method handle testing whether its first argument is of the specified class. */ @SuppressWarnings("boxing") public static MethodHandle isOfClass(final Class<?> clazz, final MethodType type) { final Class<?> declaredType = type.parameterType(0); if(clazz == declaredType) { LOG.log(Level.WARNING, "isOfClassGuardAlwaysTrue", new Object[] { clazz.getName(), 0, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantTrue(type); } if(!declaredType.isAssignableFrom(clazz)) { LOG.log(Level.WARNING, "isOfClassGuardAlwaysFalse", new Object[] { clazz.getName(), 0, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantFalse(type); } return getClassBoundArgumentTest(IS_OF_CLASS, clazz, 0, type); }
Example #20
Source File: Guards.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
/** * Creates a method handle with arguments of a specified type, but with boolean return value. When invoked, it * returns true if the n'th argument is instance of the specified class or its subclass). The rest of the arguments * will be ignored. * * @param clazz the class of the first argument to test for * @param pos the position on the argument list to test * @param type the method type * @return a method handle testing whether its first argument is of the specified class or subclass. */ @SuppressWarnings("boxing") public static MethodHandle isInstance(final Class<?> clazz, final int pos, final MethodType type) { final Class<?> declaredType = type.parameterType(pos); if(clazz.isAssignableFrom(declaredType)) { LOG.log(Level.WARNING, "isInstanceGuardAlwaysTrue", new Object[] { clazz.getName(), pos, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantTrue(type); } if(!declaredType.isAssignableFrom(clazz)) { LOG.log(Level.WARNING, "isInstanceGuardAlwaysFalse", new Object[] { clazz.getName(), pos, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantFalse(type); } return getClassBoundArgumentTest(IS_INSTANCE, clazz, pos, type); }
Example #21
Source File: Guards.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
/** * Creates a method handle that returns true if the argument in the specified position is a Java array. * * @param pos the position in the argument lit * @param type the method type of the handle * @return a method handle that returns true if the argument in the specified position is a Java array; the rest of * the arguments are ignored. */ @SuppressWarnings("boxing") public static MethodHandle isArray(final int pos, final MethodType type) { final Class<?> declaredType = type.parameterType(pos); if(declaredType.isArray()) { LOG.log(Level.WARNING, "isArrayGuardAlwaysTrue", new Object[] { pos, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantTrue(type); } if(!declaredType.isAssignableFrom(Object[].class)) { LOG.log(Level.WARNING, "isArrayGuardAlwaysFalse", new Object[] { pos, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantFalse(type); } return asType(IS_ARRAY, pos, type); }
Example #22
Source File: Guards.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Creates a method handle that returns true if the argument in the specified position is a Java array. * * @param pos the position in the argument lit * @param type the method type of the handle * @return a method handle that returns true if the argument in the specified position is a Java array; the rest of * the arguments are ignored. */ @SuppressWarnings("boxing") public static MethodHandle isArray(final int pos, final MethodType type) { final Class<?> declaredType = type.parameterType(pos); if(declaredType.isArray()) { LOG.log(Level.WARNING, "isArrayGuardAlwaysTrue", new Object[] { pos, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantTrue(type); } if(!declaredType.isAssignableFrom(Object[].class)) { LOG.log(Level.WARNING, "isArrayGuardAlwaysFalse", new Object[] { pos, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantFalse(type); } return asType(IS_ARRAY, pos, type); }
Example #23
Source File: Guards.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Creates a method handle with arguments of a specified type, but with boolean return value. When invoked, it * returns true if the n'th argument is instance of the specified class or its subclass). The rest of the arguments * will be ignored. * * @param clazz the class of the first argument to test for * @param pos the position on the argument list to test * @param type the method type * @return a method handle testing whether its first argument is of the specified class or subclass. */ @SuppressWarnings("boxing") public static MethodHandle isInstance(final Class<?> clazz, final int pos, final MethodType type) { final Class<?> declaredType = type.parameterType(pos); if(clazz.isAssignableFrom(declaredType)) { LOG.log(Level.WARNING, "isInstanceGuardAlwaysTrue", new Object[] { clazz.getName(), pos, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantTrue(type); } if(!declaredType.isAssignableFrom(clazz)) { LOG.log(Level.WARNING, "isInstanceGuardAlwaysFalse", new Object[] { clazz.getName(), pos, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantFalse(type); } return getClassBoundArgumentTest(IS_INSTANCE, clazz, pos, type); }
Example #24
Source File: Guards.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Creates a guard method handle with arguments of a specified type, but with boolean return value. When invoked, it * returns true if the first argument is of the specified class (exactly of it, not a subclass). The rest of the * arguments will be ignored. * * @param clazz the class of the first argument to test for * @param type the method type * @return a method handle testing whether its first argument is of the specified class. */ @SuppressWarnings("boxing") public static MethodHandle isOfClass(final Class<?> clazz, final MethodType type) { final Class<?> declaredType = type.parameterType(0); if(clazz == declaredType) { LOG.log(Level.WARNING, "isOfClassGuardAlwaysTrue", new Object[] { clazz.getName(), 0, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantTrue(type); } if(!declaredType.isAssignableFrom(clazz)) { LOG.log(Level.WARNING, "isOfClassGuardAlwaysFalse", new Object[] { clazz.getName(), 0, type, DynamicLinker.getLinkedCallSiteLocation() }); return constantFalse(type); } return getClassBoundArgumentTest(IS_OF_CLASS, clazz, 0, type); }
Example #25
Source File: LinkerCallSite.java From nashorn with GNU General Public License v2.0 | 4 votes |
private static String getScriptLocation() { final StackTraceElement caller = DynamicLinker.getLinkedCallSiteLocation(); return caller == null ? "unknown location" : (caller.getFileName() + ":" + caller.getLineNumber()); }
Example #26
Source File: LinkerCallSite.java From jdk8u_nashorn with GNU General Public License v2.0 | 4 votes |
private static String getScriptLocation() { final StackTraceElement caller = DynamicLinker.getLinkedCallSiteLocation(); return caller == null ? "unknown location" : (caller.getFileName() + ":" + caller.getLineNumber()); }
Example #27
Source File: GlobalConstants.java From jdk8u_nashorn with GNU General Public License v2.0 | 4 votes |
/** * Try to turn a getter into a MethodHandle.constant, if possible * * @param find property lookup * @param receiver receiver * @param desc callsite descriptor * * @return resulting getter, or null if failed to create constant */ GuardedInvocation findGetMethod(final FindProperty find, final ScriptObject receiver, final CallSiteDescriptor desc) { // Only use constant getter for fast scope access, because the receiver may change between invocations // for slow-scope and non-scope callsites. // Also return null for user accessor properties as they may have side effects. if (invalidatedForever.get() || !NashornCallSiteDescriptor.isFastScope(desc) || (GLOBAL_ONLY && !find.getOwner().isGlobal()) || find.getProperty() instanceof UserAccessorProperty) { return null; } final boolean isOptimistic = NashornCallSiteDescriptor.isOptimistic(desc); final int programPoint = isOptimistic ? getProgramPoint(desc) : INVALID_PROGRAM_POINT; final Class<?> retType = desc.getMethodType().returnType(); final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND); synchronized (this) { final Access acc = getOrCreateSwitchPoint(name); log.fine("Starting to look up object value " + name); final Object c = find.getObjectValue(); if (log.isEnabled()) { log.fine("Trying to link constant GETTER " + acc + " value = " + c); } if (acc.hasBeenInvalidated() || acc.guardFailed() || invalidatedForever.get()) { if (log.isEnabled()) { log.info("*** GET: Giving up on " + quote(name) + " - retry count has exceeded " + DynamicLinker.getLinkedCallSiteLocation()); } return null; } final MethodHandle cmh = constantGetter(c); MethodHandle mh; MethodHandle guard; if (isOptimistic) { if (JSType.getAccessorTypeIndex(cmh.type().returnType()) <= JSType.getAccessorTypeIndex(retType)) { //widen return type - this is pessimistic, so it will always work mh = MH.asType(cmh, cmh.type().changeReturnType(retType)); } else { //immediately invalidate - we asked for a too wide constant as a narrower one mh = MH.dropArguments(MH.insertArguments(JSType.THROW_UNWARRANTED.methodHandle(), 0, c, programPoint), 0, Object.class); } } else { //pessimistic return type filter mh = Lookup.filterReturnType(cmh, retType); } if (find.getOwner().isGlobal()) { guard = null; } else { guard = MH.insertArguments(RECEIVER_GUARD, 0, acc, receiver); } if (log.isEnabled()) { log.info("Linked getter " + quote(name) + " as MethodHandle.constant() -> " + c + " " + acc.getSwitchPoint()); mh = MethodHandleFactory.addDebugPrintout(log, Level.FINE, mh, "get const " + acc); } return new GuardedInvocation(mh, guard, acc.getSwitchPoint(), null); } }
Example #28
Source File: LinkerCallSite.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
private static String getScriptLocation() { final StackTraceElement caller = DynamicLinker.getLinkedCallSiteLocation(); return caller == null ? "unknown location" : (caller.getFileName() + ":" + caller.getLineNumber()); }
Example #29
Source File: LinkerCallSite.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
private static String getScriptLocation() { final StackTraceElement caller = DynamicLinker.getLinkedCallSiteLocation(); return caller == null ? "unknown location" : (caller.getFileName() + ":" + caller.getLineNumber()); }
Example #30
Source File: LinkerCallSite.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
private static String getScriptLocation() { final StackTraceElement caller = DynamicLinker.getLinkedCallSiteLocation(); return caller == null ? "unknown location" : (caller.getFileName() + ":" + caller.getLineNumber()); }