Skip to content

8305714 : Add an extra test for JDK-8292755 #13719

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

Closed

Conversation

weibxiao
Copy link
Contributor

@weibxiao weibxiao commented Apr 28, 2023

Add a testing case for undefined classes in Java JShell to make sure JShell does not crash when an undefined class is used.

This test was passed for Linux, MacOS, and Windows by mach5 build and test in Oracle.

Reviewer: @coffeys @lahodaj


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

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 13719

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

Using diff file

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

Webrev

Link to Webrev Comment

@weibxiao weibxiao marked this pull request as ready for review April 28, 2023 13:48
@bridgekeeper
Copy link

bridgekeeper bot commented Apr 28, 2023

👋 Welcome back weibxiao! 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.

@weibxiao weibxiao marked this pull request as draft April 28, 2023 13:49
@openjdk
Copy link

openjdk bot commented Apr 28, 2023

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

  • kulla

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 kulla kulla-dev@openjdk.org label Apr 28, 2023
@weibxiao weibxiao marked this pull request as ready for review April 28, 2023 14:08
@openjdk openjdk bot added the rfr Pull request is ready for review label Apr 28, 2023
@weibxiao weibxiao changed the title 8305714 : JShell crashes when trying to throw a non-exist exception in certain lambdas 8305714 : Add an extra test for JDK-8292755 Apr 28, 2023
@mlbridge
Copy link

mlbridge bot commented Apr 28, 2023

Webrevs


/**
* @test
* @bug 8305714
Copy link
Contributor

Choose a reason for hiding this comment

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

8292755 would be the bug ID here since it refers to the product bug.

Is there a reason why you couldn't fold this test into the test/langtools/jdk/jshell/ClassesTest.java test ?

Copy link
Contributor Author

@weibxiao weibxiao Apr 28, 2023

Choose a reason for hiding this comment

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

Updated the bug ID.

Assuming ClassesTest is to verify the definition of Class.

After applying the patch, this test can catch the following error message described in the attached file in JShell Console.
image

Without the patch of 8292755 for JDK17, JShell will crash with this test case. After applying this patch in JDK17U, JShell console will print something like below,

Exception in thread "main" java.lang.InternalError: Exception during analyze - java.lang.AssertionError: isSubtype UNKNOWN
at jdk.jshell/jdk.jshell.TaskFactory$AnalyzeTask.analyze(TaskFactory.java:415)
at jdk.jshell/jdk.jshell.TaskFactory$AnalyzeTask.(TaskFactory.java:406)
at jdk.jshell/jdk.jshell.TaskFactory.lambda$analyze$1(TaskFactory.java:178)
at jdk.jshell/jdk.jshell.TaskFactory.lambda$runTask$4(TaskFactory.java:213)
at jdk.compiler/com.sun.tools.javac.api.JavacTaskPool.getTask(JavacTaskPool.java:193)
at jdk.jshell/jdk.jshell.TaskFactory.runTask(TaskFactory.java:206)
at jdk.jshell/jdk.jshell.TaskFactory.analyze(TaskFactory.java:175)

Copy link
Contributor

@coffeys coffeys 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 - minor suggestions

/**
* @test
* @bug 8292755
* @summary make sure JShell not crashing while throwing undefined exception
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest "InternalError seen while throwing undefined exception" as summary.

"interface RunnableWithThrowable {\n" +
" void run() throws Throwable;\n" +
"\n" +
" // You can also replace `static` with `default` and test again\n" +
Copy link
Contributor

Choose a reason for hiding this comment

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

why the comment in test code ? maybe you can create a 2nd test instead :

    public void testUndefinedClass1() throws Exception{
        String code = "@FunctionalInterface\n" +
                "interface RunnableWithThrowable {\n" +
                " void run() throws Throwable;\n" +
                "\n" +
                " default RunnableWithThrowable getInstance() {\n" +
                " return () -> { throw new NotExist(); };\n" +
                " }\n" +
                "}";
        // set terminal height so that help output won't hit page breaks
        System.setProperty("test.terminal.height", "1000000");
        doRunTest((inputSink, out) -> {
            inputSink.write(code + "\n");
            waitOutput(out, "NotExist");
        });
    }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the summary. And I remove the code to set the terminal height. I don't think it is necessary since there are only two lines for the print-out.

@openjdk openjdk bot removed the rfr Pull request is ready for review label May 4, 2023
@openjdk openjdk bot added the rfr Pull request is ready for review label May 4, 2023
@weibxiao
Copy link
Contributor Author

weibxiao commented May 4, 2023

@lahodaj , let me know if you have any concerns and comments. Thanks.

@openjdk
Copy link

openjdk bot commented May 4, 2023

@weibxiao 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:

8305714: Add an extra test for JDK-8292755

Reviewed-by: coffeys

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

  • 1a1ce66: 8305080: Suppress the 'removal' warning for finalize() from test/hotspot/jtreg/compiler/jvmci/common/testcases that used in compiler/jvmci/compilerToVM/ tests
  • 3b430b9: 8250596: Update remaining manpage references from "OS X" to "macOS"
  • 948f3b3: 8301493: Replace NULL with nullptr in cpu/aarch64
  • f94f957: 8307331: Correctly update line maps when class redefine rewrites bytecodes
  • 302bc2f: 8307421: Fix comment in g1CollectionSetChooser.hpp after JDK-8306836
  • e19cf26: 8307196: Dangling pointer warning for MetadataAllocationRequest
  • 1b143ba: 8307378: Allow collectors to provide specific values for GC notifications' actions
  • a44e890: 8307308: Add serviceability_ttf_virtual group to exclude jvmti tests developed for virtual threads
  • 46df171: 8304948: [vectorapi] C2 crashes when expanding VectorBox
  • 111858f: 8307489: ProblemList jdk/incubator/vector/LoadJsvmlTest.java on windows-x64
  • ... and 100 more: https://git.openjdk.org/jdk/compare/80fae514b16bfe38ff29f71f8cdc6d4c3482ad3d...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.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@coffeys) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready Pull request is ready to be integrated label May 4, 2023
@weibxiao
Copy link
Contributor Author

weibxiao commented May 5, 2023

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label May 5, 2023
@openjdk
Copy link

openjdk bot commented May 5, 2023

@weibxiao
Your change (at version baa82f6) is now ready to be sponsored by a Committer.

@coffeys
Copy link
Contributor

coffeys commented May 5, 2023

/sponsor

@openjdk
Copy link

openjdk bot commented May 5, 2023

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

  • 1a1ce66: 8305080: Suppress the 'removal' warning for finalize() from test/hotspot/jtreg/compiler/jvmci/common/testcases that used in compiler/jvmci/compilerToVM/ tests
  • 3b430b9: 8250596: Update remaining manpage references from "OS X" to "macOS"
  • 948f3b3: 8301493: Replace NULL with nullptr in cpu/aarch64
  • f94f957: 8307331: Correctly update line maps when class redefine rewrites bytecodes
  • 302bc2f: 8307421: Fix comment in g1CollectionSetChooser.hpp after JDK-8306836
  • e19cf26: 8307196: Dangling pointer warning for MetadataAllocationRequest
  • 1b143ba: 8307378: Allow collectors to provide specific values for GC notifications' actions
  • a44e890: 8307308: Add serviceability_ttf_virtual group to exclude jvmti tests developed for virtual threads
  • 46df171: 8304948: [vectorapi] C2 crashes when expanding VectorBox
  • 111858f: 8307489: ProblemList jdk/incubator/vector/LoadJsvmlTest.java on windows-x64
  • ... and 100 more: https://git.openjdk.org/jdk/compare/80fae514b16bfe38ff29f71f8cdc6d4c3482ad3d...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented May 5, 2023

@coffeys @weibxiao Pushed as commit 746f8d1.

💡 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 kulla kulla-dev@openjdk.org
Development

Successfully merging this pull request may close these issues.

2 participants