mirror of
https://github.com/shadowfacts/jinput-arm64.git
synced 2026-01-05 00:09:57 +01:00
Close resources as per PR #10
This commit is contained in:
parent
b6150acbce
commit
796c4780fd
|
|
@ -117,13 +117,14 @@ class PluginClassLoader extends ClassLoader {
|
|||
if (!file.exists()) {
|
||||
throw new ClassNotFoundException(name);
|
||||
}
|
||||
FileInputStream fileInputStream = new FileInputStream(file);
|
||||
assert file.length() <= Integer.MAX_VALUE;
|
||||
int length = (int)file.length();
|
||||
byte[] bytes = new byte[length];
|
||||
int length2 = fileInputStream.read(bytes);
|
||||
assert length == length2;
|
||||
return bytes;
|
||||
try(FileInputStream fileInputStream = new FileInputStream(file)) {
|
||||
assert file.length() <= Integer.MAX_VALUE;
|
||||
int length = (int) file.length();
|
||||
byte[] bytes = new byte[length];
|
||||
int length2 = fileInputStream.read(bytes);
|
||||
assert length == length2;
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -141,14 +142,15 @@ class PluginClassLoader extends ClassLoader {
|
|||
JarFile jarfile = new JarFile(jarFiles[i]);
|
||||
JarEntry jarentry = jarfile.getJarEntry(name + ".class");
|
||||
if (jarentry != null) {
|
||||
InputStream jarInputStream = jarfile.getInputStream(jarentry);
|
||||
assert jarentry.getSize() <= Integer.MAX_VALUE;
|
||||
int length = (int)jarentry.getSize();
|
||||
assert length >= 0;
|
||||
byte[] bytes = new byte[length];
|
||||
int length2 = jarInputStream.read(bytes);
|
||||
assert length == length2;
|
||||
return bytes;
|
||||
try(InputStream jarInputStream = jarfile.getInputStream(jarentry)) {
|
||||
assert jarentry.getSize() <= Integer.MAX_VALUE;
|
||||
int length = (int) jarentry.getSize();
|
||||
assert length >= 0;
|
||||
byte[] bytes = new byte[length];
|
||||
int length2 = jarInputStream.read(bytes);
|
||||
assert length == length2;
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new FileNotFoundException(name);
|
||||
|
|
|
|||
Loading…
Reference in a new issue