mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-04 05:05:09 +00:00
Fixed Warnings about invalid reflective access in color dialog on Java 9+
This commit is contained in:
@@ -648,12 +648,12 @@ public class Helper {
|
||||
public static <E> E deepCopy(E o) {
|
||||
try {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
try (ObjectOutputStream oos = new ObjectOutputStream(baos)) {
|
||||
try ( ObjectOutputStream oos = new ObjectOutputStream(baos)) {
|
||||
oos.writeObject(o);
|
||||
oos.flush();
|
||||
}
|
||||
E copy;
|
||||
try (ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()))) {
|
||||
try ( ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()))) {
|
||||
copy = (E) ois.readObject();
|
||||
}
|
||||
return copy;
|
||||
@@ -694,7 +694,7 @@ public class Helper {
|
||||
public static byte[] readFile(String... file) {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
for (String f : file) {
|
||||
try (FileInputStream fis = new FileInputStream(f)) {
|
||||
try ( FileInputStream fis = new FileInputStream(f)) {
|
||||
byte[] buf = new byte[4096];
|
||||
int cnt;
|
||||
while ((cnt = fis.read(buf)) > 0) {
|
||||
@@ -798,7 +798,7 @@ public class Helper {
|
||||
}
|
||||
|
||||
public static void appendFile(String file, byte[]... data) {
|
||||
try (FileOutputStream fos = new FileOutputStream(file, true)) {
|
||||
try ( FileOutputStream fos = new FileOutputStream(file, true)) {
|
||||
for (byte[] d : data) {
|
||||
fos.write(d);
|
||||
}
|
||||
@@ -808,7 +808,7 @@ public class Helper {
|
||||
}
|
||||
|
||||
public static void writeFile(String file, byte[]... data) {
|
||||
try (FileOutputStream fos = new FileOutputStream(file)) {
|
||||
try ( FileOutputStream fos = new FileOutputStream(file)) {
|
||||
for (byte[] d : data) {
|
||||
fos.write(d);
|
||||
}
|
||||
@@ -818,7 +818,7 @@ public class Helper {
|
||||
}
|
||||
|
||||
public static void writeFile(String file, InputStream stream) {
|
||||
try (FileOutputStream fos = new FileOutputStream(file)) {
|
||||
try ( FileOutputStream fos = new FileOutputStream(file)) {
|
||||
copyStream(stream, fos);
|
||||
} catch (IOException ex) {
|
||||
// ignore
|
||||
@@ -938,7 +938,7 @@ public class Helper {
|
||||
}
|
||||
try {
|
||||
f.setAccessible(true);
|
||||
|
||||
|
||||
Object v = f.get(obj);
|
||||
if (v != null) {
|
||||
try {
|
||||
@@ -1167,7 +1167,7 @@ public class Helper {
|
||||
public static void saveStream(InputStream is, File output) throws IOException {
|
||||
byte[] buf = new byte[4096];
|
||||
int cnt;
|
||||
try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(output))) {
|
||||
try ( OutputStream fos = new BufferedOutputStream(new FileOutputStream(output))) {
|
||||
while ((cnt = is.read(buf)) > 0) {
|
||||
fos.write(buf, 0, cnt);
|
||||
fos.flush();
|
||||
@@ -1581,4 +1581,16 @@ public class Helper {
|
||||
String text = new String(data, Utf8Helper.charset);
|
||||
return text;
|
||||
}
|
||||
|
||||
public static int getJavaVersion() {
|
||||
String version = System.getProperty("java.version");
|
||||
if (version.startsWith("1.")) {
|
||||
version = version.substring(2, 3);
|
||||
}
|
||||
int dot = version.indexOf(".");
|
||||
if (dot != -1) {
|
||||
version = version.substring(0, dot);
|
||||
}
|
||||
return Integer.parseInt(version);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user