problem with Class#getResource

Dawid Weiss dawid.weiss at gmail.com
Sun Sep 4 19:30:44 UTC 2016


This kind of "package-list" by getResources seems to be used quite
frequently in the wild... Check out this issue I filed for Log4j2.

https://issues.apache.org/jira/browse/LOG4J2-1484

I agree it's a side-effect that isn't defined in the spec (and
shouldn't be working).

Dawid

On Sun, Sep 4, 2016 at 5:32 PM, Uwe Schindler <uschindler at apache.org> wrote:
> Hi,
>
> I think this is related to multi-release JAR files because directories are no longer "unique" for the same resource. I am not 100% sure, but according to specs, Resources are only files, never directories, so I'd always say the above code is wrong and it is just caused by an implementation detail that it works at all. :-)
>
> Uwe
>
> -----
> Uwe Schindler
> uschindler at apache.org
> ASF Member, Apache Lucene PMC / Committer
> Bremen, Germany
> http://lucene.apache.org/
>> Sent: Sunday, September 4, 2016 3:36 PM
>> To: jigsaw-dev at openjdk.java.net
>> Subject: problem with Class#getResource
>>
>> Hi all,
>>
>>
>> I am using build 9-ea+132
>>
>> I have a test, that does in the setup this.class.getResource("/jars"),
>> to get a URL to the jars directory. The parent directory is on the
>> classpath, but the call returns null... This code is not run in a named
>> module.
>>
>> Can anyone tell me why that returns null with jigsaw?
>>
>> bye Jochen
>


More information about the jigsaw-dev mailing list