Skip to content
This repository was archived by the owner on Aug 27, 2022. It is now read-only.
/ lanai Public archive

Commit 9d57eef

Browse files
committedMar 4, 2020
8239575: javadoc triggers javac AssertionError for annos on modules
Ensure ModuleSymbols are implicitly loaded only once in the javadoc context. Reviewed-by: jjg
1 parent b3666b9 commit 9d57eef

File tree

2 files changed

+35
-15
lines changed

2 files changed

+35
-15
lines changed
 

‎src/jdk.compiler/share/classes/com/sun/tools/javac/code/ModuleFinder.java

+16-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2020, 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
@@ -248,23 +248,26 @@ private ModuleSymbol readModule(JavaFileObject fo) throws IOException {
248248
}
249249

250250
ModuleSymbol msym = syms.enterModule(name);
251-
msym.module_info.classfile = fo;
252-
if (fileManager.hasLocation(StandardLocation.PATCH_MODULE_PATH) && name != names.error) {
253-
msym.patchLocation = fileManager.getLocationForModule(StandardLocation.PATCH_MODULE_PATH, name.toString());
254251

255-
if (msym.patchLocation != null) {
256-
JavaFileObject patchFO = getModuleInfoFromLocation(StandardLocation.CLASS_OUTPUT, Kind.CLASS);
257-
patchFO = preferredFileObject(getModuleInfoFromLocation(msym.patchLocation, Kind.CLASS), patchFO);
258-
patchFO = preferredFileObject(getModuleInfoFromLocation(msym.patchLocation, Kind.SOURCE), patchFO);
252+
if (msym.module_info.classfile == null) {
253+
msym.module_info.classfile = fo;
254+
if (fileManager.hasLocation(StandardLocation.PATCH_MODULE_PATH) && name != names.error) {
255+
msym.patchLocation = fileManager.getLocationForModule(StandardLocation.PATCH_MODULE_PATH, name.toString());
259256

260-
if (patchFO != null) {
261-
msym.module_info.classfile = patchFO;
257+
if (msym.patchLocation != null) {
258+
JavaFileObject patchFO = getModuleInfoFromLocation(StandardLocation.CLASS_OUTPUT, Kind.CLASS);
259+
patchFO = preferredFileObject(getModuleInfoFromLocation(msym.patchLocation, Kind.CLASS), patchFO);
260+
patchFO = preferredFileObject(getModuleInfoFromLocation(msym.patchLocation, Kind.SOURCE), patchFO);
261+
262+
if (patchFO != null) {
263+
msym.module_info.classfile = patchFO;
264+
}
262265
}
263266
}
264-
}
265267

266-
msym.completer = Completer.NULL_COMPLETER;
267-
classFinder.fillIn(msym.module_info);
268+
msym.completer = Completer.NULL_COMPLETER;
269+
classFinder.fillIn(msym.module_info);
270+
}
268271

269272
return msym;
270273
}

‎test/langtools/jdk/javadoc/tool/modules/Modules.java

+19-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2020, 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
@@ -23,7 +23,7 @@
2323

2424
/*
2525
* @test
26-
* @bug 8159305 8166127 8175860 8176481
26+
* @bug 8159305 8166127 8175860 8176481 8239575
2727
* @summary Tests primarily the module graph computations.
2828
* @modules
2929
* jdk.javadoc/jdk.javadoc.internal.api
@@ -653,4 +653,21 @@ void createAuxiliaryModules(Path src) throws IOException {
653653
.write(src);
654654

655655
}
656+
657+
@Test
658+
public void testSingleModuleOptionWithSourcePathAndAnnotatedModule(Path base) throws Exception {
659+
Path src = base.resolve("src");
660+
Path mod = Paths.get(src.toString(), "m1");
661+
tb.writeJavaFiles(mod,
662+
"@Deprecated module m1 { exports p; }",
663+
"package p; public class C { }",
664+
"package p; public class P { }");
665+
execTask("--source-path", mod.toString(),
666+
"--module", "m1");
667+
checkModulesSpecified("m1");
668+
checkPackagesIncluded("p");
669+
checkTypesIncluded("p.C");
670+
checkTypesIncluded("p.P");
671+
}
672+
656673
}

0 commit comments

Comments
 (0)