Skip to content
Permalink
Browse files
8263380: Unintended use of Objects.nonNull in VarHandles
Reviewed-by: rriggs
  • Loading branch information
cl4es committed Mar 10, 2021
1 parent 4b5be40 commit 7e52a6e8b37412b43b0024ca067959100c14f508
Showing with 14 additions and 14 deletions.
  1. +14 −14 src/java.base/share/classes/java/lang/invoke/VarHandles.java
@@ -360,9 +360,9 @@ private static VarHandle maybeAdapt(VarHandle target) {
}

public static VarHandle filterValue(VarHandle target, MethodHandle filterToTarget, MethodHandle filterFromTarget) {
Objects.nonNull(target);
Objects.nonNull(filterToTarget);
Objects.nonNull(filterFromTarget);
Objects.requireNonNull(target);
Objects.requireNonNull(filterToTarget);
Objects.requireNonNull(filterFromTarget);
//check that from/to filters do not throw checked exceptions
noCheckedExceptions(filterToTarget);
noCheckedExceptions(filterFromTarget);
@@ -459,8 +459,8 @@ private static MethodHandle joinDuplicateArgs(MethodHandle handle, int originalS
}

public static VarHandle filterCoordinates(VarHandle target, int pos, MethodHandle... filters) {
Objects.nonNull(target);
Objects.nonNull(filters);
Objects.requireNonNull(target);
Objects.requireNonNull(filters);

List<Class<?>> targetCoordinates = target.coordinateTypes();
if (pos < 0 || pos >= targetCoordinates.size()) {
@@ -488,8 +488,8 @@ public static VarHandle filterCoordinates(VarHandle target, int pos, MethodHandl
}

public static VarHandle insertCoordinates(VarHandle target, int pos, Object... values) {
Objects.nonNull(target);
Objects.nonNull(values);
Objects.requireNonNull(target);
Objects.requireNonNull(values);

List<Class<?>> targetCoordinates = target.coordinateTypes();
if (pos < 0 || pos >= targetCoordinates.size()) {
@@ -517,9 +517,9 @@ public static VarHandle insertCoordinates(VarHandle target, int pos, Object... v
}

public static VarHandle permuteCoordinates(VarHandle target, List<Class<?>> newCoordinates, int... reorder) {
Objects.nonNull(target);
Objects.nonNull(newCoordinates);
Objects.nonNull(reorder);
Objects.requireNonNull(target);
Objects.requireNonNull(newCoordinates);
Objects.requireNonNull(reorder);

List<Class<?>> targetCoordinates = target.coordinateTypes();
MethodHandles.permuteArgumentChecks(reorder,
@@ -565,8 +565,8 @@ private static MethodType methodTypeFor(VarHandle.AccessType at, MethodType oldT
}

public static VarHandle collectCoordinates(VarHandle target, int pos, MethodHandle filter) {
Objects.nonNull(target);
Objects.nonNull(filter);
Objects.requireNonNull(target);
Objects.requireNonNull(filter);
noCheckedExceptions(filter);

List<Class<?>> targetCoordinates = target.coordinateTypes();
@@ -587,8 +587,8 @@ public static VarHandle collectCoordinates(VarHandle target, int pos, MethodHand
}

public static VarHandle dropCoordinates(VarHandle target, int pos, Class<?>... valueTypes) {
Objects.nonNull(target);
Objects.nonNull(valueTypes);
Objects.requireNonNull(target);
Objects.requireNonNull(valueTypes);

List<Class<?>> targetCoordinates = target.coordinateTypes();
if (pos < 0 || pos > targetCoordinates.size()) {

1 comment on commit 7e52a6e

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on 7e52a6e Mar 10, 2021

Please sign in to comment.