Skip to content

Commit fdcfe49

Browse files
committed
FileLocator#classPathRoutine(): use the AppClassLoader directly instead of the Class#getResourceAsStream(...) algorithm
1 parent bbd6e8a commit fdcfe49

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

snaploader/src/main/java/electrostatic4j/snaploader/filesystem/FileLocator.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,12 @@ public void initialize(int size) throws IOException {
152152
protected void classPathRoutine() {
153153
SnapLoaderLogger.log(Level.INFO, getClass().getName(), "initialize(int)",
154154
"File locator initialized using classpath routine with hash key #" + getHashKey());
155-
this.fileInputStream = getClass().getResourceAsStream(filePath);
155+
// use the AppClassLoader, a BuiltinClassLoader to get the resources from the classpath
156+
// notice that the JVM Classloaders are arranged in a tree-like structure
157+
// 1) The BootStrap ClassLoader is the most ancestor
158+
// 2) The Java Platform ClassLoader is the next in the tree.
159+
// 3) The AppClassLoader is the last in the tree.
160+
this.fileInputStream = getClass().getClassLoader().getResourceAsStream(filePath);
156161
}
157162

158163
/**

0 commit comments

Comments
 (0)