db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Hillegas <rick.hille...@gmail.com>
Subject resource location problem in JDK 9 from build 148 onward
Date Mon, 16 Jan 2017 16:45:23 GMT
Dalibor Topic suggested that I pose this question to the jigsaw-dev list:

Starting (at least) with build 148, resource location has changed in a 
way which is not backward compatible with JDK 8. The following 
experiment shows the behavior change:

1) Compile the following class using JDK 8 and put it in a jar file 
called z.jar:

public class public class ResourceLocationProblem
{
   public static void main(String... args) throws Exception
   {
     String resourceName = "/META-INF/MANIFEST.MF";
     Class dummyClass = (new Object()).getClass();
     Object is = dummyClass.getResourceAsStream(resourceName);

     if (is != null) { System.out.println("Resource found."); }
     else { System.out.println("Resource NOT found!"); }
   }
}

2) Then run the program thusly:

   java -cp z.jar ResourceLocationProblem

On JDK 8, the program produces this output...

Resource found.

...while on JDK 9 build 151 the program produces this output...

Resource NOT found!

Dalibor pointed me to the following proposal, which indicates that some 
significant changes have been made to resource location: 
http://mail.openjdk.java.net/pipermail/jpms-spec-experts/2016-September/000392.html 
However, I am not trying to use any jigsaw features. This test program 
suggests that JDK 9 will break many legacy applications.

1) Is the observed behavior change a bug?

2) What is the recommended workaround?

Thanks,
-Rick

Mime
View raw message