JEP 458: Launch Multi-File Source-Code Program: Inferring the root of the source tree
Ron Pressler
ron.pressler at oracle.com
Fri Oct 20 08:28:12 UTC 2023
> On 20 Oct 2023, at 00:37, Maurizio Cimadamore <maurizio.cimadamore at oracle.com> wrote:
>
> That said, if you are wondering whether the behavior of javac could eventually be aligned to match this, I'd be more skeptical,
I wasn’t thinking about applying this to javac.
>
> Summing up, I think your approach is workable. I don't know exactly (as I had not have the time to play around with the new launcher much) how much this algorithm _exactly_ brings on the table. Using the current folder as the source path is not a completely terrible default, and has the enormous advantage of not requiring any parsing step, so it's a very pragmatical one from a tooling perspective. But ultimately, I believe that, in the context of a JEP like this, usability has to take the front seat. I imagine there are some examples and use cases where the proposed algorithm worked and the "classic" one didn't?
It’s mostly so that changing the current directory is not required to launch the program, which may be common when the source tree root is a src directory under a project’s root directory (so you can launch with `java src/pkg/Main.java`). It doesn’t matter as much for javac, which is now most commonly invoked indirectly by tools.
> I suppose the plan is to only support classpath applications only - otherwise there's also a module sourcepath to infer, and that could be a bit trickier :-)
A *single* module is supported, too, if a module-info.java is found at the root of the source tree: https://openjdk.org/jeps/458#Modular-source-code-programs
— Ron
More information about the compiler-dev
mailing list