Skip to content
Permalink
Browse files
fix: address some deprecation warnings in Java 9+ (#1215)
  • Loading branch information
elharo committed Jan 12, 2021
1 parent 6b9b6c5 commit 9f53a6788e20bbded1b5937a5e8fe19ace31beaa
@@ -575,10 +575,10 @@ private static Object parseValue(Type valueType, List<Type> context, String valu
valueType = Data.resolveWildcardTypeOrTypeVariable(context, valueType);
if (valueType == Double.class || valueType == double.class) {
if (value.equals("INF")) {
return new Double(Double.POSITIVE_INFINITY);
return Double.valueOf(Double.POSITIVE_INFINITY);
}
if (value.equals("-INF")) {
return new Double(Double.NEGATIVE_INFINITY);
return Double.valueOf(Double.NEGATIVE_INFINITY);
}
}
if (valueType == Float.class || valueType == float.class) {
@@ -45,36 +45,47 @@ public class Data {
// NOTE: create new instances to avoid cache, e.g. new String()

/** The single instance of the magic null object for a {@link Boolean}. */
@SuppressWarnings("deprecation")
public static final Boolean NULL_BOOLEAN = new Boolean(true);

/** The single instance of the magic null object for a {@link String}. */
@SuppressWarnings("deprecation")
public static final String NULL_STRING = new String();

/** The single instance of the magic null object for a {@link Character}. */
@SuppressWarnings("deprecation")
public static final Character NULL_CHARACTER = new Character((char) 0);

/** The single instance of the magic null object for a {@link Byte}. */
@SuppressWarnings("deprecation")
public static final Byte NULL_BYTE = new Byte((byte) 0);

/** The single instance of the magic null object for a {@link Short}. */
@SuppressWarnings("deprecation")
public static final Short NULL_SHORT = new Short((short) 0);

/** The single instance of the magic null object for a {@link Integer}. */
@SuppressWarnings("deprecation")
public static final Integer NULL_INTEGER = new Integer(0);

/** The single instance of the magic null object for a {@link Float}. */
@SuppressWarnings("deprecation")
public static final Float NULL_FLOAT = new Float(0);

/** The single instance of the magic null object for a {@link Long}. */
@SuppressWarnings("deprecation")
public static final Long NULL_LONG = new Long(0);

/** The single instance of the magic null object for a {@link Double}. */
@SuppressWarnings("deprecation")
public static final Double NULL_DOUBLE = new Double(0);

/** The single instance of the magic null object for a {@link BigInteger}. */
@SuppressWarnings("deprecation")
public static final BigInteger NULL_BIG_INTEGER = new BigInteger("0");

/** The single instance of the magic null object for a {@link BigDecimal}. */
@SuppressWarnings("deprecation")
public static final BigDecimal NULL_BIG_DECIMAL = new BigDecimal("0");

/** The single instance of the magic null object for a {@link DateTime}. */
@@ -34,7 +34,7 @@ public void testConstructor_innerClass() {

public void testToString_oneIntegerField() {
String toTest =
Objects.toStringHelper(new TestClass()).add("field1", new Integer(42)).toString();
Objects.toStringHelper(new TestClass()).add("field1", Integer.valueOf(42)).toString();
assertEquals("TestClass{field1=42}", toTest);
}

0 comments on commit 9f53a67

Please sign in to comment.