missing resources when using --patch-module
Tom De Wolf
tom.dewolf at aca-it.be
Fri Apr 3 11:46:55 UTC 2020
Hi,
I understand that for individual classes and non-java resources a patch
should replace them. However for directories which are actually java
packages this seems to be odd. Does this not make it impossible to add a
new class to an existing package or replace only 1 class in a package but
keep the rest? If only the package found in the patch is returned then only
classes in that patch are found and not the classes in the original package.
Best regards,
Tom- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
Op vr 3 apr. 2020 om 13:28 schreef Robert Scholte <rfscholte at apache.org>:
> Thanks for the explanation, it makes sense:
> Patch acts more like an override than an append.
>
> best,
> Robert
>
> On 3-4-2020 12:56:10, Alan Bateman <alan.bateman at oracle.com> wrote:
> On 03/04/2020 10:17, Robert Scholte wrote:
> > This issue was registered as SUREFIRE-1768[1]
> > It contains a very small Maven project to demonstrate the issue.
> >
> > That project contains one method executing the following:
> >
> >
> Demo.class.getClassLoader().getResources("demo").asIterator().forEachRemaining(url
> -> {
> > System.out.println(url.getFile()); // I'd like to see the
> target/classes/demo directory here at some point.
> > });
> >
> >
> > After executing the test it shows the following result
> > /E:/test-classpath-demo-master/target/test-classes/demo/
> > /E:/test-classpath-demo-master/target/test-classes/demo
> >
> > these are similar, but more worrying: where is
> > /E:/test-classpath-demo-master/target/classes/demo
> >
> > I rewrote it a bit by including a main method to ensure it is not
> caused by surefire:
> > "%JAVA_HOME%"\bin\java --module-path target/classes --patch-module
> test.classpath.demo=target/test-classes --module
> test.classpath.demo/demo.DemoTest
> >
> >
> > this gave me only one result (where I expected 2):
> > /E:/test-classpath-demo-master/target/test-classes/demo/
> >
> >
> > So the question is, where is
> > /E:/test-classpath-demo-master/target/classes/demo/
> >
> Patching is to used to replace specific classes or resources in a module
> with alternative versions. It can also be used to augment a module with
> new classes or resources. In the reproducer, it looks like module
> test.classpath.demo has been patched so that "demo" is found in the
> patch rather than the original module. This is correct behavior.
>
> If it helps, this will give a list of the resources in the module so you
> can see the effect of the patching:
>
> String name = this.getClass().getModule().getName();
> ModuleLayer.boot()
> .configuration()
> .findModule(name)
> .orElseThrow()
> .reference()
> .open()
> .list()
> .forEach(System.out::println)
>
> -Alan
>
More information about the jigsaw-dev
mailing list