From f7b6d39f21cbf0cfd3b423da64780e670996b789 Mon Sep 17 00:00:00 2001 From: Sanddust Date: Wed, 29 Jul 2020 16:00:16 -0500 Subject: [PATCH] XStream modules are using to be deleted Java APIs - Java9 version #211 https://github.com/x-stream/xstream/issues/211 Updates from CodeUpdater https://j2eeguys.com/updater/ Also-by: Steve Davidson Signed-off-by: Sanddust --- .../xstream/tools/benchmark/model/Five.java | 2 +- .../tools/benchmark/model/FiveBean.java | 2 +- .../benchmark/model/SerializableFive.java | 2 +- .../tools/benchmark/targets/BasicTarget.java | 12 +++++----- .../benchmark/targets/ExtendedTarget.java | 2 +- .../converters/basic/ByteConverter.java | 2 +- .../converters/basic/CharConverter.java | 6 ++--- .../converters/basic/IntConverter.java | 2 +- .../converters/basic/LongConverter.java | 2 +- .../converters/basic/ShortConverter.java | 2 +- .../extended/StackTraceElementFactory.java | 2 +- .../reflection/CGLIBEnhancedConverter.java | 6 ++--- .../reflection/ExternalizableConverter.java | 2 +- .../PureJavaReflectionProvider.java | 2 +- .../SunUnsafeReflectionProvider.java | 2 +- .../com/thoughtworks/xstream/core/JVM.java | 12 +++++----- .../core/util/CustomObjectOutputStream.java | 22 +++++++++---------- .../xstream/core/util/Primitives.java | 16 +++++++------- .../xstream/io/binary/BinaryStreamReader.java | 4 ++-- .../xstream/io/path/PathTracker.java | 2 +- .../xstream/persistence/XmlArrayList.java | 12 +++++----- .../xstream/persistence/XmlSet.java | 4 ++-- 22 files changed, 60 insertions(+), 60 deletions(-) diff --git a/xstream-benchmark/src/java/com/thoughtworks/xstream/tools/benchmark/model/Five.java b/xstream-benchmark/src/java/com/thoughtworks/xstream/tools/benchmark/model/Five.java index 4059ea0c3..5a1daaa42 100644 --- a/xstream-benchmark/src/java/com/thoughtworks/xstream/tools/benchmark/model/Five.java +++ b/xstream-benchmark/src/java/com/thoughtworks/xstream/tools/benchmark/model/Five.java @@ -38,6 +38,6 @@ public boolean equals(Object obj) { } public int hashCode() { - return super.hashCode() + two + new Boolean(three).hashCode() + five.toString().hashCode(); + return super.hashCode() + two + Boolean.valueOf(three).hashCode() + five.toString().hashCode(); } } \ No newline at end of file diff --git a/xstream-benchmark/src/java/com/thoughtworks/xstream/tools/benchmark/model/FiveBean.java b/xstream-benchmark/src/java/com/thoughtworks/xstream/tools/benchmark/model/FiveBean.java index 021156dcb..cd2de248e 100644 --- a/xstream-benchmark/src/java/com/thoughtworks/xstream/tools/benchmark/model/FiveBean.java +++ b/xstream-benchmark/src/java/com/thoughtworks/xstream/tools/benchmark/model/FiveBean.java @@ -62,6 +62,6 @@ public boolean equals(Object obj) { } public int hashCode() { - return super.hashCode() + two + new Boolean(three).hashCode() + five.toString().hashCode(); + return super.hashCode() + two + Boolean.valueOf(three).hashCode() + five.toString().hashCode(); } } \ No newline at end of file diff --git a/xstream-benchmark/src/java/com/thoughtworks/xstream/tools/benchmark/model/SerializableFive.java b/xstream-benchmark/src/java/com/thoughtworks/xstream/tools/benchmark/model/SerializableFive.java index 53e34152d..7855c4b10 100644 --- a/xstream-benchmark/src/java/com/thoughtworks/xstream/tools/benchmark/model/SerializableFive.java +++ b/xstream-benchmark/src/java/com/thoughtworks/xstream/tools/benchmark/model/SerializableFive.java @@ -51,6 +51,6 @@ public boolean equals(Object obj) { } public int hashCode() { - return super.hashCode() + two + new Boolean(three).hashCode() + five.toString().hashCode(); + return super.hashCode() + two + Boolean.valueOf(three).hashCode() + five.toString().hashCode(); } } \ No newline at end of file diff --git a/xstream-benchmark/src/java/com/thoughtworks/xstream/tools/benchmark/targets/BasicTarget.java b/xstream-benchmark/src/java/com/thoughtworks/xstream/tools/benchmark/targets/BasicTarget.java index a119f5742..bbdd19691 100644 --- a/xstream-benchmark/src/java/com/thoughtworks/xstream/tools/benchmark/targets/BasicTarget.java +++ b/xstream-benchmark/src/java/com/thoughtworks/xstream/tools/benchmark/targets/BasicTarget.java @@ -30,14 +30,14 @@ public class BasicTarget implements Target { public BasicTarget() { list = new ArrayList(); - list.add(new Integer(1)); - list.add(new Byte((byte)2)); - list.add(new Short((short)3)); - list.add(new Long(4)); + list.add(Integer.valueOf(1)); + list.add(Byte.valueOf((byte)2)); + list.add(Short.valueOf((short)3)); + list.add(Long.valueOf(4)); list.add("Profile"); list.add(Boolean.TRUE); - list.add(new Float(1.2f)); - list.add(new Double(1.2f)); + list.add(Float.valueOf(1.2f)); + list.add(Double.valueOf(1.2f)); list.add(new File("profile.txt")); list.add(Locale.ENGLISH); } diff --git a/xstream-benchmark/src/java/com/thoughtworks/xstream/tools/benchmark/targets/ExtendedTarget.java b/xstream-benchmark/src/java/com/thoughtworks/xstream/tools/benchmark/targets/ExtendedTarget.java index 62195da79..8c39ac41f 100644 --- a/xstream-benchmark/src/java/com/thoughtworks/xstream/tools/benchmark/targets/ExtendedTarget.java +++ b/xstream-benchmark/src/java/com/thoughtworks/xstream/tools/benchmark/targets/ExtendedTarget.java @@ -86,7 +86,7 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl if (method.equals(EQUALS)) { return new Boolean(args[0] instanceof Runnable); } else if (method.getName().equals("hashCode")) { - return new Integer(System.identityHashCode(proxy)); + return Integer.valueOf(System.identityHashCode(proxy)); } else if (method.getName().equals("toString")) { return "Proxy" + System.identityHashCode(proxy); } else if (method.getName().equals("getClass")) { diff --git a/xstream/src/java/com/thoughtworks/xstream/converters/basic/ByteConverter.java b/xstream/src/java/com/thoughtworks/xstream/converters/basic/ByteConverter.java index d05935283..f1f1df432 100644 --- a/xstream/src/java/com/thoughtworks/xstream/converters/basic/ByteConverter.java +++ b/xstream/src/java/com/thoughtworks/xstream/converters/basic/ByteConverter.java @@ -28,7 +28,7 @@ public Object fromString(String str) { if(value < Byte.MIN_VALUE || value > 0xFF) { throw new NumberFormatException("For input string: \"" + str + '"'); } - return new Byte((byte)value); + return Byte.valueOf((byte)value); } } diff --git a/xstream/src/java/com/thoughtworks/xstream/converters/basic/CharConverter.java b/xstream/src/java/com/thoughtworks/xstream/converters/basic/CharConverter.java index 0e105673c..2b225198d 100644 --- a/xstream/src/java/com/thoughtworks/xstream/converters/basic/CharConverter.java +++ b/xstream/src/java/com/thoughtworks/xstream/converters/basic/CharConverter.java @@ -38,7 +38,7 @@ public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingC public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { String nullAttribute = reader.getAttribute("null"); if (nullAttribute != null && nullAttribute.equals("true")) { - return new Character('\0'); + return Character.valueOf('\0'); } else { return fromString(reader.getValue()); } @@ -46,9 +46,9 @@ public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext co public Object fromString(String str) { if (str.length() == 0) { - return new Character('\0'); + return Character.valueOf('\0'); } else { - return new Character(str.charAt(0)); + return Character.valueOf(str.charAt(0)); } } diff --git a/xstream/src/java/com/thoughtworks/xstream/converters/basic/IntConverter.java b/xstream/src/java/com/thoughtworks/xstream/converters/basic/IntConverter.java index 49086a65e..1f44cba93 100644 --- a/xstream/src/java/com/thoughtworks/xstream/converters/basic/IntConverter.java +++ b/xstream/src/java/com/thoughtworks/xstream/converters/basic/IntConverter.java @@ -28,7 +28,7 @@ public Object fromString(String str) { if(value < Integer.MIN_VALUE || value > 0xFFFFFFFFl) { throw new NumberFormatException("For input string: \"" + str + '"'); } - return new Integer((int)value); + return Integer.valueOf((int)value); } } diff --git a/xstream/src/java/com/thoughtworks/xstream/converters/basic/LongConverter.java b/xstream/src/java/com/thoughtworks/xstream/converters/basic/LongConverter.java index ac44dd6db..a5e49ea7f 100644 --- a/xstream/src/java/com/thoughtworks/xstream/converters/basic/LongConverter.java +++ b/xstream/src/java/com/thoughtworks/xstream/converters/basic/LongConverter.java @@ -50,7 +50,7 @@ public Object fromString(String str) { return Long.decode(str); } final long num = high | low; - return new Long(num); + return Long.valueOf(num); } } diff --git a/xstream/src/java/com/thoughtworks/xstream/converters/basic/ShortConverter.java b/xstream/src/java/com/thoughtworks/xstream/converters/basic/ShortConverter.java index b8d11da88..78c0a1807 100644 --- a/xstream/src/java/com/thoughtworks/xstream/converters/basic/ShortConverter.java +++ b/xstream/src/java/com/thoughtworks/xstream/converters/basic/ShortConverter.java @@ -28,7 +28,7 @@ public Object fromString(String str) { if(value < Short.MIN_VALUE || value > 0xFFFF) { throw new NumberFormatException("For input string: \"" + str + '"'); } - return new Short((short)value); + return Short.valueOf((short)value); } } diff --git a/xstream/src/java/com/thoughtworks/xstream/converters/extended/StackTraceElementFactory.java b/xstream/src/java/com/thoughtworks/xstream/converters/extended/StackTraceElementFactory.java index c480653aa..32e102c0e 100644 --- a/xstream/src/java/com/thoughtworks/xstream/converters/extended/StackTraceElementFactory.java +++ b/xstream/src/java/com/thoughtworks/xstream/converters/extended/StackTraceElementFactory.java @@ -48,7 +48,7 @@ protected StackTraceElement create(final String declaringClass, final String met setField(result, "declaringClass", declaringClass); setField(result, "methodName", methodName); setField(result, "fileName", fileName); - setField(result, "lineNumber", new Integer(lineNumber)); + setField(result, "lineNumber", Integer.valueOf(lineNumber)); return result; } diff --git a/xstream/src/java/com/thoughtworks/xstream/converters/reflection/CGLIBEnhancedConverter.java b/xstream/src/java/com/thoughtworks/xstream/converters/reflection/CGLIBEnhancedConverter.java index 3e0d8a1ca..262d1c7e2 100644 --- a/xstream/src/java/com/thoughtworks/xstream/converters/reflection/CGLIBEnhancedConverter.java +++ b/xstream/src/java/com/thoughtworks/xstream/converters/reflection/CGLIBEnhancedConverter.java @@ -283,7 +283,7 @@ private Map createCallbackIndexMap(Factory source) { } } if (idxNoOp >= 0) { - Integer idx = new Integer(idxNoOp); + Integer idx = Integer.valueOf(idxNoOp); for (final Iterator iter = methods.iterator(); iter.hasNext();) { callbackIndexMap.put(iter.next(), idx); } @@ -306,7 +306,7 @@ private Object[] createNullArguments(Class[] parameterTypes) { } else if (type == short.class) { arguments[i] = new Short((short)0); } else if (type == int.class) { - arguments[i] = new Integer(0); + arguments[i] = Integer.valueOf(0); } else if (type == long.class) { arguments[i] = new Long(0); } else if (type == float.class) { @@ -464,7 +464,7 @@ private static final class ReverseEngineeringInvocationHandler implements Invoca public ReverseEngineeringInvocationHandler(int index, Map indexMap) { this.indexMap = indexMap; - this.index = new Integer(index); + this.index = Integer.valueOf(index); } public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { diff --git a/xstream/src/java/com/thoughtworks/xstream/converters/reflection/ExternalizableConverter.java b/xstream/src/java/com/thoughtworks/xstream/converters/reflection/ExternalizableConverter.java index fd89d89e2..d50f097cf 100644 --- a/xstream/src/java/com/thoughtworks/xstream/converters/reflection/ExternalizableConverter.java +++ b/xstream/src/java/com/thoughtworks/xstream/converters/reflection/ExternalizableConverter.java @@ -135,7 +135,7 @@ public Object unmarshal(final HierarchicalStreamReader reader, final Unmarshalli final Constructor defaultConstructor; try { defaultConstructor = type.getDeclaredConstructor((Class[]) null); - if (!defaultConstructor.isAccessible()) { + if (!defaultConstructor.canAccess(null)) { defaultConstructor.setAccessible(true); } final Externalizable externalizable = (Externalizable) defaultConstructor.newInstance((Object[]) null); diff --git a/xstream/src/java/com/thoughtworks/xstream/converters/reflection/PureJavaReflectionProvider.java b/xstream/src/java/com/thoughtworks/xstream/converters/reflection/PureJavaReflectionProvider.java index c7d837c42..0efe16ee8 100644 --- a/xstream/src/java/com/thoughtworks/xstream/converters/reflection/PureJavaReflectionProvider.java +++ b/xstream/src/java/com/thoughtworks/xstream/converters/reflection/PureJavaReflectionProvider.java @@ -64,7 +64,7 @@ public Object newInstance(Class type) { for (int i = 0; i < constructors.length; i++) { final Constructor constructor = constructors[i]; if (constructor.getParameterTypes().length == 0) { - if (!constructor.isAccessible()) { + if (!constructor.canAccess(null)) { constructor.setAccessible(true); } return constructor.newInstance(new Object[0]); diff --git a/xstream/src/java/com/thoughtworks/xstream/converters/reflection/SunUnsafeReflectionProvider.java b/xstream/src/java/com/thoughtworks/xstream/converters/reflection/SunUnsafeReflectionProvider.java index 4c1302308..b5f59d887 100644 --- a/xstream/src/java/com/thoughtworks/xstream/converters/reflection/SunUnsafeReflectionProvider.java +++ b/xstream/src/java/com/thoughtworks/xstream/converters/reflection/SunUnsafeReflectionProvider.java @@ -102,7 +102,7 @@ private void write(Field field, Object object, Object value) { private synchronized long getFieldOffset(Field f) { Long l = (Long)fieldOffsetCache.get(f); if (l == null) { - l = new Long(unsafe.objectFieldOffset(f)); + l = Long.valueOf(unsafe.objectFieldOffset(f)); fieldOffsetCache.put(f, l); } diff --git a/xstream/src/java/com/thoughtworks/xstream/core/JVM.java b/xstream/src/java/com/thoughtworks/xstream/core/JVM.java index 65a053e21..ed393c42f 100644 --- a/xstream/src/java/com/thoughtworks/xstream/core/JVM.java +++ b/xstream/src/java/com/thoughtworks/xstream/core/JVM.java @@ -98,13 +98,13 @@ static class Test { Test t = (Test)provider.newInstance(Test.class); try { provider.writeField(t, "o", "object", Test.class); - provider.writeField(t, "c", new Character('c'), Test.class); - provider.writeField(t, "b", new Byte((byte)1), Test.class); + provider.writeField(t, "c", Character.valueOf('c'), Test.class); + provider.writeField(t, "b", Byte.valueOf((byte)1), Test.class); provider.writeField(t, "s", new Short((short)1), Test.class); - provider.writeField(t, "i", new Integer(1), Test.class); - provider.writeField(t, "l", new Long(1), Test.class); - provider.writeField(t, "f", new Float(1), Test.class); - provider.writeField(t, "d", new Double(1), Test.class); + provider.writeField(t, "i", Integer.valueOf(1), Test.class); + provider.writeField(t, "l", Long.valueOf(1), Test.class); + provider.writeField(t, "f", Float.valueOf(1), Test.class); + provider.writeField(t, "d", Double.valueOf(1), Test.class); provider.writeField(t, "bool", Boolean.TRUE, Test.class); test = true; } catch(IncompatibleClassChangeError e) { diff --git a/xstream/src/java/com/thoughtworks/xstream/core/util/CustomObjectOutputStream.java b/xstream/src/java/com/thoughtworks/xstream/core/util/CustomObjectOutputStream.java index a354005a2..e21e3269d 100644 --- a/xstream/src/java/com/thoughtworks/xstream/core/util/CustomObjectOutputStream.java +++ b/xstream/src/java/com/thoughtworks/xstream/core/util/CustomObjectOutputStream.java @@ -96,23 +96,23 @@ public void writeByte(int val) throws IOException { } public void writeInt(int val) throws IOException { - peekCallback().writeToStream(new Integer(val)); + peekCallback().writeToStream(Integer.valueOf(val)); } public void writeChar(int val) throws IOException { - peekCallback().writeToStream(new Character((char)val)); + peekCallback().writeToStream(Character.valueOf((char)val)); } public void writeDouble(double val) throws IOException { - peekCallback().writeToStream(new Double(val)); + peekCallback().writeToStream(Double.valueOf(val)); } public void writeFloat(float val) throws IOException { - peekCallback().writeToStream(new Float(val)); + peekCallback().writeToStream(Float.valueOf(val)); } public void writeLong(long val) throws IOException { - peekCallback().writeToStream(new Long(val)); + peekCallback().writeToStream(Long.valueOf(val)); } public void writeShort(int val) throws IOException { @@ -177,27 +177,27 @@ public void put(String name, Object val) { } public void put(String name, byte val) { - put(name, new Byte(val)); + put(name, Byte.valueOf(val)); } public void put(String name, char val) { - put(name, new Character(val)); + put(name, Character.valueOf(val)); } public void put(String name, double val) { - put(name, new Double(val)); + put(name, Double.valueOf(val)); } public void put(String name, float val) { - put(name, new Float(val)); + put(name, Float.valueOf(val)); } public void put(String name, int val) { - put(name, new Integer(val)); + put(name, Integer.valueOf(val)); } public void put(String name, long val) { - put(name, new Long(val)); + put(name, Long.valueOf(val)); } public void put(String name, short val) { diff --git a/xstream/src/java/com/thoughtworks/xstream/core/util/Primitives.java b/xstream/src/java/com/thoughtworks/xstream/core/util/Primitives.java index 7a9528296..2bc0e9dfd 100644 --- a/xstream/src/java/com/thoughtworks/xstream/core/util/Primitives.java +++ b/xstream/src/java/com/thoughtworks/xstream/core/util/Primitives.java @@ -38,14 +38,14 @@ public final class Primitives { { Void.TYPE, Void.class}, }; final Character[] representingChars = { - new Character('B'), - new Character('C'), - new Character('S'), - new Character('I'), - new Character('J'), - new Character('F'), - new Character('D'), - new Character('Z'), + Character.valueOf('B'), + Character.valueOf('C'), + Character.valueOf('S'), + Character.valueOf('I'), + Character.valueOf('J'), + Character.valueOf('F'), + Character.valueOf('D'), + Character.valueOf('Z'), null }; for (int i = 0; i < boxing.length; i++) { diff --git a/xstream/src/java/com/thoughtworks/xstream/io/binary/BinaryStreamReader.java b/xstream/src/java/com/thoughtworks/xstream/io/binary/BinaryStreamReader.java index 28396517f..bef778162 100644 --- a/xstream/src/java/com/thoughtworks/xstream/io/binary/BinaryStreamReader.java +++ b/xstream/src/java/com/thoughtworks/xstream/io/binary/BinaryStreamReader.java @@ -205,11 +205,11 @@ private static class IdRegistry { private Map map = new HashMap(); public void put(long id, String value) { - map.put(new Long(id), value); + map.put(Long.valueOf(id), value); } public String get(long id) { - String result = (String) map.get(new Long(id)); + String result = (String) map.get(Long.valueOf(id)); if (result == null) { throw new StreamException("Unknown ID : " + id); } else { diff --git a/xstream/src/java/com/thoughtworks/xstream/io/path/PathTracker.java b/xstream/src/java/com/thoughtworks/xstream/io/path/PathTracker.java index 76b25cd66..c1a641585 100644 --- a/xstream/src/java/com/thoughtworks/xstream/io/path/PathTracker.java +++ b/xstream/src/java/com/thoughtworks/xstream/io/path/PathTracker.java @@ -85,7 +85,7 @@ public void pushElement(String name) { if (indexMap.containsKey(name)) { indexMap.put(name, new Integer(((Integer) indexMap.get(name)).intValue() + 1)); } else { - indexMap.put(name, new Integer(1)); + indexMap.put(name, Integer.valueOf(1)); } pointer++; currentPath = null; diff --git a/xstream/src/java/com/thoughtworks/xstream/persistence/XmlArrayList.java b/xstream/src/java/com/thoughtworks/xstream/persistence/XmlArrayList.java index 2a16e3717..a9d5ef4d1 100644 --- a/xstream/src/java/com/thoughtworks/xstream/persistence/XmlArrayList.java +++ b/xstream/src/java/com/thoughtworks/xstream/persistence/XmlArrayList.java @@ -33,7 +33,7 @@ public int size() { public Object set(int index, Object element) { rangeCheck(index); Object value = get(index); - map.put(new Integer(index), element); + map.put(Integer.valueOf(index), element); return value; } @@ -45,9 +45,9 @@ public void add(int index, Object element) { } int to = index != size ? index - 1 : index; for (int i = size; i > to; i--) { - map.put(new Integer(i + 1), map.get(new Integer(i))); + map.put(new Integer(i + 1), map.get(Integer.valueOf(i))); } - map.put(new Integer(index), element); + map.put(Integer.valueOf(index), element); } private void rangeCheck(int index) { @@ -60,15 +60,15 @@ private void rangeCheck(int index) { public Object get(int index) { rangeCheck(index); - return map.get(new Integer(index)); + return map.get(Integer.valueOf(index)); } public Object remove(int index) { int size = size(); rangeCheck(index); - Object value = map.get(new Integer(index)); + Object value = map.get(Integer.valueOf(index)); for (int i = index; i < size - 1; i++) { - map.put(new Integer(i), map.get(new Integer(i + 1))); + map.put(Integer.valueOf(i), map.get(new Integer(i + 1))); } map.remove(new Integer(size - 1)); return value; diff --git a/xstream/src/java/com/thoughtworks/xstream/persistence/XmlSet.java b/xstream/src/java/com/thoughtworks/xstream/persistence/XmlSet.java index c48ef3958..bba40adce 100644 --- a/xstream/src/java/com/thoughtworks/xstream/persistence/XmlSet.java +++ b/xstream/src/java/com/thoughtworks/xstream/persistence/XmlSet.java @@ -47,10 +47,10 @@ public boolean add(Object o) { private Long findEmptyKey() { long i = System.currentTimeMillis(); - while (map.containsKey(new Long(i))) { + while (map.containsKey(Long.valueOf(i))) { i++; } - return new Long(i); + return Long.valueOf(i); } }