src/jdk/nashorn/internal/runtime/options/Options.java
Print this page
rev 1199 : 8072595: nashorn should not use obj.getClass() for null checks
Reviewed-by: hannesw, attila
@@ -40,10 +40,11 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.MissingResourceException;
+import java.util.Objects;
import java.util.PropertyPermission;
import java.util.ResourceBundle;
import java.util.StringTokenizer;
import java.util.TimeZone;
import java.util.TreeMap;
@@ -141,11 +142,11 @@
* @param name of boolean property
* @param defValue default value of boolean property
* @return true if set to true, default value if unset or set to false
*/
public static boolean getBooleanProperty(final String name, final Boolean defValue) {
- name.getClass(); // null check
+ Objects.requireNonNull(name);
if (!name.startsWith("nashorn.")) {
throw new IllegalArgumentException(name);
}
return AccessController.doPrivileged(
@@ -182,11 +183,11 @@
* @param name of string property
* @param defValue the default value if unset
* @return string property if set or default value
*/
public static String getStringProperty(final String name, final String defValue) {
- name.getClass(); // null check
+ Objects.requireNonNull(name);
if (! name.startsWith("nashorn.")) {
throw new IllegalArgumentException(name);
}
return AccessController.doPrivileged(
@@ -209,11 +210,11 @@
* @param name of integer property
* @param defValue the default value if unset
* @return integer property if set or default value
*/
public static int getIntProperty(final String name, final int defValue) {
- name.getClass(); // null check
+ Objects.requireNonNull(name);
if (! name.startsWith("nashorn.")) {
throw new IllegalArgumentException(name);
}
return AccessController.doPrivileged(