The javadoc for public static URL getSystemResource(String name) reads:
* In JDK1.1, the search path used is that of the virtual machine's
* built-in class loader.<p>
*
* Since JDK1.2, this method locates the resource through the system class
* loader (see {@link #getSystemClassLoader()}).
The comment in JDK1.1 is either not clear or wrong. In 1.1, does the VM's built in class loader see the application classpath too? If so, then there is no diff
between 1.1 and 1.2. If not, then this contradicts the actual behavior.
Here's a test program that calls this method. If you have a index.html
file in the application's classpath (set using CLASSPATH env var),
then getResource() will see it (albeit giving it some weird URL).Here's the
sample output:
alto# set path = (/usr/local/java/jdk1.1.7/solaris/bin $path)
alto# java Main
systemresource:/FILE0/+/index.html
alto<# mv index.html /tmp
alto# setenv CLASSPATH /tmp\:.
alto# java Main
systemresource:/FILE0/+/index.html
alto# unsetenv CLASSPATH
alto# java Main
null
alto# cat Main.java
public class Main {
public static void main(String[] args) {
System.out.println(
ClassLoader.getSystemResource("index.html"));
}
}
Other related methods in ClassLoader use similar wording and should
be fix if these comments are changed.