Java Code Examples for sun.invoke.util.VerifyType#isNullConversion()

The following examples show how to use sun.invoke.util.VerifyType#isNullConversion() . 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: MethodType.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/** True if the new parameters can be viewed (w/o casting) under the old parameter types. */
/*non-public*/
boolean parametersAreViewableAs(MethodType newType, boolean keepInterfaces) {
    if (form == newType.form && form.erasedType == this)
        return true;  // my reference parameters are all Object
    if (ptypes == newType.ptypes)
        return true;
    int argc = parameterCount();
    if (argc != newType.parameterCount())
        return false;
    for (int i = 0; i < argc; i++) {
        if (!VerifyType.isNullConversion(newType.parameterType(i), parameterType(i), keepInterfaces))
            return false;
    }
    return true;
}
 
Example 2
Source File: MethodType.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/** True if the new parameters can be viewed (w/o casting) under the old parameter types. */
/*non-public*/
boolean parametersAreViewableAs(MethodType newType, boolean keepInterfaces) {
    if (form == newType.form && form.erasedType == this)
        return true;  // my reference parameters are all Object
    if (ptypes == newType.ptypes)
        return true;
    int argc = parameterCount();
    if (argc != newType.parameterCount())
        return false;
    for (int i = 0; i < argc; i++) {
        if (!VerifyType.isNullConversion(newType.parameterType(i), parameterType(i), keepInterfaces))
            return false;
    }
    return true;
}
 
Example 3
Source File: MethodType.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/** True if the new parameters can be viewed (w/o casting) under the old parameter types. */
/*non-public*/
boolean parametersAreViewableAs(MethodType newType, boolean keepInterfaces) {
    if (form == newType.form && form.erasedType == this)
        return true;  // my reference parameters are all Object
    if (ptypes == newType.ptypes)
        return true;
    int argc = parameterCount();
    if (argc != newType.parameterCount())
        return false;
    for (int i = 0; i < argc; i++) {
        if (!VerifyType.isNullConversion(newType.parameterType(i), parameterType(i), keepInterfaces))
            return false;
    }
    return true;
}
 
Example 4
Source File: InvokerBytecodeGenerator.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Emit an implicit conversion for an argument which must be of the given pclass.
 * This is usually a no-op, except when pclass is a subword type or a reference other than Object or an interface.
 *
 * @param ptype type of value present on stack
 * @param pclass type of value required on stack
 * @param arg compile-time representation of value on stack (Node, constant) or null if none
 */
private void emitImplicitConversion(BasicType ptype, Class<?> pclass, Object arg) {
    assert(basicType(pclass) == ptype);  // boxing/unboxing handled by caller
    if (pclass == ptype.basicTypeClass() && ptype != L_TYPE)
        return;   // nothing to do
    switch (ptype) {
        case L_TYPE:
            if (VerifyType.isNullConversion(Object.class, pclass, false)) {
                if (PROFILE_LEVEL > 0)
                    emitReferenceCast(Object.class, arg);
                return;
            }
            emitReferenceCast(pclass, arg);
            return;
        case I_TYPE:
            if (!VerifyType.isNullConversion(int.class, pclass, false))
                emitPrimCast(ptype.basicTypeWrapper(), Wrapper.forPrimitiveType(pclass));
            return;
    }
    throw newInternalError("bad implicit conversion: tc="+ptype+": "+pclass);
}
 
Example 5
Source File: InvokerBytecodeGenerator.java    From Java8CN with Apache License 2.0 6 votes vote down vote up
/**
 * Emit an implicit conversion for an argument which must be of the given pclass.
 * This is usually a no-op, except when pclass is a subword type or a reference other than Object or an interface.
 *
 * @param ptype type of value present on stack
 * @param pclass type of value required on stack
 * @param arg compile-time representation of value on stack (Node, constant) or null if none
 */
private void emitImplicitConversion(BasicType ptype, Class<?> pclass, Object arg) {
    assert(basicType(pclass) == ptype);  // boxing/unboxing handled by caller
    if (pclass == ptype.basicTypeClass() && ptype != L_TYPE)
        return;   // nothing to do
    switch (ptype) {
        case L_TYPE:
            if (VerifyType.isNullConversion(Object.class, pclass, false)) {
                if (PROFILE_LEVEL > 0)
                    emitReferenceCast(Object.class, arg);
                return;
            }
            emitReferenceCast(pclass, arg);
            return;
        case I_TYPE:
            if (!VerifyType.isNullConversion(int.class, pclass, false))
                emitPrimCast(ptype.basicTypeWrapper(), Wrapper.forPrimitiveType(pclass));
            return;
    }
    throw newInternalError("bad implicit conversion: tc="+ptype+": "+pclass);
}
 
Example 6
Source File: InvokerBytecodeGenerator.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Emit an implicit conversion for an argument which must be of the given pclass.
 * This is usually a no-op, except when pclass is a subword type or a reference other than Object or an interface.
 *
 * @param ptype type of value present on stack
 * @param pclass type of value required on stack
 * @param arg compile-time representation of value on stack (Node, constant) or null if none
 */
private void emitImplicitConversion(BasicType ptype, Class<?> pclass, Object arg) {
    assert(basicType(pclass) == ptype);  // boxing/unboxing handled by caller
    if (pclass == ptype.basicTypeClass() && ptype != L_TYPE)
        return;   // nothing to do
    switch (ptype) {
        case L_TYPE:
            if (VerifyType.isNullConversion(Object.class, pclass, false)) {
                if (PROFILE_LEVEL > 0)
                    emitReferenceCast(Object.class, arg);
                return;
            }
            emitReferenceCast(pclass, arg);
            return;
        case I_TYPE:
            if (!VerifyType.isNullConversion(int.class, pclass, false))
                emitPrimCast(ptype.basicTypeWrapper(), Wrapper.forPrimitiveType(pclass));
            return;
    }
    throw newInternalError("bad implicit conversion: tc="+ptype+": "+pclass);
}
 
Example 7
Source File: MethodType.java    From Java8CN with Apache License 2.0 6 votes vote down vote up
/** True if the new parameters can be viewed (w/o casting) under the old parameter types. */
/*non-public*/
boolean parametersAreViewableAs(MethodType newType, boolean keepInterfaces) {
    if (form == newType.form && form.erasedType == this)
        return true;  // my reference parameters are all Object
    if (ptypes == newType.ptypes)
        return true;
    int argc = parameterCount();
    if (argc != newType.parameterCount())
        return false;
    for (int i = 0; i < argc; i++) {
        if (!VerifyType.isNullConversion(newType.parameterType(i), parameterType(i), keepInterfaces))
            return false;
    }
    return true;
}
 
Example 8
Source File: MethodType.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/** True if the old return type can always be viewed (w/o casting) under new return type,
 *  and the new parameters can be viewed (w/o casting) under the old parameter types.
 */
/*non-public*/
boolean isViewableAs(MethodType newType, boolean keepInterfaces) {
    if (!VerifyType.isNullConversion(returnType(), newType.returnType(), keepInterfaces))
        return false;
    return parametersAreViewableAs(newType, keepInterfaces);
}
 
Example 9
Source File: MethodHandleImpl.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
static Object[] computeValueConversions(MethodType srcType, MethodType dstType,
                                        boolean strict, boolean monobox) {
    final int INARG_COUNT = srcType.parameterCount();
    Object[] convSpecs = new Object[INARG_COUNT+1];
    for (int i = 0; i <= INARG_COUNT; i++) {
        boolean isRet = (i == INARG_COUNT);
        Class<?> src = isRet ? dstType.returnType() : srcType.parameterType(i);
        Class<?> dst = isRet ? srcType.returnType() : dstType.parameterType(i);
        if (!VerifyType.isNullConversion(src, dst, /*keepInterfaces=*/ strict)) {
            convSpecs[i] = valueConversion(src, dst, strict, monobox);
        }
    }
    return convSpecs;
}
 
Example 10
Source File: MethodHandleImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
static Object[] computeValueConversions(MethodType srcType, MethodType dstType,
                                        boolean strict, boolean monobox) {
    final int INARG_COUNT = srcType.parameterCount();
    Object[] convSpecs = new Object[INARG_COUNT+1];
    for (int i = 0; i <= INARG_COUNT; i++) {
        boolean isRet = (i == INARG_COUNT);
        Class<?> src = isRet ? dstType.returnType() : srcType.parameterType(i);
        Class<?> dst = isRet ? srcType.returnType() : dstType.parameterType(i);
        if (!VerifyType.isNullConversion(src, dst, /*keepInterfaces=*/ strict)) {
            convSpecs[i] = valueConversion(src, dst, strict, monobox);
        }
    }
    return convSpecs;
}
 
Example 11
Source File: MethodType.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/** True if the old return type can always be viewed (w/o casting) under new return type,
 *  and the new parameters can be viewed (w/o casting) under the old parameter types.
 */
/*non-public*/
boolean isViewableAs(MethodType newType, boolean keepInterfaces) {
    if (!VerifyType.isNullConversion(returnType(), newType.returnType(), keepInterfaces))
        return false;
    return parametersAreViewableAs(newType, keepInterfaces);
}
 
Example 12
Source File: MethodHandleImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
static Object[] computeValueConversions(MethodType srcType, MethodType dstType,
                                        boolean strict, boolean monobox) {
    final int INARG_COUNT = srcType.parameterCount();
    Object[] convSpecs = new Object[INARG_COUNT+1];
    for (int i = 0; i <= INARG_COUNT; i++) {
        boolean isRet = (i == INARG_COUNT);
        Class<?> src = isRet ? dstType.returnType() : srcType.parameterType(i);
        Class<?> dst = isRet ? srcType.returnType() : dstType.parameterType(i);
        if (!VerifyType.isNullConversion(src, dst, /*keepInterfaces=*/ strict)) {
            convSpecs[i] = valueConversion(src, dst, strict, monobox);
        }
    }
    return convSpecs;
}
 
Example 13
Source File: MethodType.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/** True if the old return type can always be viewed (w/o casting) under new return type,
 *  and the new parameters can be viewed (w/o casting) under the old parameter types.
 */
/*non-public*/
boolean isViewableAs(MethodType newType, boolean keepInterfaces) {
    if (!VerifyType.isNullConversion(returnType(), newType.returnType(), keepInterfaces))
        return false;
    return parametersAreViewableAs(newType, keepInterfaces);
}
 
Example 14
Source File: InvokerBytecodeGenerator.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Emit an implicit conversion.
 *
 * @param ptype type of value present on stack
 * @param pclass type of value required on stack
 */
private void emitImplicitConversion(char ptype, Class<?> pclass) {
    switch (ptype) {
    case 'L':
        if (VerifyType.isNullConversion(Object.class, pclass))
            return;
        if (isStaticallyNameable(pclass)) {
            mv.visitTypeInsn(Opcodes.CHECKCAST, getInternalName(pclass));
        } else {
            mv.visitLdcInsn(constantPlaceholder(pclass));
            mv.visitTypeInsn(Opcodes.CHECKCAST, CLS);
            mv.visitInsn(Opcodes.SWAP);
            mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, CLS, "cast", LL_SIG);
            if (pclass.isArray())
                mv.visitTypeInsn(Opcodes.CHECKCAST, OBJARY);
        }
        return;
    case 'I':
        if (!VerifyType.isNullConversion(int.class, pclass))
            emitPrimCast(ptype, Wrapper.basicTypeChar(pclass));
        return;
    case 'J':
        assert(pclass == long.class);
        return;
    case 'F':
        assert(pclass == float.class);
        return;
    case 'D':
        assert(pclass == double.class);
        return;
    }
    throw new InternalError("bad implicit conversion: tc="+ptype+": "+pclass);
}
 
Example 15
Source File: MethodType.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/** True if the old return type can always be viewed (w/o casting) under new return type,
 *  and the new parameters can be viewed (w/o casting) under the old parameter types.
 */
/*non-public*/
boolean isViewableAs(MethodType newType, boolean keepInterfaces) {
    if (!VerifyType.isNullConversion(returnType(), newType.returnType(), keepInterfaces))
        return false;
    return parametersAreViewableAs(newType, keepInterfaces);
}
 
Example 16
Source File: MethodHandleImpl.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
static Object[] computeValueConversions(MethodType srcType, MethodType dstType,
                                        boolean strict, boolean monobox) {
    final int INARG_COUNT = srcType.parameterCount();
    Object[] convSpecs = new Object[INARG_COUNT+1];
    for (int i = 0; i <= INARG_COUNT; i++) {
        boolean isRet = (i == INARG_COUNT);
        Class<?> src = isRet ? dstType.returnType() : srcType.parameterType(i);
        Class<?> dst = isRet ? srcType.returnType() : dstType.parameterType(i);
        if (!VerifyType.isNullConversion(src, dst, /*keepInterfaces=*/ strict)) {
            convSpecs[i] = valueConversion(src, dst, strict, monobox);
        }
    }
    return convSpecs;
}
 
Example 17
Source File: MethodHandleImpl.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static Object[] computeValueConversions(MethodType srcType, MethodType dstType,
                                        boolean strict, boolean monobox) {
    final int INARG_COUNT = srcType.parameterCount();
    Object[] convSpecs = new Object[INARG_COUNT+1];
    for (int i = 0; i <= INARG_COUNT; i++) {
        boolean isRet = (i == INARG_COUNT);
        Class<?> src = isRet ? dstType.returnType() : srcType.parameterType(i);
        Class<?> dst = isRet ? srcType.returnType() : dstType.parameterType(i);
        if (!VerifyType.isNullConversion(src, dst, /*keepInterfaces=*/ strict)) {
            convSpecs[i] = valueConversion(src, dst, strict, monobox);
        }
    }
    return convSpecs;
}
 
Example 18
Source File: MethodType.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/** True if the old return type can always be viewed (w/o casting) under new return type,
 *  and the new parameters can be viewed (w/o casting) under the old parameter types.
 */
/*non-public*/
boolean isViewableAs(MethodType newType, boolean keepInterfaces) {
    if (!VerifyType.isNullConversion(returnType(), newType.returnType(), keepInterfaces))
        return false;
    return parametersAreViewableAs(newType, keepInterfaces);
}
 
Example 19
Source File: MethodType.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/** True if the old return type can always be viewed (w/o casting) under new return type,
 *  and the new parameters can be viewed (w/o casting) under the old parameter types.
 */
/*non-public*/
boolean isViewableAs(MethodType newType, boolean keepInterfaces) {
    if (!VerifyType.isNullConversion(returnType(), newType.returnType(), keepInterfaces))
        return false;
    return parametersAreViewableAs(newType, keepInterfaces);
}
 
Example 20
Source File: MethodHandleImpl.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static Object[] computeValueConversions(MethodType srcType, MethodType dstType,
                                        boolean strict, boolean monobox) {
    final int INARG_COUNT = srcType.parameterCount();
    Object[] convSpecs = new Object[INARG_COUNT+1];
    for (int i = 0; i <= INARG_COUNT; i++) {
        boolean isRet = (i == INARG_COUNT);
        Class<?> src = isRet ? dstType.returnType() : srcType.parameterType(i);
        Class<?> dst = isRet ? srcType.returnType() : dstType.parameterType(i);
        if (!VerifyType.isNullConversion(src, dst, /*keepInterfaces=*/ strict)) {
            convSpecs[i] = valueConversion(src, dst, strict, monobox);
        }
    }
    return convSpecs;
}