8161020: javac, fold stop compilation options

Reviewed-by: mcimadamore
This commit is contained in:
Vicente Romero 2016-07-11 15:27:52 -07:00
parent 0917774834
commit a7cc024b53
30 changed files with 67 additions and 51 deletions

View File

@ -425,8 +425,8 @@ public class JavaCompiler {
verboseCompilePolicy = options.isSet("verboseCompilePolicy");
if (options.isSet("shouldStopPolicy") &&
CompileState.valueOf(options.get("shouldStopPolicy")) == CompileState.ATTR)
if (options.isSet("shouldstop.at") &&
CompileState.valueOf(options.get("shouldstop.at")) == CompileState.ATTR)
compilePolicy = CompilePolicy.ATTR_ONLY;
else
compilePolicy = CompilePolicy.decode(options.get("compilePolicy"));
@ -439,14 +439,14 @@ public class JavaCompiler {
: null;
shouldStopPolicyIfError =
options.isSet("shouldStopPolicy") // backwards compatible
? CompileState.valueOf(options.get("shouldStopPolicy"))
: options.isSet("shouldStopPolicyIfError")
? CompileState.valueOf(options.get("shouldStopPolicyIfError"))
options.isSet("shouldstop.at") // backwards compatible
? CompileState.valueOf(options.get("shouldstop.at"))
: options.isSet("shouldstop.ifError")
? CompileState.valueOf(options.get("shouldstop.ifError"))
: CompileState.INIT;
shouldStopPolicyIfNoError =
options.isSet("shouldStopPolicyIfNoError")
? CompileState.valueOf(options.get("shouldStopPolicyIfNoError"))
options.isSet("shouldstop.ifNoError")
? CompileState.valueOf(options.get("shouldstop.ifNoError"))
: CompileState.GENERATE;
if (options.isUnset("oldDiags"))

View File

@ -543,6 +543,19 @@ public enum Option {
}
},
XSHOULDSTOP("-Xshouldstop:", null, HIDDEN, BASIC) {
@Override
public boolean process(OptionHelper helper, String option) {
String p = option.substring(option.indexOf(':') + 1).trim();
String[] subOptions = p.split(";");
for (String subOption : subOptions) {
subOption = "shouldstop." + subOption.trim();
XD.process(helper, subOption, subOption);
}
return false;
}
},
XADDEXPORTS("-XaddExports:", "opt.arg.addExports", "opt.addExports", EXTENDED, BASIC) {
@Override
public boolean process(OptionHelper helper, String option) {

View File

@ -222,7 +222,7 @@ class TaskFactory {
this(wraps.stream(),
new WrapSourceHandler(),
Util.join(new String[] {
"-XDshouldStopPolicy=FLOW", "-Xlint:unchecked",
"-Xshouldstop:at=FLOW", "-Xlint:unchecked",
"-XaddExports:jdk.jshell/jdk.internal.jshell.remote=ALL-UNNAMED",
"-proc:none"
}, extraArgs));

View File

@ -2,7 +2,7 @@
* @test /nodynamiccopyright/
* @bug 8026963
* @summary type annotations code crashes for lambdas with void argument
* @compile/fail/ref=TypeAnnotationsCrashWithErroneousTreeTest.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW TypeAnnotationsCrashWithErroneousTreeTest.java
* @compile/fail/ref=TypeAnnotationsCrashWithErroneousTreeTest.out -XDrawDiagnostics -Xshouldstop:at=FLOW TypeAnnotationsCrashWithErroneousTreeTest.java
*/
public class TypeAnnotationsCrashWithErroneousTreeTest {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2016, 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
@ -237,7 +237,7 @@ public class VerifyErroneousAnnotationsAttributed {
JavacTask task = tool.getTask(null,
fm,
devNull,
Arrays.asList("-XDshouldStopPolicy=FLOW"),
Arrays.asList("-Xshouldstop:at=FLOW"),
null,
Arrays.asList(new MyFileObject(code)));

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2016, 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
@ -54,7 +54,7 @@ public class AfterMethodTypeParams {
String test = TEMPLATE.replace("CONTENT", tc.snippet);
List<JavaFileObject> files = Arrays.asList(new MyFileObject(test));
StringWriter out = new StringWriter();
List<String> options = Arrays.asList("-XDrawDiagnostics", "-XDshouldStopPolicy=FLOW");
List<String> options = Arrays.asList("-XDrawDiagnostics", "-Xshouldstop:at=FLOW");
JavacTask task = (JavacTask) compiler.getTask(out, null, null, options, null, files);
new TreePathScanner<Void, Void>() {

View File

@ -63,11 +63,11 @@ public class EventsBalancedTest {
test(null, Arrays.asList(b, a));
for (CompileState stop : CompileState.values()) {
test(Arrays.asList("-XDshouldStopPolicyIfNoError=" + stop,
"-XDshouldStopPolicyIfError=" + stop),
test(Arrays.asList("-Xshouldstop:ifNoError=" + stop,
"-Xshouldstop:ifError=" + stop),
Arrays.asList(a, b));
test(Arrays.asList("-XDshouldStopPolicyIfNoError=" + stop,
"-XDshouldStopPolicyIfError=" + stop),
test(Arrays.asList("-Xshouldstop:ifNoError=" + stop,
"-Xshouldstop:ifError=" + stop),
Arrays.asList(b, a));
}
}

View File

@ -260,6 +260,9 @@ public class CheckResourceKeys {
// ignore debug flag names
if (cs.startsWith("debug."))
continue;
// ignore shouldstop flag names
if (cs.startsWith("shouldstop."))
continue;
// explicit known exceptions
if (noResourceRequired.contains(cs))
continue;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2016, 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
@ -311,7 +311,7 @@ public class CheckAttributedTree {
final List<CompilationUnitTree> trees = new ArrayList<>();
Iterable<? extends Element> elems = newCompilationTask()
.withWriter(pw)
.withOption("-XDshouldStopPolicy=ATTR")
.withOption("-Xshouldstop:at=ATTR")
.withOption("-XDverboseCompilePolicy")
.withSource(files.iterator().next())
.withListener(new TaskListener() {

View File

@ -4,7 +4,7 @@
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
* @compile/fail/ref=FailOver01.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver01.java
* @compile/fail/ref=FailOver01.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver01.java
*/
class Test { { x = "" } }

View File

@ -4,7 +4,7 @@
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
* @compile/fail/ref=FailOver02.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver02.java
* @compile/fail/ref=FailOver02.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver02.java
*/
class Test implements AutoCloseable {

View File

@ -4,7 +4,7 @@
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
* @compile/fail/ref=FailOver03.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver03.java
* @compile/fail/ref=FailOver03.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver03.java
*/
class Test extends Test {

View File

@ -4,7 +4,7 @@
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
* @compile/fail/ref=FailOver04.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver04.java
* @compile/fail/ref=FailOver04.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver04.java
*/
class Test {

View File

@ -4,7 +4,7 @@
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
* @compile/fail/ref=FailOver05.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver05.java
* @compile/fail/ref=FailOver05.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver05.java
*/
class Test extends Test {

View File

@ -4,7 +4,7 @@
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
* @compile/fail/ref=FailOver06.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver06.java
* @compile/fail/ref=FailOver06.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver06.java
*/
class Test extends Test {

View File

@ -4,7 +4,7 @@
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
* @compile/fail/ref=FailOver07.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver07.java
* @compile/fail/ref=FailOver07.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver07.java
*/
class Test extends Test {

View File

@ -4,7 +4,7 @@
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
* @compile/fail/ref=FailOver08.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver08.java
* @compile/fail/ref=FailOver08.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver08.java
*/
class Test extends Test {

View File

@ -4,7 +4,7 @@
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
* @compile/fail/ref=FailOver09.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver09.java
* @compile/fail/ref=FailOver09.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver09.java
*/
class Test extends Test {

View File

@ -4,7 +4,7 @@
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
* @compile/fail/ref=FailOver10.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver10.java
* @compile/fail/ref=FailOver10.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver10.java
*/
class Test extends Test {

View File

@ -4,7 +4,7 @@
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
* @compile/fail/ref=FailOver11.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver11.java
* @compile/fail/ref=FailOver11.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver11.java
*/
class Test extends Test {

View File

@ -4,7 +4,7 @@
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
* @compile/fail/ref=FailOver12.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver12.java
* @compile/fail/ref=FailOver12.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver12.java
*/
class Test extends Test {

View File

@ -4,7 +4,7 @@
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
* @compile/fail/ref=FailOver13.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver13.java
* @compile/fail/ref=FailOver13.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver13.java
*/
class Test extends Test {

View File

@ -4,7 +4,7 @@
* @summary Flow.java should be more error-friendly
* @author mcimadamore
*
* @compile/fail/ref=FailOver14.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver14.java
* @compile/fail/ref=FailOver14.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver14.java
*/
class Test extends Test {

View File

@ -3,7 +3,7 @@
* @bug 6970584 7060926
* @summary Attr.PostAttrAnalyzer misses a case
*
* @compile/fail/ref=FailOver15.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver15.java
* @compile/fail/ref=FailOver15.out -XDrawDiagnostics -Xshouldstop:at=FLOW -XDdev FailOver15.java
*/
class Test {

View File

@ -2,7 +2,7 @@
* @test /nodynamiccopyright/
* @bug 8029718
* @summary Should always use lambda body structure to disambiguate overload resolution
* @compile/fail/ref=MostSpecific09.out -XDrawDiagnostics -XDshouldStopPolicy=ATTR -Xdebug:verboseResolution=applicable,success MostSpecific09.java
* @compile/fail/ref=MostSpecific09.out -XDrawDiagnostics -Xshouldstop:at=ATTR -Xdebug:verboseResolution=applicable,success MostSpecific09.java
*/
class MostSpecific09 {

View File

@ -3,7 +3,7 @@ MostSpecific09.java:26:9: compiler.note.verbose.resolve.multi: foo, MostSpecific
MostSpecific09.java:27:9: compiler.note.verbose.resolve.multi: foo, MostSpecific09, 0, BASIC, compiler.misc.type.none, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, foo(MostSpecific09.J), null)}
MostSpecific09.java:27:32: compiler.note.verbose.resolve.multi: println, java.io.PrintStream, 1, BASIC, java.lang.String, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, println(java.lang.Object), null),(compiler.misc.applicable.method.found: 1, println(java.lang.String), null)}
MostSpecific09.java:28:13: compiler.err.lambda.body.neither.value.nor.void.compatible
MostSpecific09.java:28:9: compiler.err.cant.apply.symbols: kindname.method, foo, @685,{(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.I), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.missing.ret.val: java.lang.String)))),(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.J), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.unexpected.ret.val)))}
MostSpecific09.java:28:9: compiler.err.cant.apply.symbols: kindname.method, foo, @681,{(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.I), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.missing.ret.val: java.lang.String)))),(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.J), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.unexpected.ret.val)))}
MostSpecific09.java:28:43: compiler.note.verbose.resolve.multi: println, java.io.PrintStream, 1, BASIC, java.lang.String, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, println(java.lang.Object), null),(compiler.misc.applicable.method.found: 1, println(java.lang.String), null)}
MostSpecific09.java:29:9: compiler.err.ref.ambiguous: foo, kindname.method, foo(MostSpecific09.I), MostSpecific09, kindname.method, foo(MostSpecific09.J), MostSpecific09
MostSpecific09.java:29:28: compiler.note.verbose.resolve.multi: <init>, java.lang.RuntimeException, 0, BASIC, compiler.misc.no.args, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, java.lang.RuntimeException(), null)}
@ -11,7 +11,7 @@ MostSpecific09.java:30:9: compiler.err.ref.ambiguous: foo, kindname.method, foo(
MostSpecific09.java:32:9: compiler.err.ref.ambiguous: foo, kindname.method, foo(MostSpecific09.I), MostSpecific09, kindname.method, foo(MostSpecific09.J), MostSpecific09
MostSpecific09.java:33:9: compiler.note.verbose.resolve.multi: foo, MostSpecific09, 0, BASIC, compiler.misc.type.none, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, foo(MostSpecific09.I), null)}
MostSpecific09.java:42:13: compiler.err.lambda.body.neither.value.nor.void.compatible
MostSpecific09.java:42:9: compiler.err.cant.apply.symbols: kindname.method, foo, @1134,{(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.I), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.missing.ret.val: java.lang.String)))),(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.J), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.unexpected.ret.val)))}
MostSpecific09.java:42:9: compiler.err.cant.apply.symbols: kindname.method, foo, @1130,{(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.I), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.missing.ret.val: java.lang.String)))),(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.J), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.unexpected.ret.val)))}
MostSpecific09.java:46:23: compiler.note.verbose.resolve.multi: println, java.io.PrintStream, 1, BASIC, java.lang.String, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, println(java.lang.Object), null),(compiler.misc.applicable.method.found: 1, println(java.lang.String), null)}
MostSpecific09.java:49:9: compiler.note.verbose.resolve.multi: foo, MostSpecific09, 0, BASIC, compiler.misc.type.none, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, foo(MostSpecific09.J), null)}
MostSpecific09.java:56:25: compiler.note.verbose.resolve.multi: <init>, Bar, 0, BASIC, compiler.misc.no.args, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, Bar(), null)}

View File

@ -119,7 +119,7 @@ public class AddLimitMods extends ModuleTestBase {
//real test
new JavacTask(tb)
.options("-modulepath", modulePath.toString(),
"-XDshouldStopPolicyIfNoError=FLOW",
"-Xshouldstop:ifNoError=FLOW",
"-limitmods", "java.base")
.outdir(modulePath)
.files(findJavaFiles(m1))
@ -128,7 +128,7 @@ public class AddLimitMods extends ModuleTestBase {
new JavacTask(tb)
.options("-modulepath", modulePath.toString(),
"-XDshouldStopPolicyIfNoError=FLOW",
"-Xshouldstop:ifNoError=FLOW",
"-limitmods", "java.base",
"-addmods", "m2")
.outdir(modulePath)
@ -138,7 +138,7 @@ public class AddLimitMods extends ModuleTestBase {
new JavacTask(tb)
.options("-modulepath", modulePath.toString(),
"-XDshouldStopPolicyIfNoError=FLOW",
"-Xshouldstop:ifNoError=FLOW",
"-limitmods", "java.base",
"-addmods", "m2,m3")
.outdir(modulePath)
@ -148,7 +148,7 @@ public class AddLimitMods extends ModuleTestBase {
new JavacTask(tb)
.options("-modulepath", modulePath.toString(),
"-XDshouldStopPolicyIfNoError=FLOW",
"-Xshouldstop:ifNoError=FLOW",
"-limitmods", "m2")
.outdir(modulePath)
.files(findJavaFiles(m1))
@ -157,7 +157,7 @@ public class AddLimitMods extends ModuleTestBase {
new JavacTask(tb)
.options("-modulepath", modulePath.toString(),
"-XDshouldStopPolicyIfNoError=FLOW",
"-Xshouldstop:ifNoError=FLOW",
"-limitmods", "m3")
.outdir(modulePath)
.files(findJavaFiles(m1))
@ -166,7 +166,7 @@ public class AddLimitMods extends ModuleTestBase {
new JavacTask(tb)
.options("-modulepath", modulePath.toString(),
"-XDshouldStopPolicyIfNoError=FLOW",
"-Xshouldstop:ifNoError=FLOW",
"-limitmods", "m3",
"-addmods", "m2")
.outdir(modulePath)
@ -473,7 +473,7 @@ public class AddLimitMods extends ModuleTestBase {
auxOptions,
"-modulepath", modulePath.toString(),
"-classpath", classpathOut.toString(),
"-XDshouldStopPolicyIfNoError=FLOW"))
"-Xshouldstop:ifNoError=FLOW"))
.outdir(modulePath)
.files(findJavaFiles(m2))
.run(success ? Task.Expect.SUCCESS : Task.Expect.FAIL)

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009, 2016, 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
@ -30,7 +30,7 @@
import java.io.*;
import java.util.*;
// Simple test of -XDshouldStopPolicy.
// Simple test of -Xshouldstop:at.
// For each of the permissable values, we compile a file with an error in it,
// then using -XDverboseCompilePolicy we check that the compilation gets as
// far as expected, but no further.
@ -83,7 +83,7 @@ public class Test {
args.add("-d");
args.add(".");
if (ssp.needOption)
args.add("-XDshouldStopPolicy=" + ssp);
args.add("-Xshouldstop:at=" + ssp);
args.add(new File(System.getProperty("test.src", "."), "A.java").getPath());
StringWriter sw = new StringWriter();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2016, 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
@ -145,7 +145,7 @@ public class TreeEndPosTest {
options.add(tempDir.getPath());
options.add("-d");
options.add(tempDir.getPath());
options.add("-XDshouldStopPolicy=GENERATE");
options.add("-Xshouldstop:at=GENERATE");
List<JavaFileObject> sources = new ArrayList<>();
sources.add(src);

View File

@ -132,7 +132,7 @@ public class ResolveHarness implements javax.tools.DiagnosticListener<JavaFileOb
protected void check() throws Exception {
String[] options = {
"-XDshouldStopPolicy=ATTR",
"-Xshouldstop:at=ATTR",
"-Xdebug:verboseResolution=success,failure,applicable,inapplicable,deferred-inference,predef"
};