Java Code Examples for sun.invoke.util.ValueConversions#ignore()

The following examples show how to use sun.invoke.util.ValueConversions#ignore() . 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: MethodHandleImpl.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
static
MethodHandle makeGuardWithCatch(MethodHandle target,
                                Class<? extends Throwable> exType,
                                MethodHandle catcher) {
    MethodType type = target.type();
    LambdaForm form = makeGuardWithCatchForm(type.basicType());

    // Prepare auxiliary method handles used during LambdaForm interpreation.
    // Box arguments and wrap them into Object[]: ValueConversions.array().
    MethodType varargsType = type.changeReturnType(Object[].class);
    MethodHandle collectArgs = varargsArray(type.parameterCount()).asType(varargsType);
    // Result unboxing: ValueConversions.unbox() OR ValueConversions.identity() OR ValueConversions.ignore().
    MethodHandle unboxResult;
    Class<?> rtype = type.returnType();
    if (rtype.isPrimitive()) {
        if (rtype == void.class) {
            unboxResult = ValueConversions.ignore();
        } else {
            Wrapper w = Wrapper.forPrimitiveType(type.returnType());
            unboxResult = ValueConversions.unboxExact(w);
        }
    } else {
        unboxResult = MethodHandles.identity(Object.class);
    }

    BoundMethodHandle.SpeciesData data = BoundMethodHandle.speciesData_LLLLL();
    BoundMethodHandle mh;
    try {
        mh = (BoundMethodHandle)
                data.constructor().invokeBasic(type, form, (Object) target, (Object) exType, (Object) catcher,
                                               (Object) collectArgs, (Object) unboxResult);
    } catch (Throwable ex) {
        throw uncaughtException(ex);
    }
    assert(mh.type() == type);
    return mh;
}
 
Example 2
Source File: MethodHandleImpl.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
static
MethodHandle makeGuardWithCatch(MethodHandle target,
                                Class<? extends Throwable> exType,
                                MethodHandle catcher) {
    MethodType type = target.type();
    LambdaForm form = makeGuardWithCatchForm(type.basicType());

    // Prepare auxiliary method handles used during LambdaForm interpreation.
    // Box arguments and wrap them into Object[]: ValueConversions.array().
    MethodType varargsType = type.changeReturnType(Object[].class);
    MethodHandle collectArgs = varargsArray(type.parameterCount()).asType(varargsType);
    // Result unboxing: ValueConversions.unbox() OR ValueConversions.identity() OR ValueConversions.ignore().
    MethodHandle unboxResult;
    Class<?> rtype = type.returnType();
    if (rtype.isPrimitive()) {
        if (rtype == void.class) {
            unboxResult = ValueConversions.ignore();
        } else {
            Wrapper w = Wrapper.forPrimitiveType(type.returnType());
            unboxResult = ValueConversions.unboxExact(w);
        }
    } else {
        unboxResult = MethodHandles.identity(Object.class);
    }

    BoundMethodHandle.SpeciesData data = BoundMethodHandle.speciesData_LLLLL();
    BoundMethodHandle mh;
    try {
        mh = (BoundMethodHandle)
                data.constructor().invokeBasic(type, form, (Object) target, (Object) exType, (Object) catcher,
                                               (Object) collectArgs, (Object) unboxResult);
    } catch (Throwable ex) {
        throw uncaughtException(ex);
    }
    assert(mh.type() == type);
    return mh;
}
 
Example 3
Source File: MethodHandleImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
static
MethodHandle makeGuardWithCatch(MethodHandle target,
                                Class<? extends Throwable> exType,
                                MethodHandle catcher) {
    MethodType type = target.type();
    LambdaForm form = makeGuardWithCatchForm(type.basicType());

    // Prepare auxiliary method handles used during LambdaForm interpreation.
    // Box arguments and wrap them into Object[]: ValueConversions.array().
    MethodType varargsType = type.changeReturnType(Object[].class);
    MethodHandle collectArgs = varargsArray(type.parameterCount()).asType(varargsType);
    // Result unboxing: ValueConversions.unbox() OR ValueConversions.identity() OR ValueConversions.ignore().
    MethodHandle unboxResult;
    Class<?> rtype = type.returnType();
    if (rtype.isPrimitive()) {
        if (rtype == void.class) {
            unboxResult = ValueConversions.ignore();
        } else {
            Wrapper w = Wrapper.forPrimitiveType(type.returnType());
            unboxResult = ValueConversions.unboxExact(w);
        }
    } else {
        unboxResult = MethodHandles.identity(Object.class);
    }

    BoundMethodHandle.SpeciesData data = BoundMethodHandle.speciesData_LLLLL();
    BoundMethodHandle mh;
    try {
        mh = (BoundMethodHandle)
                data.constructor().invokeBasic(type, form, (Object) target, (Object) exType, (Object) catcher,
                                               (Object) collectArgs, (Object) unboxResult);
    } catch (Throwable ex) {
        throw uncaughtException(ex);
    }
    assert(mh.type() == type);
    return mh;
}
 
Example 4
Source File: MethodHandleImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
static
MethodHandle makeGuardWithCatch(MethodHandle target,
                                Class<? extends Throwable> exType,
                                MethodHandle catcher) {
    MethodType type = target.type();
    LambdaForm form = makeGuardWithCatchForm(type.basicType());

    // Prepare auxiliary method handles used during LambdaForm interpreation.
    // Box arguments and wrap them into Object[]: ValueConversions.array().
    MethodType varargsType = type.changeReturnType(Object[].class);
    MethodHandle collectArgs = varargsArray(type.parameterCount()).asType(varargsType);
    // Result unboxing: ValueConversions.unbox() OR ValueConversions.identity() OR ValueConversions.ignore().
    MethodHandle unboxResult;
    Class<?> rtype = type.returnType();
    if (rtype.isPrimitive()) {
        if (rtype == void.class) {
            unboxResult = ValueConversions.ignore();
        } else {
            Wrapper w = Wrapper.forPrimitiveType(type.returnType());
            unboxResult = ValueConversions.unboxExact(w);
        }
    } else {
        unboxResult = MethodHandles.identity(Object.class);
    }

    BoundMethodHandle.SpeciesData data = BoundMethodHandle.speciesData_LLLLL();
    BoundMethodHandle mh;
    try {
        mh = (BoundMethodHandle)
                data.constructor().invokeBasic(type, form, (Object) target, (Object) exType, (Object) catcher,
                                               (Object) collectArgs, (Object) unboxResult);
    } catch (Throwable ex) {
        throw uncaughtException(ex);
    }
    assert(mh.type() == type);
    return mh;
}
 
Example 5
Source File: MethodHandleImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
static
MethodHandle makeGuardWithCatch(MethodHandle target,
                                Class<? extends Throwable> exType,
                                MethodHandle catcher) {
    MethodType type = target.type();
    LambdaForm form = makeGuardWithCatchForm(type.basicType());

    // Prepare auxiliary method handles used during LambdaForm interpreation.
    // Box arguments and wrap them into Object[]: ValueConversions.array().
    MethodType varargsType = type.changeReturnType(Object[].class);
    MethodHandle collectArgs = varargsArray(type.parameterCount()).asType(varargsType);
    // Result unboxing: ValueConversions.unbox() OR ValueConversions.identity() OR ValueConversions.ignore().
    MethodHandle unboxResult;
    Class<?> rtype = type.returnType();
    if (rtype.isPrimitive()) {
        if (rtype == void.class) {
            unboxResult = ValueConversions.ignore();
        } else {
            Wrapper w = Wrapper.forPrimitiveType(type.returnType());
            unboxResult = ValueConversions.unboxExact(w);
        }
    } else {
        unboxResult = MethodHandles.identity(Object.class);
    }

    BoundMethodHandle.SpeciesData data = BoundMethodHandle.speciesData_LLLLL();
    BoundMethodHandle mh;
    try {
        mh = (BoundMethodHandle)
                data.constructor().invokeBasic(type, form, (Object) target, (Object) exType, (Object) catcher,
                                               (Object) collectArgs, (Object) unboxResult);
    } catch (Throwable ex) {
        throw uncaughtException(ex);
    }
    assert(mh.type() == type);
    return mh;
}
 
Example 6
Source File: MethodHandleImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
static
MethodHandle makeGuardWithCatch(MethodHandle target,
                                Class<? extends Throwable> exType,
                                MethodHandle catcher) {
    MethodType type = target.type();
    LambdaForm form = makeGuardWithCatchForm(type.basicType());

    // Prepare auxiliary method handles used during LambdaForm interpreation.
    // Box arguments and wrap them into Object[]: ValueConversions.array().
    MethodType varargsType = type.changeReturnType(Object[].class);
    MethodHandle collectArgs = varargsArray(type.parameterCount()).asType(varargsType);
    // Result unboxing: ValueConversions.unbox() OR ValueConversions.identity() OR ValueConversions.ignore().
    MethodHandle unboxResult;
    Class<?> rtype = type.returnType();
    if (rtype.isPrimitive()) {
        if (rtype == void.class) {
            unboxResult = ValueConversions.ignore();
        } else {
            Wrapper w = Wrapper.forPrimitiveType(type.returnType());
            unboxResult = ValueConversions.unboxExact(w);
        }
    } else {
        unboxResult = MethodHandles.identity(Object.class);
    }

    BoundMethodHandle.SpeciesData data = BoundMethodHandle.speciesData_LLLLL();
    BoundMethodHandle mh;
    try {
        mh = (BoundMethodHandle)
                data.constructor().invokeBasic(type, form, (Object) target, (Object) exType, (Object) catcher,
                                               (Object) collectArgs, (Object) unboxResult);
    } catch (Throwable ex) {
        throw uncaughtException(ex);
    }
    assert(mh.type() == type);
    return mh;
}
 
Example 7
Source File: MethodHandleImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
static
MethodHandle makeGuardWithCatch(MethodHandle target,
                                Class<? extends Throwable> exType,
                                MethodHandle catcher) {
    MethodType type = target.type();
    LambdaForm form = makeGuardWithCatchForm(type.basicType());

    // Prepare auxiliary method handles used during LambdaForm interpreation.
    // Box arguments and wrap them into Object[]: ValueConversions.array().
    MethodType varargsType = type.changeReturnType(Object[].class);
    MethodHandle collectArgs = varargsArray(type.parameterCount()).asType(varargsType);
    // Result unboxing: ValueConversions.unbox() OR ValueConversions.identity() OR ValueConversions.ignore().
    MethodHandle unboxResult;
    Class<?> rtype = type.returnType();
    if (rtype.isPrimitive()) {
        if (rtype == void.class) {
            unboxResult = ValueConversions.ignore();
        } else {
            Wrapper w = Wrapper.forPrimitiveType(type.returnType());
            unboxResult = ValueConversions.unboxExact(w);
        }
    } else {
        unboxResult = MethodHandles.identity(Object.class);
    }

    BoundMethodHandle.SpeciesData data = BoundMethodHandle.speciesData_LLLLL();
    BoundMethodHandle mh;
    try {
        mh = (BoundMethodHandle)
                data.constructor().invokeBasic(type, form, (Object) target, (Object) exType, (Object) catcher,
                                               (Object) collectArgs, (Object) unboxResult);
    } catch (Throwable ex) {
        throw uncaughtException(ex);
    }
    assert(mh.type() == type);
    return mh;
}
 
Example 8
Source File: MethodHandleImpl.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/** Result unboxing: ValueConversions.unbox() OR ValueConversions.identity() OR ValueConversions.ignore(). */
private static MethodHandle unboxResultHandle(Class<?> returnType) {
    if (returnType.isPrimitive()) {
        if (returnType == void.class) {
            return ValueConversions.ignore();
        } else {
            Wrapper w = Wrapper.forPrimitiveType(returnType);
            return ValueConversions.unboxExact(w);
        }
    } else {
        return MethodHandles.identity(Object.class);
    }
}
 
Example 9
Source File: MethodHandleImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/** Result unboxing: ValueConversions.unbox() OR ValueConversions.identity() OR ValueConversions.ignore(). */
private static MethodHandle unboxResultHandle(Class<?> returnType) {
    if (returnType.isPrimitive()) {
        if (returnType == void.class) {
            return ValueConversions.ignore();
        } else {
            Wrapper w = Wrapper.forPrimitiveType(returnType);
            return ValueConversions.unboxExact(w);
        }
    } else {
        return MethodHandles.identity(Object.class);
    }
}
 
Example 10
Source File: MethodHandleImpl.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static
MethodHandle makeGuardWithCatch(MethodHandle target,
                                Class<? extends Throwable> exType,
                                MethodHandle catcher) {
    MethodType type = target.type();
    LambdaForm form = makeGuardWithCatchForm(type.basicType());

    // Prepare auxiliary method handles used during LambdaForm interpreation.
    // Box arguments and wrap them into Object[]: ValueConversions.array().
    MethodType varargsType = type.changeReturnType(Object[].class);
    MethodHandle collectArgs = varargsArray(type.parameterCount()).asType(varargsType);
    // Result unboxing: ValueConversions.unbox() OR ValueConversions.identity() OR ValueConversions.ignore().
    MethodHandle unboxResult;
    Class<?> rtype = type.returnType();
    if (rtype.isPrimitive()) {
        if (rtype == void.class) {
            unboxResult = ValueConversions.ignore();
        } else {
            Wrapper w = Wrapper.forPrimitiveType(type.returnType());
            unboxResult = ValueConversions.unboxExact(w);
        }
    } else {
        unboxResult = MethodHandles.identity(Object.class);
    }

    BoundMethodHandle.SpeciesData data = BoundMethodHandle.speciesData_LLLLL();
    BoundMethodHandle mh;
    try {
        mh = (BoundMethodHandle)
                data.constructor().invokeBasic(type, form, (Object) target, (Object) exType, (Object) catcher,
                                               (Object) collectArgs, (Object) unboxResult);
    } catch (Throwable ex) {
        throw uncaughtException(ex);
    }
    assert(mh.type() == type);
    return mh;
}
 
Example 11
Source File: MethodHandleImpl.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
static
MethodHandle makeGuardWithCatch(MethodHandle target,
                                Class<? extends Throwable> exType,
                                MethodHandle catcher) {
    MethodType type = target.type();
    LambdaForm form = makeGuardWithCatchForm(type.basicType());

    // Prepare auxiliary method handles used during LambdaForm interpreation.
    // Box arguments and wrap them into Object[]: ValueConversions.array().
    MethodType varargsType = type.changeReturnType(Object[].class);
    MethodHandle collectArgs = varargsArray(type.parameterCount()).asType(varargsType);
    // Result unboxing: ValueConversions.unbox() OR ValueConversions.identity() OR ValueConversions.ignore().
    MethodHandle unboxResult;
    Class<?> rtype = type.returnType();
    if (rtype.isPrimitive()) {
        if (rtype == void.class) {
            unboxResult = ValueConversions.ignore();
        } else {
            Wrapper w = Wrapper.forPrimitiveType(type.returnType());
            unboxResult = ValueConversions.unboxExact(w);
        }
    } else {
        unboxResult = MethodHandles.identity(Object.class);
    }

    BoundMethodHandle.SpeciesData data = BoundMethodHandle.speciesData_LLLLL();
    BoundMethodHandle mh;
    try {
        mh = (BoundMethodHandle)
                data.constructor().invokeBasic(type, form, (Object) target, (Object) exType, (Object) catcher,
                                               (Object) collectArgs, (Object) unboxResult);
    } catch (Throwable ex) {
        throw uncaughtException(ex);
    }
    assert(mh.type() == type);
    return mh;
}
 
Example 12
Source File: MethodHandleImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
static
MethodHandle makeGuardWithCatch(MethodHandle target,
                                Class<? extends Throwable> exType,
                                MethodHandle catcher) {
    MethodType type = target.type();
    LambdaForm form = makeGuardWithCatchForm(type.basicType());

    // Prepare auxiliary method handles used during LambdaForm interpreation.
    // Box arguments and wrap them into Object[]: ValueConversions.array().
    MethodType varargsType = type.changeReturnType(Object[].class);
    MethodHandle collectArgs = varargsArray(type.parameterCount()).asType(varargsType);
    // Result unboxing: ValueConversions.unbox() OR ValueConversions.identity() OR ValueConversions.ignore().
    MethodHandle unboxResult;
    Class<?> rtype = type.returnType();
    if (rtype.isPrimitive()) {
        if (rtype == void.class) {
            unboxResult = ValueConversions.ignore();
        } else {
            Wrapper w = Wrapper.forPrimitiveType(type.returnType());
            unboxResult = ValueConversions.unboxExact(w);
        }
    } else {
        unboxResult = MethodHandles.identity(Object.class);
    }

    BoundMethodHandle.SpeciesData data = BoundMethodHandle.speciesData_LLLLL();
    BoundMethodHandle mh;
    try {
        mh = (BoundMethodHandle)
                data.constructor().invokeBasic(type, form, (Object) target, (Object) exType, (Object) catcher,
                                               (Object) collectArgs, (Object) unboxResult);
    } catch (Throwable ex) {
        throw uncaughtException(ex);
    }
    assert(mh.type() == type);
    return mh;
}
 
Example 13
Source File: MethodHandleImpl.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
static
MethodHandle makeGuardWithCatch(MethodHandle target,
                                Class<? extends Throwable> exType,
                                MethodHandle catcher) {
    MethodType type = target.type();
    LambdaForm form = makeGuardWithCatchForm(type.basicType());

    // Prepare auxiliary method handles used during LambdaForm interpreation.
    // Box arguments and wrap them into Object[]: ValueConversions.array().
    MethodType varargsType = type.changeReturnType(Object[].class);
    MethodHandle collectArgs = varargsArray(type.parameterCount()).asType(varargsType);
    // Result unboxing: ValueConversions.unbox() OR ValueConversions.identity() OR ValueConversions.ignore().
    MethodHandle unboxResult;
    Class<?> rtype = type.returnType();
    if (rtype.isPrimitive()) {
        if (rtype == void.class) {
            unboxResult = ValueConversions.ignore();
        } else {
            Wrapper w = Wrapper.forPrimitiveType(type.returnType());
            unboxResult = ValueConversions.unboxExact(w);
        }
    } else {
        unboxResult = MethodHandles.identity(Object.class);
    }

    BoundMethodHandle.SpeciesData data = BoundMethodHandle.speciesData_LLLLL();
    BoundMethodHandle mh;
    try {
        mh = (BoundMethodHandle)
                data.constructor().invokeBasic(type, form, (Object) target, (Object) exType, (Object) catcher,
                                               (Object) collectArgs, (Object) unboxResult);
    } catch (Throwable ex) {
        throw uncaughtException(ex);
    }
    assert(mh.type() == type);
    return mh;
}
 
Example 14
Source File: MethodHandleImpl.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static
MethodHandle makeGuardWithCatch(MethodHandle target,
                                Class<? extends Throwable> exType,
                                MethodHandle catcher) {
    MethodType type = target.type();
    LambdaForm form = makeGuardWithCatchForm(type.basicType());

    // Prepare auxiliary method handles used during LambdaForm interpreation.
    // Box arguments and wrap them into Object[]: ValueConversions.array().
    MethodType varargsType = type.changeReturnType(Object[].class);
    MethodHandle collectArgs = varargsArray(type.parameterCount()).asType(varargsType);
    // Result unboxing: ValueConversions.unbox() OR ValueConversions.identity() OR ValueConversions.ignore().
    MethodHandle unboxResult;
    Class<?> rtype = type.returnType();
    if (rtype.isPrimitive()) {
        if (rtype == void.class) {
            unboxResult = ValueConversions.ignore();
        } else {
            Wrapper w = Wrapper.forPrimitiveType(type.returnType());
            unboxResult = ValueConversions.unboxExact(w);
        }
    } else {
        unboxResult = MethodHandles.identity(Object.class);
    }

    BoundMethodHandle.SpeciesData data = BoundMethodHandle.speciesData_LLLLL();
    BoundMethodHandle mh;
    try {
        mh = (BoundMethodHandle)
                data.constructor().invokeBasic(type, form, (Object) target, (Object) exType, (Object) catcher,
                                               (Object) collectArgs, (Object) unboxResult);
    } catch (Throwable ex) {
        throw uncaughtException(ex);
    }
    assert(mh.type() == type);
    return mh;
}
 
Example 15
Source File: MethodHandleImpl.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
static
MethodHandle makeGuardWithCatch(MethodHandle target,
                                Class<? extends Throwable> exType,
                                MethodHandle catcher) {
    MethodType type = target.type();
    LambdaForm form = makeGuardWithCatchForm(type.basicType());

    // Prepare auxiliary method handles used during LambdaForm interpreation.
    // Box arguments and wrap them into Object[]: ValueConversions.array().
    MethodType varargsType = type.changeReturnType(Object[].class);
    MethodHandle collectArgs = varargsArray(type.parameterCount()).asType(varargsType);
    // Result unboxing: ValueConversions.unbox() OR ValueConversions.identity() OR ValueConversions.ignore().
    MethodHandle unboxResult;
    Class<?> rtype = type.returnType();
    if (rtype.isPrimitive()) {
        if (rtype == void.class) {
            unboxResult = ValueConversions.ignore();
        } else {
            Wrapper w = Wrapper.forPrimitiveType(type.returnType());
            unboxResult = ValueConversions.unboxExact(w);
        }
    } else {
        unboxResult = MethodHandles.identity(Object.class);
    }

    BoundMethodHandle.SpeciesData data = BoundMethodHandle.speciesData_LLLLL();
    BoundMethodHandle mh;
    try {
        mh = (BoundMethodHandle)
                data.constructor().invokeBasic(type, form, (Object) target, (Object) exType, (Object) catcher,
                                               (Object) collectArgs, (Object) unboxResult);
    } catch (Throwable ex) {
        throw uncaughtException(ex);
    }
    assert(mh.type() == type);
    return mh;
}