Java Code Examples for java.lang.invoke.MethodHandle#asVarargsCollector()
The following examples show how to use
java.lang.invoke.MethodHandle#asVarargsCollector() .
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: CatchExceptionTest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public CatchExceptionTest(TestCase testCase, final boolean isVararg, final int argsCount, final int catchDrops) { this.testCase = testCase; this.dropped = catchDrops; MethodHandle thrower = testCase.thrower; int throwerLen = thrower.type().parameterCount(); List<Class<?>> classes; int extra = Math.max(0, argsCount - throwerLen); classes = getThrowerParams(isVararg, extra); this.argsCount = throwerLen + classes.size(); thrower = Helper.addTrailingArgs(thrower, this.argsCount, classes); if (isVararg && argsCount > throwerLen) { MethodType mt = thrower.type(); Class<?> lastParam = mt.parameterType(mt.parameterCount() - 1); thrower = thrower.asVarargsCollector(lastParam); } this.thrower = thrower; this.dropped = Math.min(this.argsCount, catchDrops); catcher = testCase.getCatcher(getCatcherParams()); nargs = Math.max(2, this.argsCount); }
Example 2
Source File: CatchExceptionTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public CatchExceptionTest(TestCase testCase, final boolean isVararg, final int argsCount, final int catchDrops) { this.testCase = testCase; this.dropped = catchDrops; MethodHandle thrower = testCase.thrower; int throwerLen = thrower.type().parameterCount(); List<Class<?>> classes; int extra = Math.max(0, argsCount - throwerLen); classes = getThrowerParams(isVararg, extra); this.argsCount = throwerLen + classes.size(); thrower = Helper.addTrailingArgs(thrower, this.argsCount, classes); if (isVararg && argsCount > throwerLen) { MethodType mt = thrower.type(); Class<?> lastParam = mt.parameterType(mt.parameterCount() - 1); thrower = thrower.asVarargsCollector(lastParam); } this.thrower = thrower; this.dropped = Math.min(this.argsCount, catchDrops); catcher = testCase.getCatcher(getCatcherParams()); nargs = Math.max(2, this.argsCount); }
Example 3
Source File: CatchExceptionTest.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public CatchExceptionTest(TestCase testCase, final boolean isVararg, final int argsCount, final int catchDrops) { this.testCase = testCase; this.dropped = catchDrops; MethodHandle thrower = testCase.thrower; int throwerLen = thrower.type().parameterCount(); List<Class<?>> classes; int extra = Math.max(0, argsCount - throwerLen); classes = getThrowerParams(isVararg, extra); this.argsCount = throwerLen + classes.size(); thrower = Helper.addTrailingArgs(thrower, this.argsCount, classes); if (isVararg && argsCount > throwerLen) { MethodType mt = thrower.type(); Class<?> lastParam = mt.parameterType(mt.parameterCount() - 1); thrower = thrower.asVarargsCollector(lastParam); } this.thrower = thrower; this.dropped = Math.min(this.argsCount, catchDrops); catcher = testCase.getCatcher(getCatcherParams()); nargs = Math.max(2, this.argsCount); }
Example 4
Source File: CatchExceptionTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public CatchExceptionTest(TestCase testCase, final boolean isVararg, final int argsCount, final int catchDrops) { this.testCase = testCase; this.dropped = catchDrops; MethodHandle thrower = testCase.thrower; int throwerLen = thrower.type().parameterCount(); List<Class<?>> classes; int extra = Math.max(0, argsCount - throwerLen); classes = getThrowerParams(isVararg, extra); this.argsCount = throwerLen + classes.size(); thrower = Helper.addTrailingArgs(thrower, this.argsCount, classes); if (isVararg && argsCount > throwerLen) { MethodType mt = thrower.type(); Class<?> lastParam = mt.parameterType(mt.parameterCount() - 1); thrower = thrower.asVarargsCollector(lastParam); } this.thrower = thrower; this.dropped = Math.min(this.argsCount, catchDrops); catcher = testCase.getCatcher(getCatcherParams()); nargs = Math.max(2, this.argsCount); }
Example 5
Source File: CatchExceptionTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public CatchExceptionTest(TestCase testCase, final boolean isVararg, final int argsCount, final int catchDrops) { this.testCase = testCase; this.dropped = catchDrops; MethodHandle thrower = testCase.thrower; int throwerLen = thrower.type().parameterCount(); List<Class<?>> classes; int extra = Math.max(0, argsCount - throwerLen); classes = getThrowerParams(isVararg, extra); this.argsCount = throwerLen + classes.size(); thrower = Helper.addTrailingArgs(thrower, this.argsCount, classes); if (isVararg && argsCount > throwerLen) { MethodType mt = thrower.type(); Class<?> lastParam = mt.parameterType(mt.parameterCount() - 1); thrower = thrower.asVarargsCollector(lastParam); } this.thrower = thrower; this.dropped = Math.min(this.argsCount, catchDrops); catcher = testCase.getCatcher(getCatcherParams()); nargs = Math.max(2, this.argsCount); }
Example 6
Source File: NativeCalls.java From es6draft with MIT License | 6 votes |
private static MethodHandle adaptNativeMethodHandle(MethodHandle mh) { MethodType type = mh.type(); boolean varargs = mh.isVarargsCollector(); // Allow to omit execution context argument. if (type.parameterCount() == 0 || !type.parameterType(0).equals(ExecutionContext.class)) { mh = MethodHandles.dropArguments(mh, 0, ExecutionContext.class); } // Allow void return type. if (type.returnType() == void.class) { mh = MethodHandles.filterReturnValue(mh, MethodHandles.constant(Object.class, UNDEFINED)); } // Restore var-args flag. if (varargs && !mh.isVarargsCollector()) { mh = mh.asVarargsCollector(mh.type().parameterType(mh.type().parameterCount() - 1)); } return mh; }
Example 7
Source File: CatchExceptionTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public CatchExceptionTest(TestCase testCase, final boolean isVararg, final int argsCount, final int catchDrops) { this.testCase = testCase; this.dropped = catchDrops; MethodHandle thrower = testCase.thrower; int throwerLen = thrower.type().parameterCount(); List<Class<?>> classes; int extra = Math.max(0, argsCount - throwerLen); classes = getThrowerParams(isVararg, extra); this.argsCount = throwerLen + classes.size(); thrower = Helper.addTrailingArgs(thrower, this.argsCount, classes); if (isVararg && argsCount > throwerLen) { MethodType mt = thrower.type(); Class<?> lastParam = mt.parameterType(mt.parameterCount() - 1); thrower = thrower.asVarargsCollector(lastParam); } this.thrower = thrower; this.dropped = Math.min(this.argsCount, catchDrops); catcher = testCase.getCatcher(getCatcherParams()); nargs = Math.max(2, this.argsCount); }
Example 8
Source File: CatchExceptionTest.java From hottub with GNU General Public License v2.0 | 6 votes |
public CatchExceptionTest(TestCase testCase, final boolean isVararg, final int argsCount, final int catchDrops) { this.testCase = testCase; this.dropped = catchDrops; MethodHandle thrower = testCase.thrower; int throwerLen = thrower.type().parameterCount(); List<Class<?>> classes; int extra = Math.max(0, argsCount - throwerLen); classes = getThrowerParams(isVararg, extra); this.argsCount = throwerLen + classes.size(); thrower = Helper.addTrailingArgs(thrower, this.argsCount, classes); if (isVararg && argsCount > throwerLen) { MethodType mt = thrower.type(); Class<?> lastParam = mt.parameterType(mt.parameterCount() - 1); thrower = thrower.asVarargsCollector(lastParam); } this.thrower = thrower; this.dropped = Math.min(this.argsCount, catchDrops); catcher = testCase.getCatcher(getCatcherParams()); nargs = Math.max(2, this.argsCount); }
Example 9
Source File: CatchExceptionTest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
public CatchExceptionTest(TestCase testCase, final boolean isVararg, final int argsCount, final int catchDrops) { this.testCase = testCase; this.dropped = catchDrops; if (Helper.IS_VERBOSE) { System.out.printf("CatchException::CatchException(%s, isVararg=%b " + "argsCount=%d catchDrops=%d)%n", testCase, isVararg, argsCount, catchDrops ); } MethodHandle thrower = testCase.thrower; int throwerLen = thrower.type().parameterCount(); List<Class<?>> classes; int extra = Math.max(0, argsCount - throwerLen); classes = getThrowerParams(isVararg, extra); this.argsCount = throwerLen + classes.size(); thrower = Helper.addTrailingArgs(thrower, this.argsCount, classes); if (isVararg && argsCount > throwerLen) { MethodType mt = thrower.type(); Class<?> lastParam = mt.parameterType(mt.parameterCount() - 1); thrower = thrower.asVarargsCollector(lastParam); } this.thrower = thrower; this.dropped = Math.min(this.argsCount, catchDrops); catcher = testCase.getCatcher(getCatcherParams()); nargs = Math.max(2, this.argsCount); }
Example 10
Source File: CatchExceptionTest.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public CatchExceptionTest(TestCase testCase, final boolean isVararg, final int argsCount, final int catchDrops) { this.testCase = testCase; this.dropped = catchDrops; if (Helper.IS_VERBOSE) { System.out.printf("CatchException::CatchException(%s, isVararg=%b " + "argsCount=%d catchDrops=%d)%n", testCase, isVararg, argsCount, catchDrops ); } MethodHandle thrower = testCase.thrower; int throwerLen = thrower.type().parameterCount(); List<Class<?>> classes; int extra = Math.max(0, argsCount - throwerLen); classes = getThrowerParams(isVararg, extra); this.argsCount = throwerLen + classes.size(); thrower = Helper.addTrailingArgs(thrower, this.argsCount, classes); if (isVararg && argsCount > throwerLen) { MethodType mt = thrower.type(); Class<?> lastParam = mt.parameterType(mt.parameterCount() - 1); thrower = thrower.asVarargsCollector(lastParam); } this.thrower = thrower; this.dropped = Math.min(this.argsCount, catchDrops); catcher = testCase.getCatcher(getCatcherParams()); nargs = Math.max(2, this.argsCount); }
Example 11
Source File: StaticClassIntrospector.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
private static MethodHandle dropReceiver(final MethodHandle mh, final Class<?> receiverClass) { MethodHandle newHandle = MethodHandles.dropArguments(mh, 0, receiverClass); // NOTE: this is a workaround for the fact that dropArguments doesn't preserve vararg collector state. if(mh.isVarargsCollector() && !newHandle.isVarargsCollector()) { final MethodType type = mh.type(); newHandle = newHandle.asVarargsCollector(type.parameterType(type.parameterCount() - 1)); } return newHandle; }
Example 12
Source File: StaticClassIntrospector.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private static MethodHandle dropReceiver(final MethodHandle mh, final Class<?> receiverClass) { MethodHandle newHandle = MethodHandles.dropArguments(mh, 0, receiverClass); // NOTE: this is a workaround for the fact that dropArguments doesn't preserve vararg collector state. if(mh.isVarargsCollector() && !newHandle.isVarargsCollector()) { final MethodType type = mh.type(); newHandle = newHandle.asVarargsCollector(type.parameterType(type.parameterCount() - 1)); } return newHandle; }
Example 13
Source File: StaticClassIntrospector.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private static MethodHandle dropReceiver(final MethodHandle mh, final Class<?> receiverClass) { MethodHandle newHandle = MethodHandles.dropArguments(mh, 0, receiverClass); // NOTE: this is a workaround for the fact that dropArguments doesn't preserve vararg collector state. if(mh.isVarargsCollector() && !newHandle.isVarargsCollector()) { final MethodType type = mh.type(); newHandle = newHandle.asVarargsCollector(type.parameterType(type.parameterCount() - 1)); } return newHandle; }
Example 14
Source File: StaticClassIntrospector.java From hottub with GNU General Public License v2.0 | 5 votes |
private static MethodHandle dropReceiver(final MethodHandle mh, final Class<?> receiverClass) { MethodHandle newHandle = MethodHandles.dropArguments(mh, 0, receiverClass); // NOTE: this is a workaround for the fact that dropArguments doesn't preserve vararg collector state. if(mh.isVarargsCollector() && !newHandle.isVarargsCollector()) { final MethodType type = mh.type(); newHandle = newHandle.asVarargsCollector(type.parameterType(type.parameterCount() - 1)); } return newHandle; }
Example 15
Source File: StaticClassIntrospector.java From nashorn with GNU General Public License v2.0 | 5 votes |
private static MethodHandle dropReceiver(final MethodHandle mh, final Class<?> receiverClass) { MethodHandle newHandle = MethodHandles.dropArguments(mh, 0, receiverClass); // NOTE: this is a workaround for the fact that dropArguments doesn't preserve vararg collector state. if(mh.isVarargsCollector() && !newHandle.isVarargsCollector()) { final MethodType type = mh.type(); newHandle = newHandle.asVarargsCollector(type.parameterType(type.parameterCount() - 1)); } return newHandle; }
Example 16
Source File: StaticClassIntrospector.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static MethodHandle dropReceiver(final MethodHandle mh, final Class<?> receiverClass) { MethodHandle newHandle = MethodHandles.dropArguments(mh, 0, receiverClass); // NOTE: this is a workaround for the fact that dropArguments doesn't preserve vararg collector state. if(mh.isVarargsCollector() && !newHandle.isVarargsCollector()) { final MethodType type = mh.type(); newHandle = newHandle.asVarargsCollector(type.parameterType(type.parameterCount() - 1)); } return newHandle; }
Example 17
Source File: StaticClassIntrospector.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static MethodHandle dropReceiver(final MethodHandle mh, final Class<?> receiverClass) { MethodHandle newHandle = MethodHandles.dropArguments(mh, 0, receiverClass); // NOTE: this is a workaround for the fact that dropArguments doesn't preserve vararg collector state. if(mh.isVarargsCollector() && !newHandle.isVarargsCollector()) { final MethodType type = mh.type(); newHandle = newHandle.asVarargsCollector(type.parameterType(type.parameterCount() - 1)); } return newHandle; }
Example 18
Source File: StaticClassIntrospector.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private static MethodHandle dropReceiver(final MethodHandle mh, final Class<?> receiverClass) { MethodHandle newHandle = MethodHandles.dropArguments(mh, 0, receiverClass); // NOTE: this is a workaround for the fact that dropArguments doesn't preserve vararg collector state. if(mh.isVarargsCollector() && !newHandle.isVarargsCollector()) { final MethodType type = mh.type(); newHandle = newHandle.asVarargsCollector(type.parameterType(type.parameterCount() - 1)); } return newHandle; }
Example 19
Source File: StaticClassIntrospector.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private static MethodHandle dropReceiver(final MethodHandle mh, final Class<?> receiverClass) { MethodHandle newHandle = MethodHandles.dropArguments(mh, 0, receiverClass); // NOTE: this is a workaround for the fact that dropArguments doesn't preserve vararg collector state. if(mh.isVarargsCollector() && !newHandle.isVarargsCollector()) { final MethodType type = mh.type(); newHandle = newHandle.asVarargsCollector(type.parameterType(type.parameterCount() - 1)); } return newHandle; }
Example 20
Source File: StaticClassIntrospector.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private static MethodHandle dropReceiver(final MethodHandle mh, final Class<?> receiverClass) { MethodHandle newHandle = MethodHandles.dropArguments(mh, 0, receiverClass); // NOTE: this is a workaround for the fact that dropArguments doesn't preserve vararg collector state. if(mh.isVarargsCollector() && !newHandle.isVarargsCollector()) { final MethodType type = mh.type(); newHandle = newHandle.asVarargsCollector(type.parameterType(type.parameterCount() - 1)); } return newHandle; }