Skip to content

Commit 17ceef9

Browse files
lgxbslgxmcimadamore
authored andcommittedMay 13, 2021
8266819: Separate the stop policies from the compile policies completely
Reviewed-by: mcimadamore
1 parent a270cbe commit 17ceef9

File tree

9 files changed

+21
-45
lines changed

9 files changed

+21
-45
lines changed
 

‎src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java

+1-28
Original file line numberDiff line numberDiff line change
@@ -160,17 +160,6 @@ private static String version(String key) {
160160
* it does not depend on any unrelated errors that might have occurred.
161161
*/
162162
protected static enum CompilePolicy {
163-
/**
164-
* Just attribute the parse trees.
165-
*/
166-
ATTR_ONLY,
167-
168-
/**
169-
* Just attribute and do flow analysis on the parse trees.
170-
* This should catch most user errors.
171-
*/
172-
CHECK_ONLY,
173-
174163
/**
175164
* Attribute everything, then do flow analysis for everything,
176165
* then desugar everything, and only then generate output.
@@ -198,10 +187,6 @@ protected static enum CompilePolicy {
198187
static CompilePolicy decode(String option) {
199188
if (option == null)
200189
return DEFAULT_COMPILE_POLICY;
201-
else if (option.equals("attr"))
202-
return ATTR_ONLY;
203-
else if (option.equals("check"))
204-
return CHECK_ONLY;
205190
else if (option.equals("simple"))
206191
return SIMPLE;
207192
else if (option.equals("byfile"))
@@ -443,11 +428,7 @@ public JavaCompiler(Context context) {
443428

444429
verboseCompilePolicy = options.isSet("verboseCompilePolicy");
445430

446-
if (options.isSet("should-stop.at") &&
447-
CompileState.valueOf(options.get("should-stop.at")) == CompileState.ATTR)
448-
compilePolicy = CompilePolicy.ATTR_ONLY;
449-
else
450-
compilePolicy = CompilePolicy.decode(options.get("compilePolicy"));
431+
compilePolicy = CompilePolicy.decode(options.get("compilePolicy"));
451432

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

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

949930
if (!CompileState.ATTR.isAfter(shouldStopPolicyIfNoError)) {
950931
switch (compilePolicy) {
951-
case ATTR_ONLY:
952-
attribute(todo);
953-
break;
954-
955-
case CHECK_ONLY:
956-
flow(attribute(todo));
957-
break;
958-
959932
case SIMPLE:
960933
generate(desugar(flow(attribute(todo))));
961934
break;

‎test/langtools/tools/javac/6199662/Tree.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -38,11 +38,11 @@
3838
* @compile -XDcompilePolicy=simple Tree.java TreeScanner.java TreeInfo.java
3939
* @compile -XDcompilePolicy=simple TreeInfo.java TreeScanner.java Tree.java
4040
*
41-
* @compile -XDcompilePolicy=check Tree.java TreeScanner.java TreeInfo.java
42-
* @compile -XDcompilePolicy=check TreeInfo.java TreeScanner.java Tree.java
41+
* @compile -XDshould-stop.ifError=FLOW -XDshould-stop.ifNoError=FLOW Tree.java TreeScanner.java TreeInfo.java
42+
* @compile -XDshould-stop.ifError=FLOW -XDshould-stop.ifNoError=FLOW TreeInfo.java TreeScanner.java Tree.java
4343
*
44-
* @compile -XDcompilePolicy=attr Tree.java TreeScanner.java TreeInfo.java
45-
* @compile -XDcompilePolicy=attr TreeInfo.java TreeScanner.java Tree.java
44+
* @compile -XDshould-stop.ifError=ATTR -XDshould-stop.ifNoError=ATTR Tree.java TreeScanner.java TreeInfo.java
45+
* @compile -XDshould-stop.ifError=ATTR -XDshould-stop.ifNoError=ATTR TreeInfo.java TreeScanner.java Tree.java
4646
*/
4747

4848
package p;

‎test/langtools/tools/javac/failover/CheckAttributedTree.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -315,7 +315,8 @@ void readAndCheck(File file, BiConsumer<JCCompilationUnit, JCTree> c) throws IOE
315315
totalNumberOfCompilations++;
316316
newCompilationTask()
317317
.withWriter(pw)
318-
.withOption("--should-stop=at=ATTR")
318+
.withOption("--should-stop=ifError=ATTR")
319+
.withOption("--should-stop=ifNoError=ATTR")
319320
.withOption("-XDverboseCompilePolicy")
320321
.withOption("-Xdoclint:none")
321322
.withSource(files.iterator().next())

‎test/langtools/tools/javac/importscope/T8193717.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -94,7 +94,8 @@ private void run() throws IOException {
9494
try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
9595
fm.setLocationFromPaths(StandardLocation.CLASS_OUTPUT, List.of(Paths.get(".")));
9696
new JavacTask(tb).sources(source)
97-
.options("-XDshould-stop.at=ATTR") //the source is too big for a classfile
97+
.options("-XDshould-stop.ifError=ATTR",
98+
"-XDshould-stop.ifNoError=ATTR") //the source is too big for a classfile
9899
.fileManager(new TestJFM(fm))
99100
.run();
100101
}

‎test/langtools/tools/javac/lambda/MostSpecific09.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @test /nodynamiccopyright/
33
* @bug 8029718 8065800
44
* @summary Should always use lambda body structure to disambiguate overload resolution
5-
* @compile/fail/ref=MostSpecific09.out -XDrawDiagnostics --should-stop=at=ATTR --debug=verboseResolution=applicable,success MostSpecific09.java
5+
* @compile/fail/ref=MostSpecific09.out -XDrawDiagnostics --should-stop=ifError=ATTR --should-stop=ifNoError=ATTR --debug=verboseResolution=applicable,success MostSpecific09.java
66
*/
77

88
class MostSpecific09 {

‎test/langtools/tools/javac/modules/AnnotationProcessing.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -1716,7 +1716,8 @@ public void testUnboundLookupNew(Path base) throws Exception {
17161716
"-AlookupClass=+test.Test",
17171717
"-AlookupPackage=+test",
17181718
"--add-modules=m2x",
1719-
"-XDshould-stop.at=ATTR",
1719+
"-XDshould-stop.ifError=ATTR",
1720+
"-XDshould-stop.ifNoError=ATTR",
17201721
"-XDrawDiagnostics")
17211722
.outdir(srcClasses)
17221723
.files(findJavaFiles(src))

‎test/langtools/tools/javac/resolve/ResolveHarness.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -131,9 +131,9 @@ protected ResolveHarness(JavaFileObject jfo) {
131131
}
132132

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

139139
AbstractProcessor[] processors = { new ResolveCandidateFinder(), null };

‎test/langtools/tools/javac/switchexpr/WarnWrongYieldTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @test /nodynamiccopyright/
33
* @bug 8223305 8226522
44
* @summary Verify correct warnings w.r.t. yield
5-
* @compile/ref=WarnWrongYieldTest.out -Xlint:-options -source 13 -XDrawDiagnostics -XDshould-stop.at=ATTR WarnWrongYieldTest.java
5+
* @compile/ref=WarnWrongYieldTest.out -Xlint:-options -source 13 -XDrawDiagnostics -XDshould-stop.ifError=ATTR -XDshould-stop.ifNoError=ATTR WarnWrongYieldTest.java
66
*/
77

88
package t;

‎test/langtools/tools/javac/switchexpr/WrongYieldTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @test /nodynamiccopyright/
33
* @bug 8223305 8226522
44
* @summary Ensure proper errors are returned for yields.
5-
* @compile/fail/ref=WrongYieldTest.out -XDrawDiagnostics -XDshould-stop.at=ATTR WrongYieldTest.java
5+
* @compile/fail/ref=WrongYieldTest.out -XDrawDiagnostics -XDshould-stop.ifError=ATTR -XDshould-stop.ifNoError=ATTR WrongYieldTest.java
66
*/
77

88
package t;

0 commit comments

Comments
 (0)
Please sign in to comment.