altoslib: Stop using deprecated Java functionality
authorKeith Packard <keithp@keithp.com>
Wed, 17 Jul 2019 18:38:43 +0000 (11:38 -0700)
committerKeith Packard <keithp@keithp.com>
Wed, 17 Jul 2019 18:38:43 +0000 (11:38 -0700)
new Double(x) -> Double.valueOf(x)
c.newInstance() -> c.getDeclaredConstructor().newInstance()

Signed-off-by: Keith Packard <keithp@keithp.com>
altoslib/AltosFrequency.java
altoslib/AltosJson.java
altoslib/AltosLatLon.java
altoslib/AltosPointDouble.java
altoslib/AltosUnits.java

index 58f503c..85e7dbf 100644 (file)
@@ -27,7 +27,7 @@ public class AltosFrequency {
        public String   description;
 
        public int hashCode() {
-               return new Double(frequency).hashCode();
+               return Double.valueOf(frequency).hashCode();
        }
 
        public boolean equals(Object o) {
index b981c36..8f6897b 100644 (file)
@@ -623,7 +623,7 @@ public class AltosJson extends JsonUtil {
                        }
                        break;
                case type_long:
-                       result.append(new Long(l_number).toString());
+                       result.append(Long.valueOf(l_number).toString());
                        break;
                case type_string:
                        quote(result, string);
@@ -1036,6 +1036,7 @@ public class AltosJson extends JsonUtil {
         * all inner classes are only members of their immediate outer
         * class
         */
+       @SuppressWarnings("unchecked")
        private Object make(Class c, Class enclosing_class, Object enclosing_object) {
                Object  ret;
                if (c == Boolean.TYPE) {
@@ -1105,7 +1106,7 @@ public class AltosJson extends JsonUtil {
                                        Constructor<?> ctor = ((Class<?>)c).getDeclaredConstructor((Class<?>) enclosing_class);
                                        object = ctor.newInstance(enclosing_object);
                                } else {
-                                       object = c.newInstance();
+                                       object = c.getDeclaredConstructor().newInstance();
                                }
                                for (; c != Object.class; c = c.getSuperclass()) {
                                        for (Field field : c.getDeclaredFields()) {
index cd7015e..277858f 100644 (file)
@@ -23,7 +23,7 @@ public class AltosLatLon {
        public double   lon;
 
        public int hashCode() {
-               return new Double(lat).hashCode() ^ new Double(lon).hashCode();
+               return Double.valueOf(lat).hashCode() ^ Double.valueOf(lon).hashCode();
        }
 
        public boolean equals(Object o) {
index 59e2f76..f775738 100644 (file)
@@ -22,7 +22,7 @@ public class AltosPointDouble {
        public double   x, y;
 
        public int hashCode() {
-               return new Double(x).hashCode() ^ new Double(y).hashCode();
+               return Double.valueOf(x).hashCode() ^ Double.valueOf(y).hashCode();
        }
 
        public boolean equals(Object o) {
index 9295b8e..6e49214 100644 (file)
@@ -42,7 +42,7 @@ public abstract class AltosUnits {
        public abstract double inverse(double v, boolean imperial_units);
 
        public String string_value(double v, boolean imperial_units) {
-               return new Double(value(v, imperial_units)).toString();
+               return Double.valueOf(value(v, imperial_units)).toString();
        }
 
        public abstract String show_units(boolean imperial_units);