src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/linker/GuardedInvocation.java
Print this page
@@ -89,10 +89,11 @@
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.lang.invoke.SwitchPoint;
import java.lang.invoke.WrongMethodTypeException;
import java.util.List;
+import java.util.Objects;
import jdk.internal.dynalink.CallSiteDescriptor;
import jdk.internal.dynalink.support.Guards;
/**
* Represents a conditionally valid method handle. It is an immutable triple of an invocation method handle, a guard
@@ -168,12 +169,11 @@
* @param exception the optional exception type that is expected to be thrown by the invocation and that also
* invalidates the linkage.
* @throws NullPointerException if invocation is null.
*/
public GuardedInvocation(final MethodHandle invocation, final MethodHandle guard, final SwitchPoint switchPoint, final Class<? extends Throwable> exception) {
- invocation.getClass(); // NPE check
- this.invocation = invocation;
+ this.invocation = Objects.requireNonNull(invocation);
this.guard = guard;
this.switchPoints = switchPoint == null ? null : new SwitchPoint[] { switchPoint };
this.exception = exception;
}
@@ -188,12 +188,11 @@
* @param exception the optional exception type that is expected to be thrown by the invocation and that also
* invalidates the linkage.
* @throws NullPointerException if invocation is null.
*/
public GuardedInvocation(final MethodHandle invocation, final MethodHandle guard, final SwitchPoint[] switchPoints, final Class<? extends Throwable> exception) {
- invocation.getClass(); // NPE check
- this.invocation = invocation;
+ this.invocation = Objects.requireNonNull(invocation);
this.guard = guard;
this.switchPoints = switchPoints == null ? null : switchPoints.clone();
this.exception = exception;
}