This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-bcel.git
The following commit(s) were added to refs/heads/master by this push: new 8bee94f4 Use Objects#requireNonNull() 8bee94f4 is described below commit 8bee94f4fc92f3de384c2362c71c2f2ec78890d7 Author: Gary Gregory <gardgreg...@gmail.com> AuthorDate: Tue May 24 18:30:28 2022 -0400 Use Objects#requireNonNull() --- .../org/apache/bcel/classfile/ConstantUtf8.java | 6 ++-- src/main/java/org/apache/bcel/generic/Type.java | 37 +++++++++++----------- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/src/main/java/org/apache/bcel/classfile/ConstantUtf8.java b/src/main/java/org/apache/bcel/classfile/ConstantUtf8.java index 1ab3f337..aa3d97db 100644 --- a/src/main/java/org/apache/bcel/classfile/ConstantUtf8.java +++ b/src/main/java/org/apache/bcel/classfile/ConstantUtf8.java @@ -23,6 +23,7 @@ import java.io.IOException; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; +import java.util.Objects; import org.apache.bcel.Const; @@ -206,10 +207,7 @@ public final class ConstantUtf8 extends Constant { */ public ConstantUtf8(final String value) { super(Const.CONSTANT_Utf8); - if (value == null) { - throw new IllegalArgumentException("Value must not be null."); - } - this.value = value; + this.value = Objects.requireNonNull(value, "value"); created++; } diff --git a/src/main/java/org/apache/bcel/generic/Type.java b/src/main/java/org/apache/bcel/generic/Type.java index cc24596d..144fbd69 100644 --- a/src/main/java/org/apache/bcel/generic/Type.java +++ b/src/main/java/org/apache/bcel/generic/Type.java @@ -19,6 +19,7 @@ package org.apache.bcel.generic; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import org.apache.bcel.Const; import org.apache.bcel.classfile.ClassFormatException; @@ -174,50 +175,48 @@ public abstract class Type { /** Convert runtime java.lang.Class to BCEL Type object. - * @param cl Java class + * @param cls Java class * @return corresponding Type object */ - public static Type getType( final java.lang.Class<?> cl ) { - if (cl == null) { - throw new IllegalArgumentException("Class must not be null"); - } + public static Type getType( final java.lang.Class<?> cls ) { + Objects.requireNonNull(cls, "cls"); /* That's an amzingly easy case, because getName() returns * the signature. That's what we would have liked anyway. */ - if (cl.isArray()) { - return getType(cl.getName()); + if (cls.isArray()) { + return getType(cls.getName()); } - if (!cl.isPrimitive()) { // "Real" class - return ObjectType.getInstance(cl.getName()); + if (!cls.isPrimitive()) { // "Real" class + return ObjectType.getInstance(cls.getName()); } - if (cl == Integer.TYPE) { + if (cls == Integer.TYPE) { return INT; } - if (cl == Void.TYPE) { + if (cls == Void.TYPE) { return VOID; } - if (cl == Double.TYPE) { + if (cls == Double.TYPE) { return DOUBLE; } - if (cl == Float.TYPE) { + if (cls == Float.TYPE) { return FLOAT; } - if (cl == Boolean.TYPE) { + if (cls == Boolean.TYPE) { return BOOLEAN; } - if (cl == Byte.TYPE) { + if (cls == Byte.TYPE) { return BYTE; } - if (cl == Short.TYPE) { + if (cls == Short.TYPE) { return SHORT; } - if (cl == Long.TYPE) { + if (cls == Long.TYPE) { return LONG; } - if (cl == Character.TYPE) { + if (cls == Character.TYPE) { return CHAR; } - throw new IllegalStateException("Unknown primitive type " + cl); + throw new IllegalStateException("Unknown primitive type " + cls); }