diff --git a/src/com/projectswg/common/data/Pair.java b/src/com/projectswg/common/data/Pair.java index 3bb362b..87ffe15 100644 --- a/src/com/projectswg/common/data/Pair.java +++ b/src/com/projectswg/common/data/Pair.java @@ -117,7 +117,7 @@ public class Pair implements Encodable, Persistable { // Try making our own persistable if (obj == null && Persistable.class.isAssignableFrom(klass)) { try { - obj = klass.newInstance(); + obj = klass.getConstructor().newInstance(); } catch (Exception e) { Log.e(e); } diff --git a/src/com/projectswg/common/debug/log_wrapper/FileLogWrapper.java b/src/com/projectswg/common/debug/log_wrapper/FileLogWrapper.java index 2869a5b..d2dfdaf 100644 --- a/src/com/projectswg/common/debug/log_wrapper/FileLogWrapper.java +++ b/src/com/projectswg/common/debug/log_wrapper/FileLogWrapper.java @@ -18,11 +18,6 @@ public class FileLogWrapper implements LogWrapper { writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8)); } - @Override - protected void finalize() throws IOException { - writer.close(); - } - @Override public void onLog(LogLevel level, String str) { try { diff --git a/src/com/projectswg/common/network/NetBuffer.java b/src/com/projectswg/common/network/NetBuffer.java index 99bbed3..aa0d102 100644 --- a/src/com/projectswg/common/network/NetBuffer.java +++ b/src/com/projectswg/common/network/NetBuffer.java @@ -27,6 +27,7 @@ ***********************************************************************************/ package com.projectswg.common.network; +import java.lang.reflect.InvocationTargetException; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.charset.Charset; @@ -208,7 +209,7 @@ public class NetBuffer { } public boolean getBoolean() { - return getByte() == 1 ? true : false; + return getByte() == 1; } public String getAscii() { @@ -302,12 +303,12 @@ public class NetBuffer { if (Encodable.class.isAssignableFrom(type)) { Object instance = null; try { - instance = type.newInstance(); + instance = type.getConstructor().newInstance(); ((Encodable) instance).decode(this); - } catch (InstantiationException | IllegalAccessException e) { + } catch (NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) { Log.e(e); } - + return instance; } else if (Integer.class.isAssignableFrom(type) || Integer.TYPE.isAssignableFrom(type)) return getInt(); @@ -336,11 +337,11 @@ public class NetBuffer { try { for (int i = 0; i < size; i++) { - T instance = type.newInstance(); + T instance = type.getConstructor().newInstance(); instance.decode(this); list.add(instance); } - } catch (InstantiationException | IllegalAccessException e) { + } catch (NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) { Log.e(e); } @@ -383,9 +384,9 @@ public class NetBuffer { public T getEncodable(Class type) { T instance = null; try { - instance = type.newInstance(); + instance = type.getConstructor().newInstance(); instance.decode(this); - } catch (InstantiationException | IllegalAccessException e) { + } catch (NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) { Log.e(e); } diff --git a/src/com/projectswg/common/network/packets/PacketType.java b/src/com/projectswg/common/network/packets/PacketType.java index 00148eb..6d86423 100644 --- a/src/com/projectswg/common/network/packets/PacketType.java +++ b/src/com/projectswg/common/network/packets/PacketType.java @@ -370,7 +370,7 @@ public enum PacketType { return null; Class c = type.c; try { - return c.newInstance(); + return c.getConstructor().newInstance(); } catch (Exception e) { Log.e("Packet: [%08X] %s", crc, c.getName()); Log.e(e);