RFR (XXS) 8027803: NPE in test infrastructure aka: test/sun/reflect/AnonymousNewInstance/ManyNewInstanceAnonTest.java fails
Kumar Srinivasan
kumar.x.srinivasan at oracle.com
Sun Nov 10 17:11:15 UTC 2013
Looks good.
Kumar
----- robert.field at oracle.com wrote:
> From: robert.field at oracle.com
> To: core-libs-dev at openjdk.java.net
> Cc: joel.franck at oracle.com, kumar.x.srinivasan at oracle.com, Alan.Bateman at oracle.com
> Sent: Saturday, November 9, 2013 11:24:40 PM GMT -08:00 US/Canada Pacific
> Subject: RFR (XXS) 8027803: NPE in test infrastructure aka: test/sun/reflect/AnonymousNewInstance/ManyNewInstanceAnonTest.java fails
>
>
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