JDK 9 Early Access with Project Jigsaw, build 135 on 09-14-2016 (#5500)

Claes Redestad claes.redestad at oracle.com
Sun Oct 2 13:00:20 UTC 2016


Doh, you're right, I didn't think this one through and prototyped a delegating classloader in java.lang (where of course overriding and delegating to a protected method works fine as protected implies package private).

Maybe that's an extension idea: a delegating classloader in java.lang where all protected methods are public, along with the necessary security checks when creating it.. 

/Claes


Jochen Theodorou <blackdrag at gmx.org> skrev: (2 oktober 2016 14:49:26 CEST)
>On 02.10.2016 14:43, Claes Redestad wrote:
>>
>>
>> On 2016-10-02 14:26, Jochen Theodorou wrote:
>>>
>>>> Do you know anything about the ClassLoader::getPackages issue? Is
>this a
>>>> case where the (new) public getDefinedPackages returns the Packages
>that
>>>> Gradle is looking for?
>>>
>>> hmm... if I look at
>>>
>https://github.com/gradle/gradle/blob/master/subprojects/base-services/src/main/java/org/gradle/internal/classloader/MultiParentClassLoader.java
>>>
>>> and I imagine one parent being a MultiParentClassLoader...
>>> getDefinedPackages is final, so you cannot do what they did for
>>> getPackages, unless you do it from outside. And for that you need to
>>> know about multiple parents... I don´t know if it is working well
>enough
>>> for Gradle, but no, getDefinedPackages is no suitable replacement
>for
>>> getPackages at all if you have to consider multiparent class
>loaders.
>>
>> Since the methods reflected upon in ClassLoader here are all
>protected,
>> couldn't this specific code be made reflection-free by wrapping all
>> parent classloaders in a delegating classloader that overrides
>> getPackage/getPackages as public?
>
>How is the delegating classloader going to access getPackage of the 
>loader it delegates to? Just being a classloader subclass does not
>solve 
>the problem. And you cannot be in the same package as well... not to 
>mention, that your class is probably defined in a different classloader
>
>as well. Or is here a Java-trick I do not know of?
>
>bye Jochen

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.


More information about the jigsaw-dev mailing list