mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 23:34:52 +02:00
8212233: javadoc fails on jdk12 with "The code being documented uses modules but the packages defined in $URL are in the unnamed module."
Reviewed-by: hannesw, pmuthuswamy
This commit is contained in:
parent
6dfc66948b
commit
a5624be901
3 changed files with 182 additions and 4 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2019, 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
|
||||
|
@ -40,6 +40,8 @@ import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
|
|||
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
|
||||
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* Writes a file that tries to redirect to an alternate page.
|
||||
* The redirect uses JavaScript, if enabled, falling back on
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2019, 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
|
||||
|
@ -45,6 +45,8 @@ import javax.tools.Diagnostic;
|
|||
import javax.tools.Diagnostic.Kind;
|
||||
import javax.tools.DocumentationTool;
|
||||
|
||||
import com.sun.tools.javac.code.Flags;
|
||||
import com.sun.tools.javac.code.Symbol.ModuleSymbol;
|
||||
import jdk.javadoc.doclet.Reporter;
|
||||
import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
|
||||
import jdk.javadoc.internal.doclets.toolkit.Resources;
|
||||
|
@ -276,6 +278,12 @@ public class Extern {
|
|||
ModuleElement moduleElement = utils.containingModule(packageElement);
|
||||
Map<String, Item> pkgMap = packageItems.get(utils.getModuleName(moduleElement));
|
||||
item = (pkgMap != null) ? pkgMap.get(utils.getPackageName(packageElement)) : null;
|
||||
if (item == null && isAutomaticModule(moduleElement)) {
|
||||
pkgMap = packageItems.get(utils.getModuleName(null));
|
||||
if (pkgMap != null) {
|
||||
item = pkgMap.get(utils.getPackageName(packageElement));
|
||||
}
|
||||
}
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
@ -420,12 +428,25 @@ public class Extern {
|
|||
path), null);
|
||||
}
|
||||
} else if (moduleName == null) {
|
||||
throw new Fault(resources.getText("doclet.linkMismatch_ModuleLinkedtoPackage",
|
||||
path), null);
|
||||
// suppress the error message in the case of automatic modules
|
||||
if (!isAutomaticModule(me)) {
|
||||
throw new Fault(resources.getText("doclet.linkMismatch_ModuleLinkedtoPackage",
|
||||
path), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The following should be replaced by a new method such as Elements.isAutomaticModule
|
||||
private boolean isAutomaticModule(ModuleElement me) {
|
||||
if (me == null) {
|
||||
return false;
|
||||
} else {
|
||||
ModuleSymbol msym = (ModuleSymbol) me;
|
||||
return (msym.flags() & Flags.AUTOMATIC_MODULE) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isUrl (String urlCandidate) {
|
||||
try {
|
||||
new URL(urlCandidate);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue