Skip to content

Conversation

@hns
Copy link
Member

@hns hns commented Jul 5, 2023

Please review a fix to make the comparator used by the JavaDoc index pages to be transitive (see JBS issue for a description and example of the problem).

I fix the bug by creating method getIndexElementKey(Element) to extract the key for comparing elements in Comparator.makeIndexElementComparator, and allowing IndexBuilder to reuse that extractor method when comparing element index items to search tag index items. The rationale for this approach was to preserve the current order for sorting elements in the index, and to keep the change simple (considering possible backport to 21).

In the process I also simplified some parts of the code a bit (simpler logic to compare names in element comparator, no need for composite comparator for classes-only index).

For the test, I added various elements and search tags that trigger the condition to the existing TestIndex page and replaced checkOutput with checkOrder to test the order of index page items.


Progress

  • 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

Issue

  • JDK-8311264: JavaDoc index comparator is not transitive (Bug - P3)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/14776/head:pull/14776
$ git checkout pull/14776

Update a local copy of the PR:
$ git checkout pull/14776
$ git pull https://git.openjdk.org/jdk.git pull/14776/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 14776

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/14776.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 5, 2023

👋 Welcome back hannesw! 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
Copy link

openjdk bot commented Jul 5, 2023

@hns The following label will be automatically applied to this pull request:

  • javadoc

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

@openjdk openjdk bot added the javadoc javadoc-dev@openjdk.org label Jul 5, 2023
@openjdk openjdk bot added the rfr Pull request is ready for review label Jul 5, 2023
@mlbridge
Copy link

mlbridge bot commented Jul 5, 2023

Webrevs

Copy link
Contributor

@jonathan-gibbons jonathan-gibbons left a comment

Choose a reason for hiding this comment

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

Seems reasonable, and cleaner

@openjdk
Copy link

openjdk bot commented Jul 6, 2023

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

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

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

8311264: JavaDoc index comparator is not transitive

Reviewed-by: jjg

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 9 new commits pushed to the master branch:

  • d072c40: 8311183: Remove unused mapping test files
  • 66d2736: 8307526: [JFR] Better handling of tampered JFR repository
  • 0616648: 8311035: CDS should not use dump time JVM narrow Klass encoding to pre-compute Klass ids
  • 6eba096: 8310999: Add @SInCE info in jdk.jsobject files
  • 6ebb0e3: 8311023: assert(false) failed: EA: missing memory path
  • 2cffef2: 8311290: Improve java.lang.ref.Cleaner rendered documentation
  • 22e17c2: 8311180: Remove unused unneeded definitions from globalDefinitions
  • cf82e31: 8311077: Fix -Wconversion warnings in jvmti code
  • 00ac46c: 8310645: CancelledResponse.java does not use HTTP/2 when testing the HttpClient

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 Jul 6, 2023
@hns
Copy link
Member Author

hns commented Jul 6, 2023

/integrate

@openjdk
Copy link

openjdk bot commented Jul 6, 2023

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

  • edb2be1: 8311279: TestStressIGVNAndCCP.java failed with different IGVN traces for the same seed
  • d072c40: 8311183: Remove unused mapping test files
  • 66d2736: 8307526: [JFR] Better handling of tampered JFR repository
  • 0616648: 8311035: CDS should not use dump time JVM narrow Klass encoding to pre-compute Klass ids
  • 6eba096: 8310999: Add @SInCE info in jdk.jsobject files
  • 6ebb0e3: 8311023: assert(false) failed: EA: missing memory path
  • 2cffef2: 8311290: Improve java.lang.ref.Cleaner rendered documentation
  • 22e17c2: 8311180: Remove unused unneeded definitions from globalDefinitions
  • cf82e31: 8311077: Fix -Wconversion warnings in jvmti code
  • 00ac46c: 8310645: CancelledResponse.java does not use HTTP/2 when testing the HttpClient

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Jul 6, 2023

@hns Pushed as commit 0741cd3.

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

@hns
Copy link
Member Author

hns commented Jul 6, 2023

/backport jdk21

@openjdk
Copy link

openjdk bot commented Jul 6, 2023

@hns the backport was successfully created on the branch hns-backport-0741cd32 in my personal fork of openjdk/jdk21. To create a pull request with this backport targeting openjdk/jdk21:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 0741cd32 from the openjdk/jdk repository.

The commit being backported was authored by Hannes Wallnöfer on 6 Jul 2023 and was reviewed by Jonathan Gibbons.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21:

$ git fetch https://github.com/openjdk-bots/jdk21.git hns-backport-0741cd32:hns-backport-0741cd32
$ git checkout hns-backport-0741cd32
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk21.git hns-backport-0741cd32

@pavelrappo
Copy link
Member

pavelrappo commented Jul 6, 2023

I can see that I'm late to the party. FWIW, the change looks good to me.

There's probably one additional problem that predates this PR. I see that Comparators.makeIndexElementComparator breaks ties by comparing fully qualified names. Although unlikely to happen in practise, in theory it might break when one has a static nested class and a class in the default package (hence not applicable to JDK) that share FQN. Here's an example I used for one of our tests earlier (you might need to scroll it if reading inline on GitHub):

/*
* There are two different exceptions that share the same simple name:
*
* 1. P.MyException (a nested static class in an unnamed package)
* 2. P.MyException (a public class in the P package)
*
* Although unconventional, it is not prohibited for a package name to
* start with an upper case letter. This test disregards that
* convention for the setup to work: the package and the
* class should have the same FQN to be confusing.
*
* A permissible but equally unconventional alternative would be to
* keep the package lower-case but give the class a lower-case name p.
*
* This setup works likely because of JLS 6.3. Scope of a Declaration:
*
* The scope of a top level class or interface (7.6) is all class
* and interface declarations in the package in which the top
* level class or interface is declared.
*/
@Test
public void testOuterClassAndPackage(Path base) throws Exception {
var src = base.resolve("src");
tb.writeJavaFiles(src, """
package P;
public class MyException extends RuntimeException { }
""", """
package pkg;
public class Parent {
/** @throws P.MyException sometimes */
public void m() { }
}
""", """
public class Child extends pkg.Parent {
/** @throws P.MyException {@inheritDoc} */
@Override
public void m() { }
}
""", """
public class P {
public static class MyException extends RuntimeException { }
}
""");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integrated Pull request has been integrated javadoc javadoc-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

3 participants