langtools/javac tests fail after 79d3fee395060a

Harald Eilertsen harald+jdklists at volse.no
Tue Apr 29 13:19:29 UTC 2025


Hi,

After commit 79d3fee395060a tests with @compile directives with args
after the source file name fails in the openjdk test suite. An example
is test/langtools/tools/javac/6521805/T6521805d.java:

    /*
     * @test /nodynamiccopyright/
     * @bug 6521805
     * @summary Regression: JDK5/JDK6 javac allows write access to outer class reference
     * @author mcimadamore
     *
     * @compile/fail/ref=T6521805d.out T6521805d.java -XDrawDiagnostics
     */

Which fails with the following message:

    test result: Error. Parse Exception: Can't find source file: -XDrawDiagnostics

This is because the CompileAction::init method will set the
foundJavaFile flag to true when an arg ending with `.java`, but will not
clear the flag before checking the next argument.

>From what I can see, the tests for the @compile directive in the jtreg
test suite avoids the problem by consistently listing the file to
compile as the last argument.

My question is, what is the expected behaviour in this case? Should the
test fail if the args are not in the correct order, or should the
directive accept args in any order?

Fwiw, the current jtreg release 7.5.1 handles the args in any order.

Thanks in advance for any clarification!

Harald Eilertsen
--
Eilertsens Kodeknekkeri
https://kodeknekkeriet.net


More information about the jtreg-dev mailing list