RFR (XXS) 8027803: NPE in test infrastructure aka: test/sun/reflect/AnonymousNewInstance/ManyNewInstanceAnonTest.java fails
Robert Field
robert.field at oracle.com
Sun Nov 10 07:24:31 UTC 2013
Please review the fix for:
https://bugs.openjdk.java.net/browse/JDK-8027803
Basically, the ClassFileInstaller test utility is getting a Null Pointer
Exception when the installed class file is in the default package (no
package declared). And the fix is to check for the null that occurs in
that case --
test/lib/testlibrary/ClassFileInstaller.java
------------------------------------------------------------------------
28 import java.nio.file.StandardCopyOption;
29
30 /**
31 * Dump a class file for a class on the class path in the current directory
32 */
33 public class ClassFileInstaller {
34 /**
35 * @param args The names of the classes to dump
36 * @throws Exception
37 */
38 public static void main(String... args) throws Exception {
39 for (String arg : args) {
40 ClassLoader cl = ClassFileInstaller.class.getClassLoader();
41
42 // Convert dotted class name to a path to a class file
43 String pathName = arg.replace('.', '/').concat(".class");
44 InputStream is = cl.getResourceAsStream(pathName);
45
46 // Create the class file's package directory
47 Path p = Paths.get(pathName);
48 Files.createDirectories(p.getParent());
49 // Create the class file
50 Files.copy(is, p, StandardCopyOption.REPLACE_EXISTING);
51 }
52 }
53 }
------------------------------------------------------------------------
28 import java.nio.file.StandardCopyOption;
29
30 /**
31 * Dump a class file for a class on the class path in the current directory
32 */
33 public class ClassFileInstaller {
34 /**
35 * @param args The names of the classes to dump
36 * @throws Exception
37 */
38 public static void main(String... args) throws Exception {
39 for (String arg : args) {
40 ClassLoader cl = ClassFileInstaller.class.getClassLoader();
41
42 // Convert dotted class name to a path to a class file
43 String pathName = arg.replace('.', '/').concat(".class");
44 InputStream is = cl.getResourceAsStream(pathName);
45
46 // Create the class file's package directory
47 Path p = Paths.get(pathName);
48 Path parent = p.getParent();
49 if (parent != null) {
50 Files.createDirectories(parent);
51 }
52 // Create the class file
53 Files.copy(is, p, StandardCopyOption.REPLACE_EXISTING);
54 }
55 }
56 }
Contributed by Alan Bateman.
Thanks,
Robert
More information about the core-libs-dev
mailing list