Skip to content

Commit 0fbf10a

Browse files
committed
8348038: Docs build failing in Options.notifyListeners with AssertionError
Reviewed-by: jlahoda, mcimadamore
1 parent 9346984 commit 0fbf10a

File tree

3 files changed

+70
-11
lines changed

3 files changed

+70
-11
lines changed

src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileManager.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ public void setContext(Context context) {
9494
// Initialize locations
9595
locations.update(log, lint, FSInfo.instance(context));
9696

97+
// Apply options
98+
options.whenReady(this::applyOptions);
99+
}
100+
101+
protected void applyOptions(Options options) {
102+
97103
// Setting this option is an indication that close() should defer actually closing
98104
// the file manager until after a specified period of inactivity.
99105
// This is to accommodate clients which save references to Symbols created for use
@@ -106,16 +112,14 @@ public void setContext(Context context) {
106112
// in seconds, of the period of inactivity to wait for, before the file manager
107113
// is actually closed.
108114
// See also deferredClose().
109-
options.whenReady(options -> {
110-
String s = options.get("fileManager.deferClose");
111-
if (s != null) {
112-
try {
113-
deferredCloseTimeout = (int) (Float.parseFloat(s) * 1000);
114-
} catch (NumberFormatException e) {
115-
deferredCloseTimeout = 60 * 1000; // default: one minute, in millis
116-
}
115+
String s = options.get("fileManager.deferClose");
116+
if (s != null) {
117+
try {
118+
deferredCloseTimeout = (int) (Float.parseFloat(s) * 1000);
119+
} catch (NumberFormatException e) {
120+
deferredCloseTimeout = 60 * 1000; // default: one minute, in millis
117121
}
118-
});
122+
}
119123
}
120124

121125
protected Locations createLocations() {

src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
import com.sun.tools.javac.util.DefinedBy.Api;
8181
import com.sun.tools.javac.util.List;
8282
import com.sun.tools.javac.util.ListBuffer;
83+
import com.sun.tools.javac.util.Options;
8384

8485
import static java.nio.charset.StandardCharsets.US_ASCII;
8586
import static java.nio.file.FileVisitOption.FOLLOW_LINKS;
@@ -109,7 +110,7 @@ public static char[] toArray(CharBuffer buffer) {
109110
private static final Set<JavaFileObject.Kind> SOURCE_OR_CLASS =
110111
Set.of(JavaFileObject.Kind.SOURCE, JavaFileObject.Kind.CLASS);
111112

112-
protected boolean symbolFileEnabled;
113+
protected boolean symbolFileEnabled = true;
113114

114115
private PathFactory pathFactory = Paths::get;
115116

@@ -169,8 +170,12 @@ public JavacFileManager(Context context, boolean register, Charset charset) {
169170
@Override
170171
public void setContext(Context context) {
171172
super.setContext(context);
172-
173173
fsInfo = FSInfo.instance(context);
174+
}
175+
176+
@Override
177+
protected void applyOptions(Options options) {
178+
super.applyOptions(options);
174179

175180
symbolFileEnabled = !options.isSet("ignore.symbol.file");
176181

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
/*
25+
* @test
26+
* @bug 8348038
27+
* @summary Verify use of "-XDignore.symbol.file=true" doesn't cause assertion failure
28+
* @modules jdk.javadoc/jdk.javadoc.internal.tool
29+
*/
30+
31+
import java.io.File;
32+
import java.io.PrintWriter;
33+
import java.io.StringWriter;
34+
35+
public class JavadocIgnoreSymbolFile {
36+
37+
public static void main(String[] args) {
38+
String[] javadocArgs = new String[] {
39+
"-XDignore.symbol.file=true"
40+
};
41+
StringWriter buf = new StringWriter();
42+
try (PrintWriter pw = new PrintWriter(buf)) {
43+
jdk.javadoc.internal.tool.Main.execute(javadocArgs, pw);
44+
}
45+
String expected = "error: No modules, packages or classes specified. 1 error";
46+
String actual = buf.toString().trim().replaceAll("\\s+", " ");
47+
if (!actual.equals(expected))
48+
throw new AssertionError("unexpected output:\n" + actual);
49+
}
50+
}

0 commit comments

Comments
 (0)