89 import java.lang.invoke.MethodHandles; |
89 import java.lang.invoke.MethodHandles; |
90 import java.lang.invoke.MethodType; |
90 import java.lang.invoke.MethodType; |
91 import java.lang.invoke.SwitchPoint; |
91 import java.lang.invoke.SwitchPoint; |
92 import java.lang.invoke.WrongMethodTypeException; |
92 import java.lang.invoke.WrongMethodTypeException; |
93 import java.util.List; |
93 import java.util.List; |
|
94 import java.util.Objects; |
94 import jdk.internal.dynalink.CallSiteDescriptor; |
95 import jdk.internal.dynalink.CallSiteDescriptor; |
95 import jdk.internal.dynalink.support.Guards; |
96 import jdk.internal.dynalink.support.Guards; |
96 |
97 |
97 /** |
98 /** |
98 * Represents a conditionally valid method handle. It is an immutable triple of an invocation method handle, a guard |
99 * Represents a conditionally valid method handle. It is an immutable triple of an invocation method handle, a guard |
168 * @param exception the optional exception type that is expected to be thrown by the invocation and that also |
169 * @param exception the optional exception type that is expected to be thrown by the invocation and that also |
169 * invalidates the linkage. |
170 * invalidates the linkage. |
170 * @throws NullPointerException if invocation is null. |
171 * @throws NullPointerException if invocation is null. |
171 */ |
172 */ |
172 public GuardedInvocation(final MethodHandle invocation, final MethodHandle guard, final SwitchPoint switchPoint, final Class<? extends Throwable> exception) { |
173 public GuardedInvocation(final MethodHandle invocation, final MethodHandle guard, final SwitchPoint switchPoint, final Class<? extends Throwable> exception) { |
173 invocation.getClass(); // NPE check |
174 this.invocation = Objects.requireNonNull(invocation); |
174 this.invocation = invocation; |
|
175 this.guard = guard; |
175 this.guard = guard; |
176 this.switchPoints = switchPoint == null ? null : new SwitchPoint[] { switchPoint }; |
176 this.switchPoints = switchPoint == null ? null : new SwitchPoint[] { switchPoint }; |
177 this.exception = exception; |
177 this.exception = exception; |
178 } |
178 } |
179 |
179 |
188 * @param exception the optional exception type that is expected to be thrown by the invocation and that also |
188 * @param exception the optional exception type that is expected to be thrown by the invocation and that also |
189 * invalidates the linkage. |
189 * invalidates the linkage. |
190 * @throws NullPointerException if invocation is null. |
190 * @throws NullPointerException if invocation is null. |
191 */ |
191 */ |
192 public GuardedInvocation(final MethodHandle invocation, final MethodHandle guard, final SwitchPoint[] switchPoints, final Class<? extends Throwable> exception) { |
192 public GuardedInvocation(final MethodHandle invocation, final MethodHandle guard, final SwitchPoint[] switchPoints, final Class<? extends Throwable> exception) { |
193 invocation.getClass(); // NPE check |
193 this.invocation = Objects.requireNonNull(invocation); |
194 this.invocation = invocation; |
|
195 this.guard = guard; |
194 this.guard = guard; |
196 this.switchPoints = switchPoints == null ? null : switchPoints.clone(); |
195 this.switchPoints = switchPoints == null ? null : switchPoints.clone(); |
197 this.exception = exception; |
196 this.exception = exception; |
198 } |
197 } |
199 |
198 |