Skip to content
Permalink
Browse files
8266239: Some duplicated javac command-line options have repeated effect
Reviewed-by: vromero
  • Loading branch information
lgxbslgx committed Sep 3, 2021
1 parent 93eec9a commit d05494f98bad351532cdb769c9da6b6e2359b16e
Showing 3 changed files with 41 additions and 2 deletions.
@@ -1154,6 +1154,11 @@ public void handleOption(OptionHelper helper, String arg, Iterator<String> rest)
}
process(helper, option, operand);
} else {
if ((this == HELP || this == X || this == HELP_LINT || this == VERSION || this == FULLVERSION)
&& (helper.get(this) != null)) {
// avoid processing the info options repeatedly
return;
}
process(helper, arg);
}
}
@@ -23,7 +23,7 @@

/*
* @test
* @bug 8044859 8230623
* @bug 8044859 8230623 8266239
* @summary test support for info options -help -X -version -fullversion --help-lint
* @modules jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.file
@@ -66,4 +66,22 @@ void testInfoOpt(String opt, String... expect) {
runParse(opts, files)
.checkIllegalArgumentException();
}

@Test
void testUniqueInfoOpts() throws IOException {
testUniqueInfoOpt(new String[] {"--help", "--help"}, "possible options");
testUniqueInfoOpt(new String[] {"-X", "-X"}, "extra options");
testUniqueInfoOpt(new String[] {"--help-lint", "--help-lint"}, "supported keys");

String specVersion = System.getProperty("java.specification.version");
testUniqueInfoOpt(new String[] {"-version", "-version"}, "javac", specVersion);
testUniqueInfoOpt(new String[] {"-fullversion", "-fullversion"}, "javac", specVersion);
}

void testUniqueInfoOpt(String[] opts, String... expect) {
String[] files = { };
runMain(opts, files)
.checkOK()
.checkUniqueLog(expect);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -269,6 +269,22 @@ TestResult checkLog(Log l, String... expects) {
return this;
}

TestResult checkUniqueLog(String... uniqueExpects) {
return checkUniqueLog(Log.DIRECT, uniqueExpects);
}

TestResult checkUniqueLog(Log l, String... uniqueExpects) {
String log = logs.get(l);
for (String e : uniqueExpects) {
if (!log.contains(e)) {
error("Expected string not found: " + e);
} else if (log.indexOf(e) != log.lastIndexOf(e)) {
error("Expected string appears more than once: " + e);
}
}
return this;
}

TestResult checkIllegalArgumentException() {
return checkThrown(IllegalArgumentException.class);
}

3 comments on commit d05494f

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on d05494f Sep 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lgxbslgx
Copy link
Member Author

@lgxbslgx lgxbslgx commented on d05494f Sep 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk17u

@openjdk
Copy link

@openjdk openjdk bot commented on d05494f Sep 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lgxbslgx the backport was successfully created on the branch lgxbslgx-backport-d05494f9 in my personal fork of openjdk/jdk17u. To create a pull request with this backport targeting openjdk/jdk17u:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

this pull request contains a backport of commit d05494f9 from the openjdk/jdk repository.

The commit being backported was authored by Guoxiong Li on 3 Sep 2021 and was reviewed by Vicente Romero.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u:

$ git fetch https://github.com/openjdk-bots/jdk17u lgxbslgx-backport-d05494f9:lgxbslgx-backport-d05494f9
$ git checkout lgxbslgx-backport-d05494f9
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u lgxbslgx-backport-d05494f9

Please sign in to comment.