Hi Alex,

On Fri, Feb 14, 2020 at 7:06 PM Alex Buckley <alex.buck...@oracle.com>

> [...]

Now, I am not "proposing" `--patch-module-descriptor` for a future JDK.
> I am recognizing that certain use cases involve changing a module's
> dependences and encapsulation in a tightly scoped way.

I can clearly envision the superpowers of the not (yet) proprosed
`--patch-module-descriptor` option unleashed upon the
Modular Testing World solving the long-standing issue of
resorting to either the class-path or the command-line when
it comes to in-(tra)-module (white box) testing. [0]

Let's explore the feature set of such an option and its limits together.
Looking forward to help with and test-drive that solution.

Three or two years ago, I contributed the "tester plugin" to pro [1].
Pro is a Java build tool that works seamlessly with modules and was
created be Rémi Forax.
That pro tool already performs such a merge action when for in-(tra)-
module (white box) test modules (can you please specify simple
token for such a type of module?!).
Here is the relevant implementation [2] which may guide us
when exploring the feature set. I guess, Rémi will comment on
this topic, too. As he is, if I recall correctly, "the father of the idea".

A different way
> to address those use cases would be to ship the logic just described for
> `--patch-module-descriptor` in a launcher offered by the test framework
> itself.

That's too late in the build game. You already need this merged
descriptor at compile time. And you need the user to define the
additional elements (modifiers and directives), as no build tool
may infer them always correctly by inspecting the test sources...

> If JUnit creates its own module layer, [...]

No, we don't. We "just" make use of the ModuleReader when
scanning a module for potential test classes. That logic [3] is
shipped in a MR-JAR since two years ago and works flawlessly.

> [...] then it can define module descriptors at run time

how ever it likes [...]

Like said before, I think, that's too late in the build game. And
still we had to require the user to pass the extra information
to our framework ... in non-standard manner. Using the manually
merged in-(tra)-module (white box) test modules works for us
since day one of Java 9.

> . It's not clear to me if
> Christian & co. have looked into java.lang.ModuleLayer,
> java.lang.module.Configuration, and java.lang.module.ModuleFinder.

If they have, we'd love to hear their experiences.

Yes, I did: [4]

Works like a charm a test runtime when you want to open a module
to the modules of the build tool. Or here, as you might have guessed,
read the extra information required for testing provided by the user
in a `module-info.test` [5] formatted file. The major drawback is the
simple text format that this `module-info.test` uses: brittle as best.

Summarizing, I like the _not_ proposed `--patch-module-descriptor` option.


[1]: https://github.com/forax/pro/tree/master/plugins/tester

Reply via email to