Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8266239: Some duplicated javac command-line options have repeated effect #4244

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -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);
}