Skip to content
Permalink
Browse files
8239575: javadoc triggers javac AssertionError for annos on modules
Ensure ModuleSymbols are implicitly loaded only once in the javadoc context.

Reviewed-by: jjg
  • Loading branch information
Jan Lahoda committed Mar 4, 2020
1 parent b3666b9 commit 9d57eefe6ed88f7c5ed3637f7f37c57072c88894
Showing with 35 additions and 15 deletions.
  1. +16 −13 src/jdk.compiler/share/classes/com/sun/tools/javac/code/ModuleFinder.java
  2. +19 −2 test/langtools/jdk/javadoc/tool/modules/Modules.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2020, 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
@@ -248,23 +248,26 @@ private ModuleSymbol readModule(JavaFileObject fo) throws IOException {
}

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

if (msym.patchLocation != null) {
JavaFileObject patchFO = getModuleInfoFromLocation(StandardLocation.CLASS_OUTPUT, Kind.CLASS);
patchFO = preferredFileObject(getModuleInfoFromLocation(msym.patchLocation, Kind.CLASS), patchFO);
patchFO = preferredFileObject(getModuleInfoFromLocation(msym.patchLocation, Kind.SOURCE), patchFO);
if (msym.module_info.classfile == null) {
msym.module_info.classfile = fo;
if (fileManager.hasLocation(StandardLocation.PATCH_MODULE_PATH) && name != names.error) {
msym.patchLocation = fileManager.getLocationForModule(StandardLocation.PATCH_MODULE_PATH, name.toString());

if (patchFO != null) {
msym.module_info.classfile = patchFO;
if (msym.patchLocation != null) {
JavaFileObject patchFO = getModuleInfoFromLocation(StandardLocation.CLASS_OUTPUT, Kind.CLASS);
patchFO = preferredFileObject(getModuleInfoFromLocation(msym.patchLocation, Kind.CLASS), patchFO);
patchFO = preferredFileObject(getModuleInfoFromLocation(msym.patchLocation, Kind.SOURCE), patchFO);

if (patchFO != null) {
msym.module_info.classfile = patchFO;
}
}
}
}

msym.completer = Completer.NULL_COMPLETER;
classFinder.fillIn(msym.module_info);
msym.completer = Completer.NULL_COMPLETER;
classFinder.fillIn(msym.module_info);
}

return msym;
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2020, 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
@@ -23,7 +23,7 @@

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

}

@Test
public void testSingleModuleOptionWithSourcePathAndAnnotatedModule(Path base) throws Exception {
Path src = base.resolve("src");
Path mod = Paths.get(src.toString(), "m1");
tb.writeJavaFiles(mod,
"@Deprecated module m1 { exports p; }",
"package p; public class C { }",
"package p; public class P { }");
execTask("--source-path", mod.toString(),
"--module", "m1");
checkModulesSpecified("m1");
checkPackagesIncluded("p");
checkTypesIncluded("p.C");
checkTypesIncluded("p.P");
}

}

0 comments on commit 9d57eef

Please sign in to comment.