001/* 002 * Copyright (C) 2005 The Guava Authors 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package com.google.common.testing; 018 019import static com.google.common.base.Preconditions.checkArgument; 020import static com.google.common.base.Preconditions.checkNotNull; 021import static java.util.Arrays.stream; 022import static java.util.Objects.requireNonNull; 023import static java.util.stream.Stream.concat; 024 025import com.google.common.annotations.GwtIncompatible; 026import com.google.common.annotations.J2ktIncompatible; 027import com.google.common.base.Converter; 028import com.google.common.base.Objects; 029import com.google.common.collect.ClassToInstanceMap; 030import com.google.common.collect.ImmutableList; 031import com.google.common.collect.ImmutableSet; 032import com.google.common.collect.Lists; 033import com.google.common.collect.Maps; 034import com.google.common.collect.MutableClassToInstanceMap; 035import com.google.common.reflect.Invokable; 036import com.google.common.reflect.Parameter; 037import com.google.common.reflect.Reflection; 038import com.google.common.reflect.TypeToken; 039import com.google.common.util.concurrent.AbstractFuture; 040import com.google.errorprone.annotations.CanIgnoreReturnValue; 041import java.lang.annotation.Annotation; 042import java.lang.reflect.Constructor; 043import java.lang.reflect.InvocationTargetException; 044import java.lang.reflect.Member; 045import java.lang.reflect.Method; 046import java.lang.reflect.Modifier; 047import java.lang.reflect.ParameterizedType; 048import java.lang.reflect.Type; 049import java.util.Arrays; 050import java.util.List; 051import java.util.concurrent.ConcurrentMap; 052import junit.framework.Assert; 053import org.jspecify.annotations.NullMarked; 054import org.jspecify.annotations.Nullable; 055 056/** 057 * A test utility that verifies that your methods and constructors throw {@link 058 * NullPointerException} or {@link UnsupportedOperationException} whenever null is passed to a 059 * parameter whose declaration or type isn't annotated with an annotation with the simple name 060 * {@code Nullable}, {@code CheckForNull}, {@code NullableType}, or {@code NullableDecl}. 061 * 062 * <p>The tested methods and constructors are invoked -- each time with one parameter being null and 063 * the rest not null -- and the test fails if no expected exception is thrown. {@code 064 * NullPointerTester} uses best effort to pick non-null default values for many common JDK and Guava 065 * types, and also for interfaces and public classes that have public parameter-less constructors. 066 * When the non-null default value for a particular parameter type cannot be provided by {@code 067 * NullPointerTester}, the caller can provide a custom non-null default value for the parameter type 068 * via {@link #setDefault}. 069 * 070 * @author Kevin Bourrillion 071 * @since 10.0 072 */ 073@GwtIncompatible 074@J2ktIncompatible 075@NullMarked 076public final class NullPointerTester { 077 078 private final ClassToInstanceMap<Object> defaults = MutableClassToInstanceMap.create(); 079 private final List<Member> ignoredMembers = Lists.newArrayList(); 080 081 private ExceptionTypePolicy policy = ExceptionTypePolicy.NPE_OR_UOE; 082 083 /* 084 * Requiring desugaring for guava-*testlib* is likely safe, at least for the reflection-based 085 * NullPointerTester. But if you are a user who is reading this because this change caused you 086 * trouble, please let us know: https://github.com/google/guava/issues/new 087 */ 088 @IgnoreJRERequirement 089 public NullPointerTester() { 090 try { 091 /* 092 * Converter.apply has a non-nullable parameter type but doesn't throw for null arguments. For 093 * more information, see the comments in that class. 094 * 095 * We already know that that's how it behaves, and subclasses of Converter can't change that 096 * behavior. So there's no sense in making all subclass authors exclude the method from any 097 * NullPointerTester tests that they have. 098 */ 099 ignoredMembers.add(Converter.class.getMethod("apply", Object.class)); 100 } catch (NoSuchMethodException shouldBeImpossible) { 101 // Fine: If it doesn't exist, then there's no chance that we're going to be asked to test it. 102 } 103 104 /* 105 * These methods "should" call checkNotNull. However, I'm wary of accidentally introducing 106 * anything that might slow down execution on such a hot path. Given that the methods are only 107 * package-private, I feel OK with just not testing them for NPE. 108 * 109 * Note that testing casValue is particularly dangerous because it uses Unsafe under some 110 * versions of Java, and apparently Unsafe can cause SIGSEGV instead of NPE—almost as if it's 111 * not safe. 112 */ 113 concat( 114 stream(AbstractFuture.class.getDeclaredMethods()), 115 stream(requireNonNull(AbstractFuture.class.getSuperclass()).getDeclaredMethods())) 116 .filter( 117 m -> 118 m.getName().equals("getDoneValue") 119 || m.getName().equals("casValue") 120 || m.getName().equals("casListeners") 121 || m.getName().equals("gasListeners")) 122 .forEach(ignoredMembers::add); 123 } 124 125 /** 126 * Sets a default value that can be used for any parameter of type {@code type}. Returns this 127 * object. 128 */ 129 @CanIgnoreReturnValue 130 public <T> NullPointerTester setDefault(Class<T> type, T value) { 131 defaults.putInstance(type, checkNotNull(value)); 132 return this; 133 } 134 135 /** 136 * Ignore {@code method} in the tests that follow. Returns this object. 137 * 138 * @since 13.0 139 */ 140 @CanIgnoreReturnValue 141 public NullPointerTester ignore(Method method) { 142 ignoredMembers.add(checkNotNull(method)); 143 return this; 144 } 145 146 /** 147 * Ignore {@code constructor} in the tests that follow. Returns this object. 148 * 149 * @since 22.0 150 */ 151 @CanIgnoreReturnValue 152 public NullPointerTester ignore(Constructor<?> constructor) { 153 ignoredMembers.add(checkNotNull(constructor)); 154 return this; 155 } 156 157 /** 158 * Runs {@link #testConstructor} on every constructor in class {@code c} that has at least {@code 159 * minimalVisibility}. 160 */ 161 public void testConstructors(Class<?> c, Visibility minimalVisibility) { 162 for (Constructor<?> constructor : c.getDeclaredConstructors()) { 163 if (minimalVisibility.isVisible(constructor) && !isIgnored(constructor)) { 164 testConstructor(constructor); 165 } 166 } 167 } 168 169 /** Runs {@link #testConstructor} on every public constructor in class {@code c}. */ 170 public void testAllPublicConstructors(Class<?> c) { 171 testConstructors(c, Visibility.PUBLIC); 172 } 173 174 /** 175 * Runs {@link #testMethod} on every static method of class {@code c} that has at least {@code 176 * minimalVisibility}, including those "inherited" from superclasses of the same package. 177 */ 178 public void testStaticMethods(Class<?> c, Visibility minimalVisibility) { 179 for (Method method : minimalVisibility.getStaticMethods(c)) { 180 if (!isIgnored(method)) { 181 testMethod(null, method); 182 } 183 } 184 } 185 186 /** 187 * Runs {@link #testMethod} on every public static method of class {@code c}, including those 188 * "inherited" from superclasses of the same package. 189 */ 190 public void testAllPublicStaticMethods(Class<?> c) { 191 testStaticMethods(c, Visibility.PUBLIC); 192 } 193 194 /** 195 * Runs {@link #testMethod} on every instance method of the class of {@code instance} with at 196 * least {@code minimalVisibility}, including those inherited from superclasses of the same 197 * package. 198 */ 199 public void testInstanceMethods(Object instance, Visibility minimalVisibility) { 200 for (Method method : getInstanceMethodsToTest(instance.getClass(), minimalVisibility)) { 201 testMethod(instance, method); 202 } 203 } 204 205 ImmutableList<Method> getInstanceMethodsToTest(Class<?> c, Visibility minimalVisibility) { 206 ImmutableList.Builder<Method> builder = ImmutableList.builder(); 207 for (Method method : minimalVisibility.getInstanceMethods(c)) { 208 if (!isIgnored(method)) { 209 builder.add(method); 210 } 211 } 212 return builder.build(); 213 } 214 215 /** 216 * Runs {@link #testMethod} on every public instance method of the class of {@code instance}, 217 * including those inherited from superclasses of the same package. 218 */ 219 public void testAllPublicInstanceMethods(Object instance) { 220 testInstanceMethods(instance, Visibility.PUBLIC); 221 } 222 223 /** 224 * Verifies that {@code method} produces a {@link NullPointerException} or {@link 225 * UnsupportedOperationException} whenever <i>any</i> of its non-nullable parameters are null. 226 * 227 * @param instance the instance to invoke {@code method} on, or null if {@code method} is static 228 */ 229 public void testMethod(@Nullable Object instance, Method method) { 230 Class<?>[] types = method.getParameterTypes(); 231 for (int nullIndex = 0; nullIndex < types.length; nullIndex++) { 232 testMethodParameter(instance, method, nullIndex); 233 } 234 } 235 236 /** 237 * Verifies that {@code ctor} produces a {@link NullPointerException} or {@link 238 * UnsupportedOperationException} whenever <i>any</i> of its non-nullable parameters are null. 239 */ 240 public void testConstructor(Constructor<?> ctor) { 241 Class<?> declaringClass = ctor.getDeclaringClass(); 242 checkArgument( 243 Modifier.isStatic(declaringClass.getModifiers()) 244 || declaringClass.getEnclosingClass() == null, 245 "Cannot test constructor of non-static inner class: %s", 246 declaringClass.getName()); 247 Class<?>[] types = ctor.getParameterTypes(); 248 for (int nullIndex = 0; nullIndex < types.length; nullIndex++) { 249 testConstructorParameter(ctor, nullIndex); 250 } 251 } 252 253 /** 254 * Verifies that {@code method} produces a {@link NullPointerException} or {@link 255 * UnsupportedOperationException} when the parameter in position {@code paramIndex} is null. If 256 * this parameter is marked nullable, this method does nothing. 257 * 258 * @param instance the instance to invoke {@code method} on, or null if {@code method} is static 259 */ 260 public void testMethodParameter(@Nullable Object instance, Method method, int paramIndex) { 261 method.setAccessible(true); 262 testParameter(instance, invokable(instance, method), paramIndex, method.getDeclaringClass()); 263 } 264 265 /** 266 * Verifies that {@code ctor} produces a {@link NullPointerException} or {@link 267 * UnsupportedOperationException} when the parameter in position {@code paramIndex} is null. If 268 * this parameter is marked nullable, this method does nothing. 269 */ 270 public void testConstructorParameter(Constructor<?> ctor, int paramIndex) { 271 ctor.setAccessible(true); 272 testParameter(null, Invokable.from(ctor), paramIndex, ctor.getDeclaringClass()); 273 } 274 275 /** Visibility of any method or constructor. */ 276 public enum Visibility { 277 PACKAGE { 278 @Override 279 boolean isVisible(int modifiers) { 280 return !Modifier.isPrivate(modifiers); 281 } 282 }, 283 284 PROTECTED { 285 @Override 286 boolean isVisible(int modifiers) { 287 return Modifier.isPublic(modifiers) || Modifier.isProtected(modifiers); 288 } 289 }, 290 291 PUBLIC { 292 @Override 293 boolean isVisible(int modifiers) { 294 return Modifier.isPublic(modifiers); 295 } 296 }; 297 298 abstract boolean isVisible(int modifiers); 299 300 /** Returns {@code true} if {@code member} is visible under {@code this} visibility. */ 301 final boolean isVisible(Member member) { 302 return isVisible(member.getModifiers()); 303 } 304 305 final Iterable<Method> getStaticMethods(Class<?> cls) { 306 ImmutableList.Builder<Method> builder = ImmutableList.builder(); 307 for (Method method : getVisibleMethods(cls)) { 308 if (Invokable.from(method).isStatic()) { 309 builder.add(method); 310 } 311 } 312 return builder.build(); 313 } 314 315 final Iterable<Method> getInstanceMethods(Class<?> cls) { 316 ConcurrentMap<Signature, Method> map = Maps.newConcurrentMap(); 317 for (Method method : getVisibleMethods(cls)) { 318 if (!Invokable.from(method).isStatic()) { 319 map.putIfAbsent(new Signature(method), method); 320 } 321 } 322 return map.values(); 323 } 324 325 private ImmutableList<Method> getVisibleMethods(Class<?> cls) { 326 // Don't use cls.getPackage() because it does nasty things like reading 327 // a file. 328 String visiblePackage = Reflection.getPackageName(cls); 329 ImmutableList.Builder<Method> builder = ImmutableList.builder(); 330 for (Class<?> type : TypeToken.of(cls).getTypes().rawTypes()) { 331 if (!Reflection.getPackageName(type).equals(visiblePackage)) { 332 break; 333 } 334 for (Method method : type.getDeclaredMethods()) { 335 if (!method.isSynthetic() && isVisible(method)) { 336 builder.add(method); 337 } 338 } 339 } 340 return builder.build(); 341 } 342 } 343 344 private static final class Signature { 345 private final String name; 346 private final ImmutableList<Class<?>> parameterTypes; 347 348 Signature(Method method) { 349 this(method.getName(), ImmutableList.copyOf(method.getParameterTypes())); 350 } 351 352 Signature(String name, ImmutableList<Class<?>> parameterTypes) { 353 this.name = name; 354 this.parameterTypes = parameterTypes; 355 } 356 357 @Override 358 public boolean equals(@Nullable Object obj) { 359 if (obj instanceof Signature) { 360 Signature that = (Signature) obj; 361 return name.equals(that.name) && parameterTypes.equals(that.parameterTypes); 362 } 363 return false; 364 } 365 366 @Override 367 public int hashCode() { 368 return Objects.hashCode(name, parameterTypes); 369 } 370 } 371 372 /** 373 * Verifies that {@code invokable} produces a {@link NullPointerException} or {@link 374 * UnsupportedOperationException} when the parameter in position {@code paramIndex} is null. If 375 * this parameter is marked nullable, this method does nothing. 376 * 377 * @param instance the instance to invoke {@code invokable} on, or null if {@code invokable} is 378 * static 379 */ 380 private void testParameter( 381 @Nullable Object instance, Invokable<?, ?> invokable, int paramIndex, Class<?> testedClass) { 382 /* 383 * com.google.common is starting to rely on type-use annotations, which aren't visible under 384 * Android VMs and in open-source guava-android. So we skip testing there. 385 */ 386 if (Reflection.getPackageName(testedClass).startsWith("com.google.common")) { 387 return; 388 } 389 if (isPrimitiveOrNullable(invokable.getParameters().get(paramIndex))) { 390 return; // there's nothing to test 391 } 392 @Nullable Object[] params = buildParamList(invokable, paramIndex); 393 try { 394 @SuppressWarnings("unchecked") // We'll get a runtime exception if the type is wrong. 395 Invokable<Object, ?> unsafe = (Invokable<Object, ?>) invokable; 396 unsafe.invoke(instance, params); 397 Assert.fail( 398 "No exception thrown for parameter at index " 399 + paramIndex 400 + " from " 401 + invokable 402 + Arrays.toString(params) 403 + " for " 404 + testedClass); 405 } catch (InvocationTargetException e) { 406 Throwable cause = e.getCause(); 407 if (policy.isExpectedType(cause)) { 408 return; 409 } 410 throw new AssertionError( 411 String.format( 412 "wrong exception thrown from %s when passing null to %s parameter at index %s.%n" 413 + "Full parameters: %s%n" 414 + "Actual exception message: %s", 415 invokable, 416 invokable.getParameters().get(paramIndex).getType(), 417 paramIndex, 418 Arrays.toString(params), 419 cause), 420 cause); 421 } catch (IllegalAccessException e) { 422 throw new RuntimeException(e); 423 } 424 } 425 426 private @Nullable Object[] buildParamList( 427 Invokable<?, ?> invokable, int indexOfParamToSetToNull) { 428 ImmutableList<Parameter> params = invokable.getParameters(); 429 @Nullable Object[] args = new Object[params.size()]; 430 431 for (int i = 0; i < args.length; i++) { 432 Parameter param = params.get(i); 433 if (i != indexOfParamToSetToNull) { 434 args[i] = getDefaultValue(param.getType()); 435 Assert.assertTrue( 436 "Can't find or create a sample instance for type '" 437 + param.getType() 438 + "'; please provide one using NullPointerTester.setDefault()", 439 args[i] != null || isNullable(param)); 440 } 441 } 442 return args; 443 } 444 445 private <T> @Nullable T getDefaultValue(TypeToken<T> type) { 446 // We assume that all defaults are generics-safe, even if they aren't, 447 // we take the risk. 448 @SuppressWarnings("unchecked") 449 T defaultValue = (T) defaults.getInstance(type.getRawType()); 450 if (defaultValue != null) { 451 return defaultValue; 452 } 453 @SuppressWarnings("unchecked") // All arbitrary instances are generics-safe 454 T arbitrary = (T) ArbitraryInstances.get(type.getRawType()); 455 if (arbitrary != null) { 456 return arbitrary; 457 } 458 if (type.getRawType() == Class.class) { 459 // If parameter is Class<? extends Foo>, we return Foo.class 460 @SuppressWarnings("unchecked") 461 T defaultClass = (T) getFirstTypeParameter(type.getType()).getRawType(); 462 return defaultClass; 463 } 464 if (type.getRawType() == TypeToken.class) { 465 // If parameter is TypeToken<? extends Foo>, we return TypeToken<Foo>. 466 @SuppressWarnings("unchecked") 467 T defaultType = (T) getFirstTypeParameter(type.getType()); 468 return defaultType; 469 } 470 if (type.getRawType() == Converter.class) { 471 TypeToken<?> convertFromType = type.resolveType(Converter.class.getTypeParameters()[0]); 472 TypeToken<?> convertToType = type.resolveType(Converter.class.getTypeParameters()[1]); 473 @SuppressWarnings("unchecked") // returns default for both F and T 474 T defaultConverter = (T) defaultConverter(convertFromType, convertToType); 475 return defaultConverter; 476 } 477 if (type.getRawType().isInterface()) { 478 return newDefaultReturningProxy(type); 479 } 480 return null; 481 } 482 483 private <F, T> Converter<F, T> defaultConverter( 484 TypeToken<F> convertFromType, TypeToken<T> convertToType) { 485 return new Converter<F, T>() { 486 @Override 487 protected T doForward(F a) { 488 return doConvert(convertToType); 489 } 490 491 @Override 492 protected F doBackward(T b) { 493 return doConvert(convertFromType); 494 } 495 496 private /*static*/ <S> S doConvert(TypeToken<S> type) { 497 return checkNotNull(getDefaultValue(type)); 498 } 499 }; 500 } 501 502 private static TypeToken<?> getFirstTypeParameter(Type type) { 503 if (type instanceof ParameterizedType) { 504 return TypeToken.of(((ParameterizedType) type).getActualTypeArguments()[0]); 505 } else { 506 return TypeToken.of(Object.class); 507 } 508 } 509 510 private <T> T newDefaultReturningProxy(TypeToken<T> type) { 511 return new DummyProxy() { 512 @Override 513 <R> @Nullable R dummyReturnValue(TypeToken<R> returnType) { 514 return getDefaultValue(returnType); 515 } 516 }.newProxy(type); 517 } 518 519 private static Invokable<?, ?> invokable(@Nullable Object instance, Method method) { 520 if (instance == null) { 521 return Invokable.from(method); 522 } else { 523 return TypeToken.of(instance.getClass()).method(method); 524 } 525 } 526 527 static boolean isPrimitiveOrNullable(Parameter param) { 528 return param.getType().getRawType().isPrimitive() || isNullable(param); 529 } 530 531 private static final ImmutableSet<String> NULLABLE_ANNOTATION_SIMPLE_NAMES = 532 ImmutableSet.of("CheckForNull", "Nullable", "NullableDecl", "NullableType"); 533 534 static boolean isNullable(Invokable<?, ?> invokable) { 535 return NULLNESS_ANNOTATION_READER.isNullable(invokable); 536 } 537 538 static boolean isNullable(Parameter param) { 539 return NULLNESS_ANNOTATION_READER.isNullable(param); 540 } 541 542 private static boolean containsNullable(Annotation[] annotations) { 543 for (Annotation annotation : annotations) { 544 if (NULLABLE_ANNOTATION_SIMPLE_NAMES.contains(annotation.annotationType().getSimpleName())) { 545 return true; 546 } 547 } 548 return false; 549 } 550 551 private boolean isIgnored(Member member) { 552 return member.isSynthetic() || ignoredMembers.contains(member) || isEquals(member); 553 } 554 555 /** 556 * Returns true if the given member is a method that overrides {@link Object#equals(Object)}. 557 * 558 * <p>The documentation for {@link Object#equals} says it should accept null, so don't require an 559 * explicit {@code @NullableDecl} annotation (see <a 560 * href="https://github.com/google/guava/issues/1819">#1819</a>). 561 * 562 * <p>It is not necessary to consider visibility, return type, or type parameter declarations. The 563 * declaration of a method with the same name and formal parameters as {@link Object#equals} that 564 * is not public and boolean-returning, or that declares any type parameters, would be rejected at 565 * compile-time. 566 */ 567 private static boolean isEquals(Member member) { 568 if (!(member instanceof Method)) { 569 return false; 570 } 571 Method method = (Method) member; 572 if (!method.getName().contentEquals("equals")) { 573 return false; 574 } 575 Class<?>[] parameters = method.getParameterTypes(); 576 if (parameters.length != 1) { 577 return false; 578 } 579 if (!parameters[0].equals(Object.class)) { 580 return false; 581 } 582 return true; 583 } 584 585 /** Strategy for exception type matching used by {@link NullPointerTester}. */ 586 private enum ExceptionTypePolicy { 587 588 /** 589 * Exceptions should be {@link NullPointerException} or {@link UnsupportedOperationException}. 590 */ 591 NPE_OR_UOE() { 592 @Override 593 public boolean isExpectedType(Throwable cause) { 594 return cause instanceof NullPointerException 595 || cause instanceof UnsupportedOperationException; 596 } 597 }, 598 599 /** 600 * Exceptions should be {@link NullPointerException}, {@link IllegalArgumentException}, or 601 * {@link UnsupportedOperationException}. 602 */ 603 NPE_IAE_OR_UOE() { 604 @Override 605 public boolean isExpectedType(Throwable cause) { 606 return cause instanceof NullPointerException 607 || cause instanceof IllegalArgumentException 608 || cause instanceof UnsupportedOperationException; 609 } 610 }; 611 612 public abstract boolean isExpectedType(Throwable cause); 613 } 614 615 private static boolean annotatedTypeExists() { 616 try { 617 Class.forName("java.lang.reflect.AnnotatedType"); 618 } catch (ClassNotFoundException e) { 619 return false; 620 } 621 return true; 622 } 623 624 private static final NullnessAnnotationReader NULLNESS_ANNOTATION_READER = 625 annotatedTypeExists() 626 ? NullnessAnnotationReader.FROM_DECLARATION_AND_TYPE_USE_ANNOTATIONS 627 : NullnessAnnotationReader.FROM_DECLARATION_ANNOTATIONS_ONLY; 628 629 /** 630 * Looks for declaration nullness annotations and, if supported, type-use nullness annotations. 631 * 632 * <p>Under Android VMs, the methods for retrieving type-use annotations don't exist. This means 633 * that {@link NullPointerTester} may misbehave under Android when used on classes that rely on 634 * type-use annotations. 635 * 636 * <p>Under j2objc, the necessary APIs exist, but some (perhaps all) return stub values, like 637 * empty arrays. Presumably {@link NullPointerTester} could likewise misbehave under j2objc, but I 638 * don't know that anyone uses it there, anyway. 639 */ 640 private enum NullnessAnnotationReader { 641 @SuppressWarnings("Java7ApiChecker") 642 FROM_DECLARATION_AND_TYPE_USE_ANNOTATIONS { 643 @Override 644 boolean isNullable(Invokable<?, ?> invokable) { 645 return FROM_DECLARATION_ANNOTATIONS_ONLY.isNullable(invokable) 646 ; 647 // TODO(cpovirk): Should we also check isNullableTypeVariable? 648 } 649 650 @Override 651 boolean isNullable(Parameter param) { 652 return FROM_DECLARATION_ANNOTATIONS_ONLY.isNullable(param) 653 ; 654 } 655 }, 656 FROM_DECLARATION_ANNOTATIONS_ONLY { 657 @Override 658 boolean isNullable(Invokable<?, ?> invokable) { 659 return containsNullable(invokable.getAnnotations()); 660 } 661 662 @Override 663 boolean isNullable(Parameter param) { 664 return containsNullable(param.getAnnotations()); 665 } 666 }; 667 668 abstract boolean isNullable(Invokable<?, ?> invokable); 669 670 abstract boolean isNullable(Parameter param); 671 } 672}