8266819: Separate the stop policies from the compile policies completely

Reviewed-by: mcimadamore
This commit is contained in:
Guoxiong Li 2021-05-13 10:22:13 +00:00 committed by Maurizio Cimadamore
parent a270cbe2eb
commit 17ceef97c3
9 changed files with 21 additions and 45 deletions

View File

@ -160,17 +160,6 @@ public class JavaCompiler {
* it does not depend on any unrelated errors that might have occurred. * it does not depend on any unrelated errors that might have occurred.
*/ */
protected static enum CompilePolicy { protected static enum CompilePolicy {
/**
* Just attribute the parse trees.
*/
ATTR_ONLY,
/**
* Just attribute and do flow analysis on the parse trees.
* This should catch most user errors.
*/
CHECK_ONLY,
/** /**
* Attribute everything, then do flow analysis for everything, * Attribute everything, then do flow analysis for everything,
* then desugar everything, and only then generate output. * then desugar everything, and only then generate output.
@ -198,10 +187,6 @@ public class JavaCompiler {
static CompilePolicy decode(String option) { static CompilePolicy decode(String option) {
if (option == null) if (option == null)
return DEFAULT_COMPILE_POLICY; return DEFAULT_COMPILE_POLICY;
else if (option.equals("attr"))
return ATTR_ONLY;
else if (option.equals("check"))
return CHECK_ONLY;
else if (option.equals("simple")) else if (option.equals("simple"))
return SIMPLE; return SIMPLE;
else if (option.equals("byfile")) else if (option.equals("byfile"))
@ -443,11 +428,7 @@ public class JavaCompiler {
verboseCompilePolicy = options.isSet("verboseCompilePolicy"); verboseCompilePolicy = options.isSet("verboseCompilePolicy");
if (options.isSet("should-stop.at") && compilePolicy = CompilePolicy.decode(options.get("compilePolicy"));
CompileState.valueOf(options.get("should-stop.at")) == CompileState.ATTR)
compilePolicy = CompilePolicy.ATTR_ONLY;
else
compilePolicy = CompilePolicy.decode(options.get("compilePolicy"));
implicitSourcePolicy = ImplicitSourcePolicy.decode(options.get("-implicit")); implicitSourcePolicy = ImplicitSourcePolicy.decode(options.get("-implicit"));
@ -948,14 +929,6 @@ public class JavaCompiler {
if (!CompileState.ATTR.isAfter(shouldStopPolicyIfNoError)) { if (!CompileState.ATTR.isAfter(shouldStopPolicyIfNoError)) {
switch (compilePolicy) { switch (compilePolicy) {
case ATTR_ONLY:
attribute(todo);
break;
case CHECK_ONLY:
flow(attribute(todo));
break;
case SIMPLE: case SIMPLE:
generate(desugar(flow(attribute(todo)))); generate(desugar(flow(attribute(todo))));
break; break;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -38,11 +38,11 @@
* @compile -XDcompilePolicy=simple Tree.java TreeScanner.java TreeInfo.java * @compile -XDcompilePolicy=simple Tree.java TreeScanner.java TreeInfo.java
* @compile -XDcompilePolicy=simple TreeInfo.java TreeScanner.java Tree.java * @compile -XDcompilePolicy=simple TreeInfo.java TreeScanner.java Tree.java
* *
* @compile -XDcompilePolicy=check Tree.java TreeScanner.java TreeInfo.java * @compile -XDshould-stop.ifError=FLOW -XDshould-stop.ifNoError=FLOW Tree.java TreeScanner.java TreeInfo.java
* @compile -XDcompilePolicy=check TreeInfo.java TreeScanner.java Tree.java * @compile -XDshould-stop.ifError=FLOW -XDshould-stop.ifNoError=FLOW TreeInfo.java TreeScanner.java Tree.java
* *
* @compile -XDcompilePolicy=attr Tree.java TreeScanner.java TreeInfo.java * @compile -XDshould-stop.ifError=ATTR -XDshould-stop.ifNoError=ATTR Tree.java TreeScanner.java TreeInfo.java
* @compile -XDcompilePolicy=attr TreeInfo.java TreeScanner.java Tree.java * @compile -XDshould-stop.ifError=ATTR -XDshould-stop.ifNoError=ATTR TreeInfo.java TreeScanner.java Tree.java
*/ */
package p; package p;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -315,7 +315,8 @@ public class CheckAttributedTree {
totalNumberOfCompilations++; totalNumberOfCompilations++;
newCompilationTask() newCompilationTask()
.withWriter(pw) .withWriter(pw)
.withOption("--should-stop=at=ATTR") .withOption("--should-stop=ifError=ATTR")
.withOption("--should-stop=ifNoError=ATTR")
.withOption("-XDverboseCompilePolicy") .withOption("-XDverboseCompilePolicy")
.withOption("-Xdoclint:none") .withOption("-Xdoclint:none")
.withSource(files.iterator().next()) .withSource(files.iterator().next())

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -94,7 +94,8 @@ public class T8193717 {
try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) { try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
fm.setLocationFromPaths(StandardLocation.CLASS_OUTPUT, List.of(Paths.get("."))); fm.setLocationFromPaths(StandardLocation.CLASS_OUTPUT, List.of(Paths.get(".")));
new JavacTask(tb).sources(source) new JavacTask(tb).sources(source)
.options("-XDshould-stop.at=ATTR") //the source is too big for a classfile .options("-XDshould-stop.ifError=ATTR",
"-XDshould-stop.ifNoError=ATTR") //the source is too big for a classfile
.fileManager(new TestJFM(fm)) .fileManager(new TestJFM(fm))
.run(); .run();
} }

View File

@ -2,7 +2,7 @@
* @test /nodynamiccopyright/ * @test /nodynamiccopyright/
* @bug 8029718 8065800 * @bug 8029718 8065800
* @summary Should always use lambda body structure to disambiguate overload resolution * @summary Should always use lambda body structure to disambiguate overload resolution
* @compile/fail/ref=MostSpecific09.out -XDrawDiagnostics --should-stop=at=ATTR --debug=verboseResolution=applicable,success MostSpecific09.java * @compile/fail/ref=MostSpecific09.out -XDrawDiagnostics --should-stop=ifError=ATTR --should-stop=ifNoError=ATTR --debug=verboseResolution=applicable,success MostSpecific09.java
*/ */
class MostSpecific09 { class MostSpecific09 {

View File

@ -1716,7 +1716,8 @@ public class AnnotationProcessing extends ModuleTestBase {
"-AlookupClass=+test.Test", "-AlookupClass=+test.Test",
"-AlookupPackage=+test", "-AlookupPackage=+test",
"--add-modules=m2x", "--add-modules=m2x",
"-XDshould-stop.at=ATTR", "-XDshould-stop.ifError=ATTR",
"-XDshould-stop.ifNoError=ATTR",
"-XDrawDiagnostics") "-XDrawDiagnostics")
.outdir(srcClasses) .outdir(srcClasses)
.files(findJavaFiles(src)) .files(findJavaFiles(src))

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -131,9 +131,9 @@ public class ResolveHarness implements javax.tools.DiagnosticListener<JavaFileOb
} }
protected void check() throws Exception { protected void check() throws Exception {
String[] options = { String[][] options = {
"--should-stop=at=ATTR", {"--should-stop=ifError=ATTR", "--should-stop=ifNoError=ATTR"},
"--debug=verboseResolution=success,failure,applicable,inapplicable,deferred-inference,predef" {"--debug=verboseResolution=success,failure,applicable,inapplicable,deferred-inference,predef"}
}; };
AbstractProcessor[] processors = { new ResolveCandidateFinder(), null }; AbstractProcessor[] processors = { new ResolveCandidateFinder(), null };

View File

@ -2,7 +2,7 @@
* @test /nodynamiccopyright/ * @test /nodynamiccopyright/
* @bug 8223305 8226522 * @bug 8223305 8226522
* @summary Verify correct warnings w.r.t. yield * @summary Verify correct warnings w.r.t. yield
* @compile/ref=WarnWrongYieldTest.out -Xlint:-options -source 13 -XDrawDiagnostics -XDshould-stop.at=ATTR WarnWrongYieldTest.java * @compile/ref=WarnWrongYieldTest.out -Xlint:-options -source 13 -XDrawDiagnostics -XDshould-stop.ifError=ATTR -XDshould-stop.ifNoError=ATTR WarnWrongYieldTest.java
*/ */
package t; package t;

View File

@ -2,7 +2,7 @@
* @test /nodynamiccopyright/ * @test /nodynamiccopyright/
* @bug 8223305 8226522 * @bug 8223305 8226522
* @summary Ensure proper errors are returned for yields. * @summary Ensure proper errors are returned for yields.
* @compile/fail/ref=WrongYieldTest.out -XDrawDiagnostics -XDshould-stop.at=ATTR WrongYieldTest.java * @compile/fail/ref=WrongYieldTest.out -XDrawDiagnostics -XDshould-stop.ifError=ATTR -XDshould-stop.ifNoError=ATTR WrongYieldTest.java
*/ */
package t; package t;