RFR: 8272728: javac ignores any -J option in @argfiles silently

Christian Stein cstein at openjdk.java.net
Mon Oct 25 11:00:12 UTC 2021


On Mon, 25 Oct 2021 09:02:30 GMT, Christian Stein <cstein at openjdk.org> wrote:

>> test/langtools/tools/javac/options/modes/AtFilesTest.java line 75:
>> 
>>> 73:             .checkResult(Main.Result.CMDERR.exitCode)
>>> 74:             .checkLog(Log.DIRECT, "-J-verbose");
>>> 75:     }
>> 
>> Should we add a test that for invalid option as well? -J-non_existent_option ?
>
> In order to ensure that valid and invalid values passed to `-J` are detected?
> 
> If yes, then it does not add much to the already tested behaviour: all occurances of `-J` (with valid and invalid values) within an AtFile are now reported as an error. The tests for valid values are performed at launcher-level (I hope).

A test variant for an invalid argument would almost look like the one for the valid argument:


    @Test
    void testAtFilesMustNotContainOptionJ() throws IOException {
        writeFile("args", "-J-non_existent_option");

        String[] opts = { "@args", "-version" };
        String[] files = { };

        runMain(opts, files)
            .checkResult(Main.Result.CMDERR.exitCode)
            .checkLog(Log.DIRECT, "-J-non_existent_option");
    }

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

PR: https://git.openjdk.java.net/jdk/pull/5891


More information about the compiler-dev mailing list