RFR: 8306914: Implementation of JEP Launch Multi-File Source-Code Programs [v2]

Christian Stein cstein at openjdk.org
Tue Oct 17 15:32:17 UTC 2023


On Mon, 16 Oct 2023 13:30:58 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

>> Christian Stein has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Fix support for adding user-supplied modules on the module-path
>
> test/langtools/tools/javac/launcher/Run.java line 49:
> 
>> 47:         PrintStream prev = System.out;
>> 48:         ByteArrayOutputStream baos = new ByteArrayOutputStream();
>> 49:         try (PrintStream out = new PrintStream(baos, true)) {
> 
> So, I am looking at this, and I am not sure how it can work and test what is needed. If the compilation fails during on-demand class loading, we stop using `System.exit`, and it seems to me this code cannot handle that, and so that there's probably no test testing that scenario?
> 
> I mean:
> 
> 
> ---Test.java
> public class Test {
>     public static void main(String... args) throws Throwable {
>         Class.forName("Extra");
>     }
> }
> ----Extra.java
> public class Broken
> ---

There is a test in `MultiFileSourceLauncherTests` that checks this with a broken second file: `testSecondUnitWithSyntaxError`, including an assertion for the syntax error being emitted.

And I recall to have seen the error code `2` in a manual test - but there's no automated test for this.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/13712#discussion_r1362327231


More information about the compiler-dev mailing list