8175860: javadoc crashes with incorrect module sourcepath
Reviewed-by: jjg
This commit is contained in:
parent
558b587367
commit
9617bfb0f6
@ -188,6 +188,11 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler {
|
|||||||
.classTrees(classTrees.toList())
|
.classTrees(classTrees.toList())
|
||||||
.scanSpecifiedItems();
|
.scanSpecifiedItems();
|
||||||
|
|
||||||
|
// abort, if errors were encountered during modules initialization
|
||||||
|
if (messager.hasErrors()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// Parse the files in the packages and subpackages to be documented
|
// Parse the files in the packages and subpackages to be documented
|
||||||
ListBuffer<JCCompilationUnit> packageTrees = new ListBuffer<>();
|
ListBuffer<JCCompilationUnit> packageTrees = new ListBuffer<>();
|
||||||
parse(etable.getFilesToParse(), packageTrees, false);
|
parse(etable.getFilesToParse(), packageTrees, false);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2016, 2017, 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
|
||||||
@ -184,6 +184,10 @@ public class ModuleTestBase extends TestRunner {
|
|||||||
assertPresent(regex, Task.OutputKind.DIRECT);
|
assertPresent(regex, Task.OutputKind.DIRECT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void assertErrorNotPresent(String regex) throws Exception {
|
||||||
|
assertNotPresent(regex, Task.OutputKind.DIRECT);
|
||||||
|
}
|
||||||
|
|
||||||
void assertPresent(String regex, Task.OutputKind kind) throws Exception {
|
void assertPresent(String regex, Task.OutputKind kind) throws Exception {
|
||||||
List<String> foundList = tb.grep(regex, currentTask.getOutputLines(kind));
|
List<String> foundList = tb.grep(regex, currentTask.getOutputLines(kind));
|
||||||
if (foundList.isEmpty()) {
|
if (foundList.isEmpty()) {
|
||||||
@ -192,6 +196,14 @@ public class ModuleTestBase extends TestRunner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void assertNotPresent(String regex, Task.OutputKind kind) throws Exception {
|
||||||
|
List<String> foundList = tb.grep(regex, currentTask.getOutputLines(kind));
|
||||||
|
if (!foundList.isEmpty()) {
|
||||||
|
dumpDocletDiagnostics();
|
||||||
|
throw new Exception(regex + " found in: " + kind);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void dumpDocletDiagnostics() {
|
void dumpDocletDiagnostics() {
|
||||||
for (Task.OutputKind kind : Task.OutputKind.values()) {
|
for (Task.OutputKind kind : Task.OutputKind.values()) {
|
||||||
String output = currentTask.getOutput(kind);
|
String output = currentTask.getOutput(kind);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2016, 2017, 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
|
||||||
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 8159305 8166127
|
* @bug 8159305 8166127 8175860
|
||||||
* @summary Tests primarily the module graph computations.
|
* @summary Tests primarily the module graph computations.
|
||||||
* @modules
|
* @modules
|
||||||
* jdk.javadoc/jdk.javadoc.internal.api
|
* jdk.javadoc/jdk.javadoc.internal.api
|
||||||
@ -38,6 +38,7 @@
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
import toolbox.*;
|
import toolbox.*;
|
||||||
import toolbox.Task.Expect;
|
import toolbox.Task.Expect;
|
||||||
@ -92,6 +93,29 @@ public class Modules extends ModuleTestBase {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMissingModuleWithSourcePath(Path base) throws Exception {
|
||||||
|
Path src = base.resolve("src");
|
||||||
|
Path mod = src.resolve("m1");
|
||||||
|
|
||||||
|
ModuleBuilder mb1 = new ModuleBuilder(tb, "m1");
|
||||||
|
mb1.comment("The first module.")
|
||||||
|
.exports("m1pub")
|
||||||
|
.requires("m2")
|
||||||
|
.classes("package m1pub; /** Class A */ public class A {}")
|
||||||
|
.classes("package m1pro; /** Class B */ public class B {}")
|
||||||
|
.write(src);
|
||||||
|
|
||||||
|
Path javafile = Paths.get(mod.toString(), "m1pub/A.java");
|
||||||
|
|
||||||
|
execNegativeTask("--source-path", mod.toString(),
|
||||||
|
javafile.toString());
|
||||||
|
|
||||||
|
assertErrorPresent("error: cannot access module-info");
|
||||||
|
assertErrorNotPresent("error - fatal error encountered");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMultipleModulesAggregatedModuleOption(Path base) throws Exception {
|
public void testMultipleModulesAggregatedModuleOption(Path base) throws Exception {
|
||||||
Path src = base.resolve("src");
|
Path src = base.resolve("src");
|
||||||
|
Loading…
Reference in New Issue
Block a user