RFR: JDK-8210009: Source Launcher classloader should support getResource and getResourceAsStream
Jonathan Gibbons
jonathan.gibbons at oracle.com
Wed Sep 5 19:18:43 UTC 2018
On 09/04/2018 04:31 PM, mandy chung wrote:
>
>
> On 9/4/18 1:52 PM, Jonathan Gibbons wrote:
>> Please review a change to add support for the getResource* group of
>> methods
>> to the internal class loader used by the Source Launcher, introduced
>> in JEP 330.
>>
>> The overall issue has been discussed on OpenJDK lists, [1,2]
>>
>> The implementation consists of providing findResource and findResources,
>> along with a couple of minor additional classes to implement
>> URLStreamHandler
>> and URLConnection.
>>
>> There is one implementation detail worthy of note. The "new URL" should
>> be inside a doPrivileged block, but overall, the Source Launcher does
>> not
>> work when a security manager in installed. This is being tracked as
>> JDK-8210274,
>> and the appropriate doPrivileged call will be added as part of that fix.
>>
>> -- Jon
>>
>> JBS: https://bugs.openjdk.java.net/browse/JDK-8210009
>> Webrev: http://cr.openjdk.java.net/~jjg/8210009/webrev.01/
>
> This patch looks okay to me.
>
> This is a reasonable solution to allow getResource* to obtain the
> class file bytes
> loaded by the source launcher. JEP 330 might document that the URL
> protocol
> is implementation specific and the only way to get the URL of a .class
> file loaded
> by the source launcher is via the getResource(s) method. It does not
> support
> creating such a URL from a string.
>
How about ...
The class loader that is used to load the compiled classes itself uses
an implementation-specific protocol for any URLs that refer to resources
defined by the class loader. The only way to get such URLs is by using
methods like |getResource| or |getResources|; creating any such URL from
a string is not supported.
-- Jon
> Mandy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20180905/e226a78b/attachment.html>
More information about the compiler-dev
mailing list