mirror of
https://github.com/FranzHaidnor/haidnorJVM.git
synced 2026-03-13 21:43:42 +08:00
fix bug 修复 ClassLoader 读取不到自身 jar 文件内的配置文件
This commit is contained in:
@@ -23,17 +23,10 @@ public class ClassLoader {
|
||||
public JarFile jarFile = null;
|
||||
|
||||
static {
|
||||
URL resource = ClassLoader.class.getResource("/");
|
||||
String path = resource.getPath();
|
||||
FileInputStream fis;
|
||||
try {
|
||||
fis = new FileInputStream(path + "/haidnorJVM.properties");
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
InputStream is = ClassLoader.class.getResourceAsStream("/haidnorJVM.properties");
|
||||
Properties properties = new Properties();
|
||||
try {
|
||||
properties.load(fis);
|
||||
properties.load(is);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ public class TestJVM {
|
||||
runMainClass(demo_finally_2.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test(expected = ArithmeticException.class)
|
||||
public void demo_finally_3() throws Exception {
|
||||
runMainClass(demo_finally_3.class);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user