8037484: [javadoc] fails with java.lang.IllegalStateException: endPosTable already set
Reviewed-by: jjg
This commit is contained in:
parent
7a4a5803fc
commit
7a7a57bb88
@ -68,6 +68,7 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler {
|
||||
final Messager messager;
|
||||
final JavadocClassReader javadocReader;
|
||||
final JavadocEnter javadocEnter;
|
||||
final Set<JavaFileObject> uniquefiles;
|
||||
|
||||
/**
|
||||
* Construct a new JavaCompiler processor, using appropriately
|
||||
@ -78,6 +79,7 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler {
|
||||
messager = Messager.instance0(context);
|
||||
javadocReader = JavadocClassReader.instance0(context);
|
||||
javadocEnter = JavadocEnter.instance0(context);
|
||||
uniquefiles = new HashSet<>();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -148,9 +150,7 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler {
|
||||
String name = it.head;
|
||||
if (!docClasses && fm != null && name.endsWith(".java") && new File(name).exists()) {
|
||||
JavaFileObject fo = fm.getJavaFileObjects(name).iterator().next();
|
||||
docenv.notice("main.Loading_source_file", name);
|
||||
JCCompilationUnit tree = parse(fo);
|
||||
classTrees.append(tree);
|
||||
parse(fo, classTrees, true);
|
||||
} else if (isValidPackageName(name)) {
|
||||
names = names.append(name);
|
||||
} else if (name.endsWith(".java")) {
|
||||
@ -163,9 +163,7 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler {
|
||||
}
|
||||
}
|
||||
for (JavaFileObject fo: fileObjects) {
|
||||
docenv.notice("main.Loading_source_file", fo.getName());
|
||||
JCCompilationUnit tree = parse(fo);
|
||||
classTrees.append(tree);
|
||||
parse(fo, classTrees, true);
|
||||
}
|
||||
|
||||
if (!docClasses) {
|
||||
@ -213,7 +211,7 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler {
|
||||
* .java files found in such a directory to args.
|
||||
*/
|
||||
private void parsePackageClasses(String name,
|
||||
Iterable<JavaFileObject> files,
|
||||
List<JavaFileObject> files,
|
||||
ListBuffer<JCCompilationUnit> trees,
|
||||
List<String> excludedPackages)
|
||||
throws IOException {
|
||||
@ -221,7 +219,6 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean hasFiles = false;
|
||||
docenv.notice("main.Loading_source_files_for_package", name);
|
||||
|
||||
if (files == null) {
|
||||
@ -238,19 +235,22 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler {
|
||||
}
|
||||
files = lb.toList();
|
||||
}
|
||||
|
||||
Set<JavaFileObject> ufiles = new HashSet<>();
|
||||
for (JavaFileObject fo : files) {
|
||||
if (ufiles.add(fo)) { // ignore duplicates
|
||||
// messager.notice("main.Loading_source_file", fn);
|
||||
trees.append(parse(fo));
|
||||
hasFiles = true;
|
||||
if (files.nonEmpty()) {
|
||||
for (JavaFileObject fo : files) {
|
||||
parse(fo, trees, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasFiles) {
|
||||
} else {
|
||||
messager.warning(Messager.NOPOS, "main.no_source_files_for_package",
|
||||
name.replace(File.separatorChar, '.'));
|
||||
name.replace(File.separatorChar, '.'));
|
||||
}
|
||||
}
|
||||
|
||||
private void parse(JavaFileObject fo, ListBuffer<JCCompilationUnit> trees,
|
||||
boolean trace) {
|
||||
if (uniquefiles.add(fo)) { // ignore duplicates
|
||||
if (trace)
|
||||
docenv.notice("main.Loading_source_file", fo.getName());
|
||||
trees.append(parse(fo));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 7091528 8029145
|
||||
* @bug 7091528 8029145 8037484
|
||||
* @summary ensures javadoc parses unique source files and ignores all class files
|
||||
* @compile p/C1.java p/q/C2.java
|
||||
* @run main T7091528
|
||||
@ -50,6 +50,16 @@ public class T7091528 {
|
||||
"-sourcepath", testSrc.getAbsolutePath(),
|
||||
"-subpackages",
|
||||
"p:p.q");
|
||||
File testPkgDir = new File(testSrc, "p");
|
||||
File testFile = new File(testPkgDir, "C3.java");
|
||||
runTest("-d", ".",
|
||||
"-sourcepath", testSrc.getAbsolutePath(),
|
||||
testFile.getAbsolutePath(),
|
||||
"p");
|
||||
runTest("-d", ".",
|
||||
"-classpath", testSrc.getAbsolutePath(),
|
||||
testFile.getAbsolutePath(),
|
||||
"p");
|
||||
|
||||
}
|
||||
void runTest(String... args) {
|
||||
@ -65,7 +75,7 @@ public class T7091528 {
|
||||
}
|
||||
|
||||
if (rc != 0)
|
||||
System.err.println("javadoc failed: exit code = " + rc);
|
||||
throw new Error("javadoc failed: exit code = " + rc);
|
||||
|
||||
if (out.matches("(?s).*p/[^ ]+\\.class.*"))
|
||||
throw new Error("reading .class files");
|
||||
|
27
langtools/test/tools/javadoc/parser/7091528/p/C3.java
Normal file
27
langtools/test/tools/javadoc/parser/7091528/p/C3.java
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
/** This is class C3, and no package for me please */
|
||||
public class C3 {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user