Java Code Examples for jdk.internal.dynalink.support.Guards#isArray()

The following examples show how to use jdk.internal.dynalink.support.Guards#isArray() . 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: AbstractJavaLinker.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private MethodHandle getGuard(final ValidationType validationType, final MethodType methodType) {
    switch(validationType) {
        case EXACT_CLASS: {
            return getClassGuard(methodType);
        }
        case INSTANCE_OF: {
            return getAssignableGuard(methodType);
        }
        case IS_ARRAY: {
            return Guards.isArray(0, methodType);
        }
        case NONE: {
            return null;
        }
        default: {
            throw new AssertionError();
        }
    }
}
 
Example 2
Source File: AbstractJavaLinker.java    From nashorn with GNU General Public License v2.0 6 votes vote down vote up
private MethodHandle getGuard(ValidationType validationType, MethodType methodType) {
    switch(validationType) {
        case EXACT_CLASS: {
            return getClassGuard(methodType);
        }
        case INSTANCE_OF: {
            return getAssignableGuard(methodType);
        }
        case IS_ARRAY: {
            return Guards.isArray(0, methodType);
        }
        case NONE: {
            return null;
        }
        default: {
            throw new AssertionError();
        }
    }
}
 
Example 3
Source File: AbstractJavaLinker.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private MethodHandle getGuard(final ValidationType validationType, final MethodType methodType) {
    switch(validationType) {
        case EXACT_CLASS: {
            return getClassGuard(methodType);
        }
        case INSTANCE_OF: {
            return getAssignableGuard(methodType);
        }
        case IS_ARRAY: {
            return Guards.isArray(0, methodType);
        }
        case NONE: {
            return null;
        }
        default: {
            throw new AssertionError();
        }
    }
}
 
Example 4
Source File: AbstractJavaLinker.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private MethodHandle getGuard(final ValidationType validationType, final MethodType methodType) {
    switch(validationType) {
        case EXACT_CLASS: {
            return getClassGuard(methodType);
        }
        case INSTANCE_OF: {
            return getAssignableGuard(methodType);
        }
        case IS_ARRAY: {
            return Guards.isArray(0, methodType);
        }
        case NONE: {
            return null;
        }
        default: {
            throw new AssertionError();
        }
    }
}
 
Example 5
Source File: AbstractJavaLinker.java    From jdk8u_nashorn with GNU General Public License v2.0 6 votes vote down vote up
private MethodHandle getGuard(final ValidationType validationType, final MethodType methodType) {
    switch(validationType) {
        case EXACT_CLASS: {
            return getClassGuard(methodType);
        }
        case INSTANCE_OF: {
            return getAssignableGuard(methodType);
        }
        case IS_ARRAY: {
            return Guards.isArray(0, methodType);
        }
        case NONE: {
            return null;
        }
        default: {
            throw new AssertionError();
        }
    }
}
 
Example 6
Source File: AbstractJavaLinker.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private MethodHandle getGuard(final ValidationType validationType, final MethodType methodType) {
    switch(validationType) {
        case EXACT_CLASS: {
            return getClassGuard(methodType);
        }
        case INSTANCE_OF: {
            return getAssignableGuard(methodType);
        }
        case IS_ARRAY: {
            return Guards.isArray(0, methodType);
        }
        case NONE: {
            return null;
        }
        default: {
            throw new AssertionError();
        }
    }
}
 
Example 7
Source File: AbstractJavaLinker.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private MethodHandle getGuard(final ValidationType validationType, final MethodType methodType) {
    switch(validationType) {
        case EXACT_CLASS: {
            return getClassGuard(methodType);
        }
        case INSTANCE_OF: {
            return getAssignableGuard(methodType);
        }
        case IS_ARRAY: {
            return Guards.isArray(0, methodType);
        }
        case NONE: {
            return null;
        }
        default: {
            throw new AssertionError();
        }
    }
}
 
Example 8
Source File: AbstractJavaLinker.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private MethodHandle getGuard(ValidationType validationType, MethodType methodType) {
    switch(validationType) {
        case EXACT_CLASS: {
            return getClassGuard(methodType);
        }
        case INSTANCE_OF: {
            return getAssignableGuard(methodType);
        }
        case IS_ARRAY: {
            return Guards.isArray(0, methodType);
        }
        case NONE: {
            return null;
        }
        default: {
            throw new AssertionError();
        }
    }
}
 
Example 9
Source File: AbstractJavaLinker.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private MethodHandle getGuard(ValidationType validationType, MethodType methodType) {
    switch(validationType) {
        case EXACT_CLASS: {
            return getClassGuard(methodType);
        }
        case INSTANCE_OF: {
            return getAssignableGuard(methodType);
        }
        case IS_ARRAY: {
            return Guards.isArray(0, methodType);
        }
        case NONE: {
            return null;
        }
        default: {
            throw new AssertionError();
        }
    }
}
 
Example 10
Source File: BeanLinker.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private GuardedInvocationComponent getLengthGetter(final CallSiteDescriptor callSiteDescriptor) {
    assertParameterCount(callSiteDescriptor, 1);
    final MethodType callSiteType = callSiteDescriptor.getMethodType();
    final Class<?> declaredType = callSiteType.parameterType(0);
    // If declared type of receiver at the call site is already an array, collection, or map, bind without guard.
    // Thing is, it'd be quite stupid of a call site creator to go though invokedynamic when it knows in advance
    // they're dealing with an array, collection, or map, but hey...
    if(declaredType.isArray()) {
        return new GuardedInvocationComponent(GET_ARRAY_LENGTH.asType(callSiteType));
    } else if(Collection.class.isAssignableFrom(declaredType)) {
        return new GuardedInvocationComponent(GET_COLLECTION_LENGTH.asType(callSiteType));
    } else if(Map.class.isAssignableFrom(declaredType)) {
        return new GuardedInvocationComponent(GET_MAP_LENGTH.asType(callSiteType));
    }

    // Otherwise, create a binding based on the actual type of the argument with an appropriate guard.
    if(clazz.isArray()) {
        return new GuardedInvocationComponent(GET_ARRAY_LENGTH.asType(callSiteType), Guards.isArray(0,
                callSiteType), ValidationType.IS_ARRAY);
    } if(Collection.class.isAssignableFrom(clazz)) {
        return new GuardedInvocationComponent(GET_COLLECTION_LENGTH.asType(callSiteType), Guards.asType(
                COLLECTION_GUARD, callSiteType), Collection.class, ValidationType.INSTANCE_OF);
    } if(Map.class.isAssignableFrom(clazz)) {
        return new GuardedInvocationComponent(GET_MAP_LENGTH.asType(callSiteType), Guards.asType(MAP_GUARD,
                callSiteType), Map.class, ValidationType.INSTANCE_OF);
    }
    // Can't retrieve length for objects that are neither arrays, nor collections, nor maps.
    return null;
}
 
Example 11
Source File: BeanLinker.java    From nashorn with GNU General Public License v2.0 5 votes vote down vote up
private GuardedInvocationComponent getLengthGetter(CallSiteDescriptor callSiteDescriptor) {
    assertParameterCount(callSiteDescriptor, 1);
    final MethodType callSiteType = callSiteDescriptor.getMethodType();
    final Class<?> declaredType = callSiteType.parameterType(0);
    // If declared type of receiver at the call site is already an array, collection, or map, bind without guard.
    // Thing is, it'd be quite stupid of a call site creator to go though invokedynamic when it knows in advance
    // they're dealing with an array, collection, or map, but hey...
    if(declaredType.isArray()) {
        return new GuardedInvocationComponent(GET_ARRAY_LENGTH.asType(callSiteType));
    } else if(Collection.class.isAssignableFrom(declaredType)) {
        return new GuardedInvocationComponent(GET_COLLECTION_LENGTH.asType(callSiteType));
    } else if(Map.class.isAssignableFrom(declaredType)) {
        return new GuardedInvocationComponent(GET_MAP_LENGTH.asType(callSiteType));
    }

    // Otherwise, create a binding based on the actual type of the argument with an appropriate guard.
    if(clazz.isArray()) {
        return new GuardedInvocationComponent(GET_ARRAY_LENGTH.asType(callSiteType), Guards.isArray(0,
                callSiteType), ValidationType.IS_ARRAY);
    } if(Collection.class.isAssignableFrom(clazz)) {
        return new GuardedInvocationComponent(GET_COLLECTION_LENGTH.asType(callSiteType), Guards.asType(
                COLLECTION_GUARD, callSiteType), Collection.class, ValidationType.INSTANCE_OF);
    } if(Map.class.isAssignableFrom(clazz)) {
        return new GuardedInvocationComponent(GET_MAP_LENGTH.asType(callSiteType), Guards.asType(MAP_GUARD,
                callSiteType), Map.class, ValidationType.INSTANCE_OF);
    }
    // Can't retrieve length for objects that are neither arrays, nor collections, nor maps.
    return null;
}
 
Example 12
Source File: BeanLinker.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
private GuardedInvocationComponent getLengthGetter(final CallSiteDescriptor callSiteDescriptor) {
    assertParameterCount(callSiteDescriptor, 1);
    final MethodType callSiteType = callSiteDescriptor.getMethodType();
    final Class<?> declaredType = callSiteType.parameterType(0);
    // If declared type of receiver at the call site is already an array, collection, or map, bind without guard.
    // Thing is, it'd be quite stupid of a call site creator to go though invokedynamic when it knows in advance
    // they're dealing with an array, collection, or map, but hey...
    if(declaredType.isArray()) {
        return new GuardedInvocationComponent(GET_ARRAY_LENGTH.asType(callSiteType));
    } else if(Collection.class.isAssignableFrom(declaredType)) {
        return new GuardedInvocationComponent(GET_COLLECTION_LENGTH.asType(callSiteType));
    } else if(Map.class.isAssignableFrom(declaredType)) {
        return new GuardedInvocationComponent(GET_MAP_LENGTH.asType(callSiteType));
    }

    // Otherwise, create a binding based on the actual type of the argument with an appropriate guard.
    if(clazz.isArray()) {
        return new GuardedInvocationComponent(GET_ARRAY_LENGTH.asType(callSiteType), Guards.isArray(0,
                callSiteType), ValidationType.IS_ARRAY);
    } if(Collection.class.isAssignableFrom(clazz)) {
        return new GuardedInvocationComponent(GET_COLLECTION_LENGTH.asType(callSiteType), Guards.asType(
                COLLECTION_GUARD, callSiteType), Collection.class, ValidationType.INSTANCE_OF);
    } if(Map.class.isAssignableFrom(clazz)) {
        return new GuardedInvocationComponent(GET_MAP_LENGTH.asType(callSiteType), Guards.asType(MAP_GUARD,
                callSiteType), Map.class, ValidationType.INSTANCE_OF);
    }
    // Can't retrieve length for objects that are neither arrays, nor collections, nor maps.
    return null;
}
 
Example 13
Source File: BeanLinker.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private GuardedInvocationComponent getLengthGetter(CallSiteDescriptor callSiteDescriptor) {
    assertParameterCount(callSiteDescriptor, 1);
    final MethodType callSiteType = callSiteDescriptor.getMethodType();
    final Class<?> declaredType = callSiteType.parameterType(0);
    // If declared type of receiver at the call site is already an array, collection, or map, bind without guard.
    // Thing is, it'd be quite stupid of a call site creator to go though invokedynamic when it knows in advance
    // they're dealing with an array, collection, or map, but hey...
    if(declaredType.isArray()) {
        return new GuardedInvocationComponent(GET_ARRAY_LENGTH.asType(callSiteType));
    } else if(Collection.class.isAssignableFrom(declaredType)) {
        return new GuardedInvocationComponent(GET_COLLECTION_LENGTH.asType(callSiteType));
    } else if(Map.class.isAssignableFrom(declaredType)) {
        return new GuardedInvocationComponent(GET_MAP_LENGTH.asType(callSiteType));
    }

    // Otherwise, create a binding based on the actual type of the argument with an appropriate guard.
    if(clazz.isArray()) {
        return new GuardedInvocationComponent(GET_ARRAY_LENGTH.asType(callSiteType), Guards.isArray(0,
                callSiteType), ValidationType.IS_ARRAY);
    } if(Collection.class.isAssignableFrom(clazz)) {
        return new GuardedInvocationComponent(GET_COLLECTION_LENGTH.asType(callSiteType), Guards.asType(
                COLLECTION_GUARD, callSiteType), Collection.class, ValidationType.INSTANCE_OF);
    } if(Map.class.isAssignableFrom(clazz)) {
        return new GuardedInvocationComponent(GET_MAP_LENGTH.asType(callSiteType), Guards.asType(MAP_GUARD,
                callSiteType), Map.class, ValidationType.INSTANCE_OF);
    }
    // Can't retrieve length for objects that are neither arrays, nor collections, nor maps.
    return null;
}
 
Example 14
Source File: BeanLinker.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private GuardedInvocationComponent getLengthGetter(CallSiteDescriptor callSiteDescriptor) {
    assertParameterCount(callSiteDescriptor, 1);
    final MethodType callSiteType = callSiteDescriptor.getMethodType();
    final Class<?> declaredType = callSiteType.parameterType(0);
    // If declared type of receiver at the call site is already an array, collection, or map, bind without guard.
    // Thing is, it'd be quite stupid of a call site creator to go though invokedynamic when it knows in advance
    // they're dealing with an array, collection, or map, but hey...
    if(declaredType.isArray()) {
        return new GuardedInvocationComponent(GET_ARRAY_LENGTH.asType(callSiteType));
    } else if(Collection.class.isAssignableFrom(declaredType)) {
        return new GuardedInvocationComponent(GET_COLLECTION_LENGTH.asType(callSiteType));
    } else if(Map.class.isAssignableFrom(declaredType)) {
        return new GuardedInvocationComponent(GET_MAP_LENGTH.asType(callSiteType));
    }

    // Otherwise, create a binding based on the actual type of the argument with an appropriate guard.
    if(clazz.isArray()) {
        return new GuardedInvocationComponent(GET_ARRAY_LENGTH.asType(callSiteType), Guards.isArray(0,
                callSiteType), ValidationType.IS_ARRAY);
    } if(Collection.class.isAssignableFrom(clazz)) {
        return new GuardedInvocationComponent(GET_COLLECTION_LENGTH.asType(callSiteType), Guards.asType(
                COLLECTION_GUARD, callSiteType), Collection.class, ValidationType.INSTANCE_OF);
    } if(Map.class.isAssignableFrom(clazz)) {
        return new GuardedInvocationComponent(GET_MAP_LENGTH.asType(callSiteType), Guards.asType(MAP_GUARD,
                callSiteType), Map.class, ValidationType.INSTANCE_OF);
    }
    // Can't retrieve length for objects that are neither arrays, nor collections, nor maps.
    return null;
}
 
Example 15
Source File: BeanLinker.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private GuardedInvocationComponent getLengthGetter(final CallSiteDescriptor callSiteDescriptor) {
    assertParameterCount(callSiteDescriptor, 1);
    final MethodType callSiteType = callSiteDescriptor.getMethodType();
    final Class<?> declaredType = callSiteType.parameterType(0);
    // If declared type of receiver at the call site is already an array, collection, or map, bind without guard.
    // Thing is, it'd be quite stupid of a call site creator to go though invokedynamic when it knows in advance
    // they're dealing with an array, collection, or map, but hey...
    if(declaredType.isArray()) {
        return new GuardedInvocationComponent(GET_ARRAY_LENGTH.asType(callSiteType));
    } else if(Collection.class.isAssignableFrom(declaredType)) {
        return new GuardedInvocationComponent(GET_COLLECTION_LENGTH.asType(callSiteType));
    } else if(Map.class.isAssignableFrom(declaredType)) {
        return new GuardedInvocationComponent(GET_MAP_LENGTH.asType(callSiteType));
    }

    // Otherwise, create a binding based on the actual type of the argument with an appropriate guard.
    if(clazz.isArray()) {
        return new GuardedInvocationComponent(GET_ARRAY_LENGTH.asType(callSiteType), Guards.isArray(0,
                callSiteType), ValidationType.IS_ARRAY);
    } if(Collection.class.isAssignableFrom(clazz)) {
        return new GuardedInvocationComponent(GET_COLLECTION_LENGTH.asType(callSiteType), Guards.asType(
                COLLECTION_GUARD, callSiteType), Collection.class, ValidationType.INSTANCE_OF);
    } if(Map.class.isAssignableFrom(clazz)) {
        return new GuardedInvocationComponent(GET_MAP_LENGTH.asType(callSiteType), Guards.asType(MAP_GUARD,
                callSiteType), Map.class, ValidationType.INSTANCE_OF);
    }
    // Can't retrieve length for objects that are neither arrays, nor collections, nor maps.
    return null;
}
 
Example 16
Source File: BeanLinker.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private GuardedInvocationComponent getLengthGetter(final CallSiteDescriptor callSiteDescriptor) {
    assertParameterCount(callSiteDescriptor, 1);
    final MethodType callSiteType = callSiteDescriptor.getMethodType();
    final Class<?> declaredType = callSiteType.parameterType(0);
    // If declared type of receiver at the call site is already an array, collection, or map, bind without guard.
    // Thing is, it'd be quite stupid of a call site creator to go though invokedynamic when it knows in advance
    // they're dealing with an array, collection, or map, but hey...
    if(declaredType.isArray()) {
        return new GuardedInvocationComponent(GET_ARRAY_LENGTH.asType(callSiteType));
    } else if(Collection.class.isAssignableFrom(declaredType)) {
        return new GuardedInvocationComponent(GET_COLLECTION_LENGTH.asType(callSiteType));
    } else if(Map.class.isAssignableFrom(declaredType)) {
        return new GuardedInvocationComponent(GET_MAP_LENGTH.asType(callSiteType));
    }

    // Otherwise, create a binding based on the actual type of the argument with an appropriate guard.
    if(clazz.isArray()) {
        return new GuardedInvocationComponent(GET_ARRAY_LENGTH.asType(callSiteType), Guards.isArray(0,
                callSiteType), ValidationType.IS_ARRAY);
    } if(Collection.class.isAssignableFrom(clazz)) {
        return new GuardedInvocationComponent(GET_COLLECTION_LENGTH.asType(callSiteType), Guards.asType(
                COLLECTION_GUARD, callSiteType), Collection.class, ValidationType.INSTANCE_OF);
    } if(Map.class.isAssignableFrom(clazz)) {
        return new GuardedInvocationComponent(GET_MAP_LENGTH.asType(callSiteType), Guards.asType(MAP_GUARD,
                callSiteType), Map.class, ValidationType.INSTANCE_OF);
    }
    // Can't retrieve length for objects that are neither arrays, nor collections, nor maps.
    return null;
}
 
Example 17
Source File: BeanLinker.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private GuardedInvocationComponent getLengthGetter(final CallSiteDescriptor callSiteDescriptor) {
    assertParameterCount(callSiteDescriptor, 1);
    final MethodType callSiteType = callSiteDescriptor.getMethodType();
    final Class<?> declaredType = callSiteType.parameterType(0);
    // If declared type of receiver at the call site is already an array, collection, or map, bind without guard.
    // Thing is, it'd be quite stupid of a call site creator to go though invokedynamic when it knows in advance
    // they're dealing with an array, collection, or map, but hey...
    if(declaredType.isArray()) {
        return new GuardedInvocationComponent(GET_ARRAY_LENGTH.asType(callSiteType));
    } else if(Collection.class.isAssignableFrom(declaredType)) {
        return new GuardedInvocationComponent(GET_COLLECTION_LENGTH.asType(callSiteType));
    } else if(Map.class.isAssignableFrom(declaredType)) {
        return new GuardedInvocationComponent(GET_MAP_LENGTH.asType(callSiteType));
    }

    // Otherwise, create a binding based on the actual type of the argument with an appropriate guard.
    if(clazz.isArray()) {
        return new GuardedInvocationComponent(GET_ARRAY_LENGTH.asType(callSiteType), Guards.isArray(0,
                callSiteType), ValidationType.IS_ARRAY);
    } if(Collection.class.isAssignableFrom(clazz)) {
        return new GuardedInvocationComponent(GET_COLLECTION_LENGTH.asType(callSiteType), Guards.asType(
                COLLECTION_GUARD, callSiteType), Collection.class, ValidationType.INSTANCE_OF);
    } if(Map.class.isAssignableFrom(clazz)) {
        return new GuardedInvocationComponent(GET_MAP_LENGTH.asType(callSiteType), Guards.asType(MAP_GUARD,
                callSiteType), Map.class, ValidationType.INSTANCE_OF);
    }
    // Can't retrieve length for objects that are neither arrays, nor collections, nor maps.
    return null;
}
 
Example 18
Source File: BeanLinker.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private GuardedInvocationComponent getLengthGetter(final CallSiteDescriptor callSiteDescriptor) {
    assertParameterCount(callSiteDescriptor, 1);
    final MethodType callSiteType = callSiteDescriptor.getMethodType();
    final Class<?> declaredType = callSiteType.parameterType(0);
    // If declared type of receiver at the call site is already an array, collection, or map, bind without guard.
    // Thing is, it'd be quite stupid of a call site creator to go though invokedynamic when it knows in advance
    // they're dealing with an array, collection, or map, but hey...
    if(declaredType.isArray()) {
        return new GuardedInvocationComponent(GET_ARRAY_LENGTH.asType(callSiteType));
    } else if(Collection.class.isAssignableFrom(declaredType)) {
        return new GuardedInvocationComponent(GET_COLLECTION_LENGTH.asType(callSiteType));
    } else if(Map.class.isAssignableFrom(declaredType)) {
        return new GuardedInvocationComponent(GET_MAP_LENGTH.asType(callSiteType));
    }

    // Otherwise, create a binding based on the actual type of the argument with an appropriate guard.
    if(clazz.isArray()) {
        return new GuardedInvocationComponent(GET_ARRAY_LENGTH.asType(callSiteType), Guards.isArray(0,
                callSiteType), ValidationType.IS_ARRAY);
    } if(Collection.class.isAssignableFrom(clazz)) {
        return new GuardedInvocationComponent(GET_COLLECTION_LENGTH.asType(callSiteType), Guards.asType(
                COLLECTION_GUARD, callSiteType), Collection.class, ValidationType.INSTANCE_OF);
    } if(Map.class.isAssignableFrom(clazz)) {
        return new GuardedInvocationComponent(GET_MAP_LENGTH.asType(callSiteType), Guards.asType(MAP_GUARD,
                callSiteType), Map.class, ValidationType.INSTANCE_OF);
    }
    // Can't retrieve length for objects that are neither arrays, nor collections, nor maps.
    return null;
}