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

JDK-8312445: Array types in annotation elements show square brackets twice #15019

Closed
wants to merge 3 commits into from

Conversation

hns
Copy link
Member

@hns hns commented Jul 25, 2023

Please review a change to fix the representation of array types as values of annotation elements in javadoc-generated documentation.

The primary fix is to avoid generating duplicate [] brackets for array types, but there are a few secondary improvements:

  • When linking to a type, only use the type name as link label, appending the .class as plain text after the link
  • Support linking to the base type of array types, again appending the square brackets and .class after the link
  • Leave it to the LinkFactory code to decide whether to use the qualified or simple type name for a link (uses isLinkable instead of isIncluded)

There already was some test code for the use of array types in annotation elements in TestNewLanguageFeatures.java, but it was disabled with a comment referring to another issue that has long been resolved.


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-8312445: Array types in annotation elements show square brackets twice (Bug - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 15019

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 25, 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 openjdk bot added the rfr Pull request is ready for review label Jul 25, 2023
@openjdk
Copy link

openjdk bot commented Jul 25, 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 25, 2023
@mlbridge
Copy link

mlbridge bot commented Jul 25, 2023

Webrevs

@@ -36,7 +36,8 @@
a = @AnnotationType(optional="foo",required=1994),
sa = {"up", "down"},
primitiveClassTest = boolean.class,
arrayClassTest = String[].class,
arrayPrimitiveTest = boolean[].class)
arrayClassTest = String[][].class,
Copy link
Member

Choose a reason for hiding this comment

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

Update the copyright year in this file.


// XXX: Add array test case after this if fixed:
//5020899: Incorrect internal representation of class-valued annotation elements
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for deleting this effective FIXME.

Comment on lines 1882 to 1890
public Content visitArray(ArrayType t, Void p) {
// render declared base component type as link
return visit(t.getComponentType()).add("[]");
}
}.visit(t);
@Override
protected Content defaultAction(TypeMirror t, Void p) {
return new TextBuilder(t.toString());
}
}.visit(t).add(".class");
Copy link
Member

Choose a reason for hiding this comment

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

I know that naming is hard, but consider renaming this or the outer t so they don't name-clash. Given a parameter with the same name is also present in defaultAction, I'd probably renamed the outer t. Renaming one parameter is simpler than renaming two parameters.

@pavelrappo
Copy link
Member

pavelrappo commented Jul 25, 2023

  • When linking to a type, only use the type name as link label, appending the .class as plain text after the link

This is how it's done by some IDE code editors whilst you hover over a class literal, which is probably okay.

@hns
Copy link
Member Author

hns commented Jul 26, 2023

Thanks for the review @pavelrappo, feedback is addressed in a new commit.

arrayPrimitiveTest = boolean[].class)
arrayClassTest = String[][].class,
arrayPrimitiveTest = boolean[].class,
classArrayTest = {TypeParameterSubClass[].class, String.class, long[][][].class})
Copy link
Member

Choose a reason for hiding this comment

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

Consider adding multi-dimensional array of TypeParameterSubClass, to test link generation. The problem with long[][][] is that there's nowhere to link to. The problem with String[][] is that JDK source where the java.lang.String doc comment resides is unavailable.

Alternatively, you could probably link to platform, so that we could see output for String[][].

Copy link
Member

@pavelrappo pavelrappo 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.

@openjdk
Copy link

openjdk bot commented Jul 26, 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:

8312445: Array types in annotation elements show square brackets twice

Reviewed-by: prappo

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

  • c22cadf: 8312526: Test dk/jfr/event/oldobject/TestHeapDeep.java failed: Could not find ChainNode
  • cc2a75e: 8312619: Strange error message when switching over long
  • 1f81e5b: 8312229: Crash involving yield, switch and anonymous classes
  • e9daf4a: 8312916: Remove remaining usages of -Xdebug from test/hotspot/jtreg
  • 117f42d: 8312625: Test serviceability/dcmd/vm/TrimLibcHeapTest.java failed: RSS use increased
  • 2d05d35: 8312979: Fix assembler_aarch64.hpp after JDK-8311847
  • 78a8a99: 8312488: tools/jpackage/share/AppLauncherEnvTest.java fails with dynamically linked libstdc++
  • cb82c95: 8312415: Expand -Xlint:serial checks to enum constants with specialized class bodies
  • c6396dc: 8039165: [Doc] MessageFormat null locale generates NullPointerException
  • 36f3bae: 8312401: SymbolTable::do_add_if_needed hangs when called in InstanceKlass::add_initialization_error path with requesting length exceeds max_symbol_length
  • ... and 4 more: https://git.openjdk.org/jdk/compare/b35ccb27c3c4a43eca4843bc1186a171fa23a7ed...master

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

hns commented Jul 26, 2023

/integrate

@openjdk
Copy link

openjdk bot commented Jul 26, 2023

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

  • c22cadf: 8312526: Test dk/jfr/event/oldobject/TestHeapDeep.java failed: Could not find ChainNode
  • cc2a75e: 8312619: Strange error message when switching over long
  • 1f81e5b: 8312229: Crash involving yield, switch and anonymous classes
  • e9daf4a: 8312916: Remove remaining usages of -Xdebug from test/hotspot/jtreg
  • 117f42d: 8312625: Test serviceability/dcmd/vm/TrimLibcHeapTest.java failed: RSS use increased
  • 2d05d35: 8312979: Fix assembler_aarch64.hpp after JDK-8311847
  • 78a8a99: 8312488: tools/jpackage/share/AppLauncherEnvTest.java fails with dynamically linked libstdc++
  • cb82c95: 8312415: Expand -Xlint:serial checks to enum constants with specialized class bodies
  • c6396dc: 8039165: [Doc] MessageFormat null locale generates NullPointerException
  • 36f3bae: 8312401: SymbolTable::do_add_if_needed hangs when called in InstanceKlass::add_initialization_error path with requesting length exceeds max_symbol_length
  • ... and 4 more: https://git.openjdk.org/jdk/compare/b35ccb27c3c4a43eca4843bc1186a171fa23a7ed...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Jul 26, 2023

@hns Pushed as commit 02a0473.

💡 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
Labels
integrated Pull request has been integrated javadoc javadoc-dev@openjdk.org
Development

Successfully merging this pull request may close these issues.

2 participants