RFR: 7904141: JTReg should support running compact source files

Jaikiran Pai jpai at openjdk.org
Mon Feb 2 07:50:44 UTC 2026


On Mon, 2 Feb 2026 07:36:59 GMT, Christian Stein <cstein at openjdk.org> wrote:

>> src/share/classes/com/sun/javatest/regtest/agent/MainWrapper.java line 184:
>> 
>>> 182: 
>>> 183:                 // RUN JAVA PROGRAM
>>> 184:                 Class<?> mainClass = Class.forName(className, false, cl);
>> 
>> Hello Christian, I haven't yet looked at the changes in detail, but I think this change here should be guarded by a check against the current runtime version. i.e. something like:
>> 
>> if (currentRuntimeVersion < 25) {
>>     Class<?> c = Class.forName(className, false, cl);
>>     Method mainMethod = c.getMethod("main", String[].class);
>>     mainMethod.invoke(null, (Object) args);
>> } else {
>>    ... // the new changes proposed in this PR
>> }
>
> I see the point with respect to consistency of the Java version Compact Source Files where released.
> 
> On the other hand, jtreg 8.3+ could support running such main classes as long as `javac` was able to compile them. This would allow easier backporting of tests in compact form.

Hello Christian, `javac` would compile such class in any version because it's just another method for `javac`.  The rules of identifying the main() method within a class and using that as an entry point is what changed in Java 25 through https://openjdk.org/jeps/512. Before that even if `javac` could compile such classes, launching those main() methods wouldn't be allowed (by the `java` launcher), in fact that would result in a failure to find a main() method.

So I think we shouldn't allow jtreg to reflectively "launch" such newer main() methods on Java versions that don't have https://openjdk.org/jeps/512

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

PR Review Comment: https://git.openjdk.org/jtreg/pull/313#discussion_r2752993968


More information about the jtreg-dev mailing list