-
Bug
-
Resolution: Fixed
-
P4
-
1.1.8
-
beta
-
sparc
-
solaris_2.5
-
Verified
Name: saC57035 Date: 04/26/99
java.lang.Class.getResourceAsStream(null) returns something strange under
1.1.8 and throws NullPointerException under 1.2, though according to the
documentation "...method returns null if no resource with this name is
found". Throwing NullPointerException for null argument might be valid,
although it's worth to mention that this method used to return null in
1.2 beta releases. Anyway, the specs should explicitly state what is
expected in this case.
Here is the test demonstrating the bug:
-----------------Test.java------------------------
public class Test {
public static void main(String[] args){
System.out.println(Test.class.getResourceAsStream(null));
}
}
---------Output from the test under 1.1.8---------
java.io.FileInputStream@1dc6088b
---------Output from the test under 1.2.2---------
java.lang.NullPointerException
at java.util.zip.ZipFile.getEntry(ZipFile.java, Compiled Code)
at java.util.jar.JarFile.getEntry(JarFile.java, Compiled Code)
at java.util.jar.JarFile.getJarEntry(JarFile.java, Compiled Code)
at sun.misc.URLClassPath$JarLoader.getResource(URLClassPath.java, Compiled Code)
at sun.misc.URLClassPath.getResource(URLClassPath.java, Compiled Code)
at sun.misc.URLClassPath.getResource(URLClassPath.java, Compiled Code)
at java.lang.ClassLoader.getBootstrapResource(ClassLoader.java, Compiled Code)
at java.lang.ClassLoader.getResource(ClassLoader.java, Compiled Code)
at java.lang.ClassLoader.getResource(ClassLoader.java, Compiled Code)
at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java, Compiled Code)
at java.lang.Class.getResourceAsStream(Class.java, Compiled Code)
at Test.main(Test.java, Compiled Code)
--------------------------------------------------
It should be mentioned, that most probably the roots of the problem are in
the ClassLoader class, as is seen from the output under 1.2.2.
======================================================================