Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8317289: javadoc fails with -sourcepath if contains import statements #16312

wants to merge 2 commits into from


Copy link

@pavelrappo pavelrappo commented Oct 23, 2023

Please review a fix to a bug in processing of the sourcepath javadoc option.

The bug is that when -sourcepath/--source-path is specified, retrieving a module name does not account for any import statements in

Originally, I was thinking to propose the following simple fix on the javac side:

diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/
index b25c99d3b06..e046b3d310e 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/
@@ -1322,10 +1322,9 @@ public static boolean isModuleInfo(JCCompilationUnit tree) {
     public static JCModuleDecl getModule(JCCompilationUnit t) {
-        if (t.defs.nonEmpty()) {
-            JCTree def = t.defs.head;
-            if (def.hasTag(MODULEDEF))
-                return (JCModuleDecl) def;
+        for (var d = t.defs; d.nonEmpty(); d = d.tail) {
+            if (d.head.hasTag(MODULEDEF))
+                return (JCModuleDecl) d.head;
         return null;

However, Jan Lahoda (@lahodaj) told me that JCCompilationUnit already provides this functionality in a like-named method:

        public JCModuleDecl getModule() {
            return getModuleDecl();
        public JCModuleDecl getModuleDecl() {
            for (JCTree tree : defs) {
                if (tree.hasTag(MODULEDEF)) {
                    return (JCModuleDecl) tree;

            return null;

So the actual fix in this PR is even simpler than my original fix.


  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue


  • JDK-8317289: javadoc fails with -sourcepath if contains import statements (Bug - P4)



Using git

Checkout this PR locally:
$ git fetch pull/16312/head:pull/16312
$ git checkout pull/16312

Update a local copy of the PR:
$ git checkout pull/16312
$ git pull pull/16312/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 16312

View PR using the GUI difftool:
$ git pr show -t 16312

Using diff file

Download this PR as a diff file:


Link to Webrev Comment

Copy link

bridgekeeper bot commented Oct 23, 2023

👋 Welcome back prappo! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Oct 23, 2023
Copy link

openjdk bot commented Oct 23, 2023

@pavelrappo The following labels will be automatically applied to this pull request:

  • compiler
  • javadoc

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added javadoc compiler labels Oct 23, 2023
Copy link

mlbridge bot commented Oct 23, 2023


Copy link

@lahodaj lahodaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks!

Copy link

openjdk bot commented Oct 23, 2023

@pavelrappo This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file for details.

After integration, the commit message for the final commit will be:

8317289: javadoc fails with -sourcepath if contains import statements

Reviewed-by: jlahoda

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 8 new commits pushed to the master branch:

  • d888b26: 8318071: IgnoreUnrecognizedVMOptions flag still causes failure in ArchiveHeapTestClass
  • bea2d48: 8312475: org.jline.util.PumpReader signed byte problem
  • 9f767aa: 8318109: Writing JFR records while a CHT has taken its lock asserts in rank checking
  • bd22d23: 8318027: Support alternative name to jdk.internal.vm.compiler
  • c2efd77: 8295795: hsdis does not build with binutils 2.39+
  • 99de9bb: 8317807: JAVA_FLAGS removed from jtreg running in JDK-8317039
  • 704c6ea: 8303525: Refactor/cleanup open/test/jdk/javax/rmi/ssl/
  • 7c0a828: 8318649: G1: Remove unimplemented HeapRegionRemSet::add_code_root_locked

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Oct 23, 2023
Copy link
Member Author


Copy link

openjdk bot commented Oct 24, 2023

Going to push as commit fd332da.
Since your change was applied there have been 19 commits pushed to the master branch:

  • 6d3cb45: 8318591: avoid leaks in loadlib_aix.cpp reload_table()
  • cb383c0: 8318587: refresh libraries cache on AIX in print_vm_info
  • 4bfe226: 8310031: Parallel: Implement better work distribution for large object arrays in old gen
  • 08f7914: 8305753: Allow JIT compilation for -Xshare:dump
  • 728b858: 8318130: SocksSocketImpl needlessly encodes hostname for IPv6 addresses
  • eb59167: 8318691: runtime/CompressedOops/ fails with release VMs
  • 1b15011: 8318476: Add resource consumption note to BigInteger and BigDecimal
  • 5ba9705: 8318485: Narrow klass shift should be zero if encoding range extends to 0x1_0000_0000
  • 8d9a4b4: 8317678: Fix up hashCode() for ZipFile.Source.Key
  • 69c0ae2: 8318124: JFR: Rewrite instrumentation to use Class-File API
  • ... and 9 more:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Oct 24, 2023
@openjdk openjdk bot closed this Oct 24, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Oct 24, 2023
Copy link

openjdk bot commented Oct 24, 2023

@pavelrappo Pushed as commit fd332da.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
compiler integrated Pull request has been integrated javadoc
2 participants