Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8266819: Separate the stop policies from the compile policies completely
Reviewed-by: mcimadamore
  • Loading branch information
lgxbslgx authored and mcimadamore committed May 13, 2021
1 parent a270cbe commit 17ceef9
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 45 deletions.
Expand Up @@ -160,17 +160,6 @@ private static String version(String key) {
* it does not depend on any unrelated errors that might have occurred.
*/
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,
* then desugar everything, and only then generate output.
Expand Down Expand Up @@ -198,10 +187,6 @@ protected static enum CompilePolicy {
static CompilePolicy decode(String option) {
if (option == null)
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"))
return SIMPLE;
else if (option.equals("byfile"))
Expand Down Expand Up @@ -443,11 +428,7 @@ public JavaCompiler(Context context) {

verboseCompilePolicy = options.isSet("verboseCompilePolicy");

if (options.isSet("should-stop.at") &&
CompileState.valueOf(options.get("should-stop.at")) == CompileState.ATTR)
compilePolicy = CompilePolicy.ATTR_ONLY;
else
compilePolicy = CompilePolicy.decode(options.get("compilePolicy"));
compilePolicy = CompilePolicy.decode(options.get("compilePolicy"));

implicitSourcePolicy = ImplicitSourcePolicy.decode(options.get("-implicit"));

Expand Down Expand Up @@ -948,14 +929,6 @@ public void compile(Collection<JavaFileObject> sourceFileObjects,

if (!CompileState.ATTR.isAfter(shouldStopPolicyIfNoError)) {
switch (compilePolicy) {
case ATTR_ONLY:
attribute(todo);
break;

case CHECK_ONLY:
flow(attribute(todo));
break;

case SIMPLE:
generate(desugar(flow(attribute(todo))));
break;
Expand Down
10 changes: 5 additions & 5 deletions test/langtools/tools/javac/6199662/Tree.java
@@ -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.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -38,11 +38,11 @@
* @compile -XDcompilePolicy=simple Tree.java TreeScanner.java TreeInfo.java
* @compile -XDcompilePolicy=simple TreeInfo.java TreeScanner.java Tree.java
*
* @compile -XDcompilePolicy=check Tree.java TreeScanner.java TreeInfo.java
* @compile -XDcompilePolicy=check TreeInfo.java TreeScanner.java Tree.java
* @compile -XDshould-stop.ifError=FLOW -XDshould-stop.ifNoError=FLOW Tree.java TreeScanner.java TreeInfo.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 -XDcompilePolicy=attr TreeInfo.java TreeScanner.java Tree.java
* @compile -XDshould-stop.ifError=ATTR -XDshould-stop.ifNoError=ATTR Tree.java TreeScanner.java TreeInfo.java
* @compile -XDshould-stop.ifError=ATTR -XDshould-stop.ifNoError=ATTR TreeInfo.java TreeScanner.java Tree.java
*/

package p;
Expand Down
5 changes: 3 additions & 2 deletions test/langtools/tools/javac/failover/CheckAttributedTree.java
@@ -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.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -315,7 +315,8 @@ void readAndCheck(File file, BiConsumer<JCCompilationUnit, JCTree> c) throws IOE
totalNumberOfCompilations++;
newCompilationTask()
.withWriter(pw)
.withOption("--should-stop=at=ATTR")
.withOption("--should-stop=ifError=ATTR")
.withOption("--should-stop=ifNoError=ATTR")
.withOption("-XDverboseCompilePolicy")
.withOption("-Xdoclint:none")
.withSource(files.iterator().next())
Expand Down
5 changes: 3 additions & 2 deletions test/langtools/tools/javac/importscope/T8193717.java
@@ -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.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -94,7 +94,8 @@ private void run() throws IOException {
try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
fm.setLocationFromPaths(StandardLocation.CLASS_OUTPUT, List.of(Paths.get(".")));
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))
.run();
}
Expand Down
2 changes: 1 addition & 1 deletion test/langtools/tools/javac/lambda/MostSpecific09.java
Expand Up @@ -2,7 +2,7 @@
* @test /nodynamiccopyright/
* @bug 8029718 8065800
* @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 {
Expand Down
3 changes: 2 additions & 1 deletion test/langtools/tools/javac/modules/AnnotationProcessing.java
Expand Up @@ -1716,7 +1716,8 @@ public void testUnboundLookupNew(Path base) throws Exception {
"-AlookupClass=+test.Test",
"-AlookupPackage=+test",
"--add-modules=m2x",
"-XDshould-stop.at=ATTR",
"-XDshould-stop.ifError=ATTR",
"-XDshould-stop.ifNoError=ATTR",
"-XDrawDiagnostics")
.outdir(srcClasses)
.files(findJavaFiles(src))
Expand Down
8 changes: 4 additions & 4 deletions test/langtools/tools/javac/resolve/ResolveHarness.java
@@ -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.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -131,9 +131,9 @@ protected ResolveHarness(JavaFileObject jfo) {
}

protected void check() throws Exception {
String[] options = {
"--should-stop=at=ATTR",
"--debug=verboseResolution=success,failure,applicable,inapplicable,deferred-inference,predef"
String[][] options = {
{"--should-stop=ifError=ATTR", "--should-stop=ifNoError=ATTR"},
{"--debug=verboseResolution=success,failure,applicable,inapplicable,deferred-inference,predef"}
};

AbstractProcessor[] processors = { new ResolveCandidateFinder(), null };
Expand Down
Expand Up @@ -2,7 +2,7 @@
* @test /nodynamiccopyright/
* @bug 8223305 8226522
* @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;
Expand Down
2 changes: 1 addition & 1 deletion test/langtools/tools/javac/switchexpr/WrongYieldTest.java
Expand Up @@ -2,7 +2,7 @@
* @test /nodynamiccopyright/
* @bug 8223305 8226522
* @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;
Expand Down

1 comment on commit 17ceef9

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.