Java Code Examples for java.lang.invoke.MethodHandle#asVarargsCollector()
The following examples show how to use
java.lang.invoke.MethodHandle#asVarargsCollector() .
These examples are extracted from open source projects.
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 Project: dragonwell8_jdk File: CatchExceptionTest.java License: 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 Project: TencentKona-8 File: CatchExceptionTest.java License: 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 Project: jdk8u60 File: CatchExceptionTest.java License: 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 Project: openjdk-jdk8u File: CatchExceptionTest.java License: 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 Project: openjdk-jdk8u-backup File: CatchExceptionTest.java License: 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 Project: openjdk-jdk9 File: CatchExceptionTest.java License: 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 7
Source Project: hottub File: CatchExceptionTest.java License: 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 Project: es6draft File: NativeCalls.java License: 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 9
Source Project: TencentKona-8 File: StaticClassIntrospector.java License: 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 10
Source Project: jdk8u60 File: StaticClassIntrospector.java License: 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 11
Source Project: openjdk-jdk8u File: StaticClassIntrospector.java License: 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 Project: openjdk-jdk8u-backup File: StaticClassIntrospector.java License: 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 Project: openjdk-jdk9 File: StaticClassIntrospector.java License: 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 Project: nashorn File: StaticClassIntrospector.java License: 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 Project: hottub File: StaticClassIntrospector.java License: 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 Project: openjdk-8-source File: StaticClassIntrospector.java License: 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 Project: openjdk-8 File: StaticClassIntrospector.java License: 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 Project: jdk8u_nashorn File: StaticClassIntrospector.java License: 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 Project: jdk8u-jdk File: CatchExceptionTest.java License: 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 20
Source Project: jdk8u-dev-jdk File: CatchExceptionTest.java License: 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); }