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;
|
public JarFile jarFile = null;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
URL resource = ClassLoader.class.getResource("/");
|
InputStream is = ClassLoader.class.getResourceAsStream("/haidnorJVM.properties");
|
||||||
String path = resource.getPath();
|
|
||||||
FileInputStream fis;
|
|
||||||
try {
|
|
||||||
fis = new FileInputStream(path + "/haidnorJVM.properties");
|
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
try {
|
try {
|
||||||
properties.load(fis);
|
properties.load(is);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ public class TestJVM {
|
|||||||
runMainClass(demo_finally_2.class);
|
runMainClass(demo_finally_2.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected = ArithmeticException.class)
|
||||||
public void demo_finally_3() throws Exception {
|
public void demo_finally_3() throws Exception {
|
||||||
runMainClass(demo_finally_3.class);
|
runMainClass(demo_finally_3.class);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user