< prev index next >

src/jdk.dynalink/share/classes/jdk/dynalink/linker/GuardedInvocation.java

Print this page




 185      * thrown when invoked also invalidates it.
 186      *
 187      * @param invocation the method handle representing the invocation. Must not
 188      * be null.
 189      * @param guard the method handle representing the guard. Must have be
 190      * compatible with the {@code invocation} handle as per
 191      * {@link MethodHandles#guardWithTest(MethodHandle, MethodHandle, MethodHandle)}.
 192      * For some useful guards, check out the {@link Guards} class. It can be
 193      * null. If it and the switch point and the exception are all null, this
 194      * represents an unconditional invocation.
 195      * @param switchPoint the optional switch point that can be used to
 196      * invalidate this linkage.
 197      * @param exception the optional exception type that is when thrown by the
 198      * invocation also invalidates it.
 199      * @throws NullPointerException if invocation is null.
 200      */
 201     public GuardedInvocation(final MethodHandle invocation, final MethodHandle guard, final SwitchPoint switchPoint, final Class<? extends Throwable> exception) {
 202         this.invocation = Objects.requireNonNull(invocation);
 203         this.guard = guard;
 204         this.switchPoints = switchPoint == null ? null : new SwitchPoint[] { switchPoint };



 205         this.exception = exception;
 206     }
 207 
 208     /**
 209      * Creates a new guarded invocation, with a guard method handle, any number
 210      * of switch points that can be used to invalidate it, and an exception that
 211      * if thrown when invoked also invalidates it.
 212      *
 213      * @param invocation the method handle representing the invocation. Must not
 214      * be null.
 215      * @param guard the method handle representing the guard. Must have be
 216      * compatible with the {@code invocation} handle as per
 217      * {@link MethodHandles#guardWithTest(MethodHandle, MethodHandle, MethodHandle)}.
 218      * For some useful guards, check out the {@link Guards} class. It can be
 219      * null. If it and the exception are both null, and no switch points were
 220      * specified, this represents an unconditional invocation.
 221      * @param switchPoints optional switch points that can be used to
 222      * invalidate this linkage.
 223      * @param exception the optional exception type that is when thrown by the
 224      * invocation also invalidates it.
 225      * @throws NullPointerException if invocation is null.
 226      */
 227     public GuardedInvocation(final MethodHandle invocation, final MethodHandle guard, final SwitchPoint[] switchPoints, final Class<? extends Throwable> exception) {
 228         this.invocation = Objects.requireNonNull(invocation);
 229         this.guard = guard;
 230         this.switchPoints = switchPoints == null ? null : switchPoints.clone();



 231         this.exception = exception;
 232     }
 233 
 234     /**
 235      * Returns the invocation method handle.
 236      *
 237      * @return the invocation method handle. It will never be null.
 238      */
 239     public MethodHandle getInvocation() {
 240         return invocation;
 241     }
 242 
 243     /**
 244      * Returns the guard method handle.
 245      *
 246      * @return the guard method handle. Can be null.
 247      */
 248     public MethodHandle getGuard() {
 249         return guard;
 250     }




 185      * thrown when invoked also invalidates it.
 186      *
 187      * @param invocation the method handle representing the invocation. Must not
 188      * be null.
 189      * @param guard the method handle representing the guard. Must have be
 190      * compatible with the {@code invocation} handle as per
 191      * {@link MethodHandles#guardWithTest(MethodHandle, MethodHandle, MethodHandle)}.
 192      * For some useful guards, check out the {@link Guards} class. It can be
 193      * null. If it and the switch point and the exception are all null, this
 194      * represents an unconditional invocation.
 195      * @param switchPoint the optional switch point that can be used to
 196      * invalidate this linkage.
 197      * @param exception the optional exception type that is when thrown by the
 198      * invocation also invalidates it.
 199      * @throws NullPointerException if invocation is null.
 200      */
 201     public GuardedInvocation(final MethodHandle invocation, final MethodHandle guard, final SwitchPoint switchPoint, final Class<? extends Throwable> exception) {
 202         this.invocation = Objects.requireNonNull(invocation);
 203         this.guard = guard;
 204         this.switchPoints = switchPoint == null ? null : new SwitchPoint[] { switchPoint };
 205         if (exception != null && !Throwable.class.isAssignableFrom(exception)) {
 206             throw new IllegalArgumentException(exception.getName() + " is not assignable from Throwable");
 207         }
 208         this.exception = exception;
 209     }
 210 
 211     /**
 212      * Creates a new guarded invocation, with a guard method handle, any number
 213      * of switch points that can be used to invalidate it, and an exception that
 214      * if thrown when invoked also invalidates it.
 215      *
 216      * @param invocation the method handle representing the invocation. Must not
 217      * be null.
 218      * @param guard the method handle representing the guard. Must have be
 219      * compatible with the {@code invocation} handle as per
 220      * {@link MethodHandles#guardWithTest(MethodHandle, MethodHandle, MethodHandle)}.
 221      * For some useful guards, check out the {@link Guards} class. It can be
 222      * null. If it and the exception are both null, and no switch points were
 223      * specified, this represents an unconditional invocation.
 224      * @param switchPoints optional switch points that can be used to
 225      * invalidate this linkage.
 226      * @param exception the optional exception type that is when thrown by the
 227      * invocation also invalidates it.
 228      * @throws NullPointerException if invocation is null.
 229      */
 230     public GuardedInvocation(final MethodHandle invocation, final MethodHandle guard, final SwitchPoint[] switchPoints, final Class<? extends Throwable> exception) {
 231         this.invocation = Objects.requireNonNull(invocation);
 232         this.guard = guard;
 233         this.switchPoints = switchPoints == null ? null : switchPoints.clone();
 234         if (exception != null && !Throwable.class.isAssignableFrom(exception)) {
 235             throw new IllegalArgumentException(exception.getName() + " is not assignable from Throwable");
 236         }
 237         this.exception = exception;
 238     }
 239 
 240     /**
 241      * Returns the invocation method handle.
 242      *
 243      * @return the invocation method handle. It will never be null.
 244      */
 245     public MethodHandle getInvocation() {
 246         return invocation;
 247     }
 248 
 249     /**
 250      * Returns the guard method handle.
 251      *
 252      * @return the guard method handle. Can be null.
 253      */
 254     public MethodHandle getGuard() {
 255         return guard;
 256     }


< prev index next >