JDK 9 Early Access with Project Jigsaw, build 135 on 09-14-2016 (#5500)
Jochen Theodorou
blackdrag at gmx.org
Sun Oct 2 12:49:26 UTC 2016
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
More information about the jigsaw-dev
mailing list