jdk11u-dev icon indicating copy to clipboard operation
jdk11u-dev copied to clipboard

8253700: spurious "extends Throwable" at end of Optional.orElseThrow method declaration

Open amosshi opened this issue 1 year ago β€’ 7 comments

This is backprot for parity with 11.0.24-oracle


Backport of JDK-8253700

  • This is an unclean backport, contains two commits
  • Commit 1. is generated by git patch command, is a clean apply of the original commit
  • Commit 2. contains
    • a, Manual merge of the following .rej files
    • b. Manually fixed the TestThrows.java on Java 11 compile error, and fixed the test case to match the javadoc 11 output

.rej files

  • src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractExecutableMemberWriter.java.rej
    • This file has been manually merged into the commit 2
@@ -51,6 +51,7 @@
 import static jdk.javadoc.internal.doclets.formats.html.LinkInfoImpl.Kind.MEMBER;
 import static jdk.javadoc.internal.doclets.formats.html.LinkInfoImpl.Kind.MEMBER_TYPE_PARAMS;
 import static jdk.javadoc.internal.doclets.formats.html.LinkInfoImpl.Kind.RECEIVER_TYPE;
+import static jdk.javadoc.internal.doclets.formats.html.LinkInfoImpl.Kind.THROWS_TYPE;
 
 /**
  * Print method and constructor info.
@@ -254,19 +255,16 @@
      */
     protected Content getExceptions(ExecutableElement member) {
         List<? extends TypeMirror> exceptions = utils.asInstantiatedMethodType(typeElement, member).getThrownTypes();
-        Content htmltree = new ContentBuilder();
-        if (!exceptions.isEmpty()) {
-            Content link = writer.getLink(new LinkInfoImpl(configuration, MEMBER, exceptions.get(0)));
-            htmltree.add(link);
-            for (int i = 1; i < exceptions.size(); i++) {
-                htmltree.add(",");
-                htmltree.add(DocletConstants.NL);
-                Content exceptionLink = writer.getLink(new LinkInfoImpl(configuration, MEMBER,
-                        exceptions.get(i)));
-                htmltree.add(exceptionLink);
+        Content htmlTree = new ContentBuilder();
+        for (TypeMirror t : exceptions) {
+            if (!htmlTree.isEmpty()) {
+                htmlTree.add(",");
+                htmlTree.add(DocletConstants.NL);
             }
+            Content link = writer.getLink(new LinkInfoImpl(configuration, THROWS_TYPE, t));
+            htmlTree.add(link);
         }
-        return htmltree;
+        return htmlTree;
     }
 
     protected TypeElement implementsMethodInIntfac(ExecutableElement method,
  • src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/LinkInfoImpl.java.rej
    • This file has been manually merged into the commit 2
@@ -208,14 +208,19 @@
         PROPERTY_COPY,
 
         /**
-         * A receiver type
+         * A receiver type.
          */
         RECEIVER_TYPE,
 
         /**
-         * A record component within a class signature
+         * A record component within a class signature.
          */
-        RECORD_COMPONENT
+        RECORD_COMPONENT,
+
+        /**
+         * A type thrown from a method.
+         */
+        THROWS_TYPE
     }
 
     public final HtmlConfiguration configuration;

Testing

  • πŸ’š Local: Test passed on MacOS 14.5
    • TestThrows.java: Test results: passed: 1
  • πŸ’š Pipeline: All checks have passed
  • πŸ’š Testing Machine: SAP nightlies passed on 2024-06-20
    • jtreg_langtools: jdk/javadoc/doclet/testThrows/TestThrows.java: SUCCESSFUL GitHub πŸ“Šβ² - [3,604 msec]

Progress

  • [ ] Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • [x] Change must not contain extraneous whitespace
  • [x] Commit message must refer to an issue
  • [ ] JDK-8253700 needs maintainer approval

Issue

  • JDK-8253700: spurious "extends Throwable" at end of Optional.orElseThrow method declaration (Bug - P3)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk11u-dev.git pull/2772/head:pull/2772
$ git checkout pull/2772

Update a local copy of the PR:
$ git checkout pull/2772
$ git pull https://git.openjdk.org/jdk11u-dev.git pull/2772/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 2772

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk11u-dev/pull/2772.diff

Webrev

Link to Webrev Comment

amosshi avatar Jun 14 '24 01:06 amosshi

:wave: Welcome back ashi! 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.

bridgekeeper[bot] avatar Jun 14 '24 01:06 bridgekeeper[bot]

❗ This change is not yet ready to be integrated. See the Progress checklist in the description for automated requirements.

openjdk[bot] avatar Jun 14 '24 01:06 openjdk[bot]

This backport pull request has now been updated with issue from the original commit.

openjdk[bot] avatar Jun 14 '24 01:06 openjdk[bot]

Webrevs

mlbridge[bot] avatar Jun 14 '24 01:06 mlbridge[bot]

Pre-submit tests failure Analysis

The error message

  • testng-7.3.0.jar(/Version.java):12: error: unmappable character (0xC3) for encoding US-ASCII
Running test testThrowsWithBound
Running javadoc...
args: [-d, testThrowsWithBound/out, testThrowsWithBound/src/C.java]
javadoc OUT:
Loading source file testThrowsWithBound/src/C.java...
Constructing Javadoc information...
Creating destination directory: "testThrowsWithBound/out/"
Standard Doclet version 11.0.25-internal
Building tree for all the packages and classes...
Generating testThrowsWithBound/out/C.html...
/Users/runner/work/jdk11u-dev-amos/jdk11u-dev-amos/jtreg/installed/lib/testng-7.3.0.jar(/Version.java):12: error: unmappable character (0xC3) for encoding US-ASCII
        System.out.println("...\\\\n... TestNG " + getVersionString() + " by C??dric Beust ([email protected])\\\\n...\\\\n");
                                                                            ^
/Users/runner/work/jdk11u-dev-amos/jdk11u-dev-amos/jtreg/installed/lib/testng-7.3.0.jar(/Version.java):12: error: unmappable character (0xA9) for encoding US-ASCII
        System.out.println("...\\\\n... TestNG " + getVersionString() + " by C??dric Beust ([email protected])\\\\n...\\\\n");
                                                                             ^

Reason

  • The is a special character Γ© in the source code bellow
  • https://github.com/testng-team/testng/blob/7.3.0/src/main/resources/Version.java#L12
    public static void displayBanner() {
        System.out.println("...\\n... TestNG " + getVersionString() + " by CΓ©dric Beust ([email protected])\\n...\\n");
    }

amosshi avatar Jun 18 '24 19:06 amosshi

All tests passed. Need community help to approve this PR. Thanks

amosshi avatar Jun 24 '24 00:06 amosshi

@amosshi This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

bridgekeeper[bot] avatar Jul 22 '24 04:07 bridgekeeper[bot]

@amosshi This pull request has been inactive for more than 8 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the /open pull request command.

bridgekeeper[bot] avatar Aug 20 '24 23:08 bridgekeeper[bot]