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

CODETOOLS-7902929: JMH generators fail for benchmark in unnamed package #38

Closed
wants to merge 3 commits into from

Conversation

retronym
Copy link
Contributor

@retronym retronym commented May 10, 2021

Prior to the patch, the enclosed test failed with:

$ mvn -Preflection test
...
Running UnnamedPackageTest
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.004 sec <<< FAILURE! - in UnnamedPackageTest
compileTest(UnnamedPackageTest)  Time elapsed: 0.004 sec  <<< FAILURE!
java.lang.AssertionError: Annotation generator had thrown the exception.:
java.lang.NullPointerException
	at org.junit.Assert.fail(Assert.java:89)
	at org.junit.Assert.assertTrue(Assert.java:42)
	at UnnamedPackageTest.compileTest(UnnamedPackageTest.java:55)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)

Progress

  • Change must not contain extraneous whitespace
  • Change must be properly reviewed

Issue

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jmh pull/38/head:pull/38
$ git checkout pull/38

Update a local copy of the PR:
$ git checkout pull/38
$ git pull https://git.openjdk.java.net/jmh pull/38/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 38

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jmh/pull/38.diff

Copy link
Member

@shipilev shipilev left a comment

Choose a reason for hiding this comment

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

In addition to patch comments, there are asm processor test failures with this new test, see GHA checks. It should be fixed e.g. like this:

diff --git a/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMClassInfo.java b/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMClassInfo.java
index f435d353..51b0442d 100644
--- a/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMClassInfo.java
+++ b/jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMClassInfo.java
@@ -79,11 +79,24 @@ class ASMClassInfo extends ClassVisitor implements ClassInfo {
         this.superName = superName;
         this.idName = name;
         this.access = access;
-        qualifiedName = name.replace("/", ".");
-        packageName = qualifiedName.substring(0, qualifiedName.lastIndexOf("."));
-        origQualifiedName = qualifiedName;
-        qualifiedName = qualifiedName.replace('$', '.');
-        this.name = qualifiedName.substring(qualifiedName.lastIndexOf(".") + 1);
+        this.qualifiedName = name.replace("/", ".");
+
+        int dotIndex = qualifiedName.lastIndexOf(".");
+        if (dotIndex != -1) {
+            packageName = qualifiedName.substring(0, dotIndex);
+        } else {
+            packageName = "";
+        }
+
+        this.origQualifiedName = qualifiedName;
+        this.qualifiedName = qualifiedName.replace('$', '.');
+
+        dotIndex = qualifiedName.lastIndexOf(".");
+        if (dotIndex != -1) {
+            this.name = qualifiedName.substring(dotIndex + 1);
+        } else {
+            this.name = qualifiedName;
+        }
     }
 
     @Override

You can reproduce this locally by running mvn ... -Pasm.

jmh-core-ct/src/test/java/UnnamedPackageTest.java Outdated Show resolved Hide resolved
@shipilev shipilev changed the title CODETOOLS-7902929 JMH reflection generator fails with NPE for benchmark in unnamed package CODETOOLS-7902929: JMH generators fail for benchmark in unnamed package May 10, 2021
Copy link
Member

@shipilev shipilev left a comment

Choose a reason for hiding this comment

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

Mondays, eh? Assuming tests are passing now, you are good to go!

@bridgekeeper
Copy link

bridgekeeper bot commented May 10, 2021

👋 Welcome back jzaugg! 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 May 10, 2021

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

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

7902929: JMH generators fail for benchmark in unnamed package

Reviewed-by: shade

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 no new commits pushed to the master branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential 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 (@shipilev) 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
Copy link

openjdk bot commented May 10, 2021

⚠️ @retronym a branch with the same name as the source branch for this pull request (master) is present in the target repository. If you eventually integrate this pull request then the branch master in your personal fork will diverge once you sync your personal fork with the upstream repository.

To avoid this situation, create a new branch for your changes and reset the master branch. You can do this by running the following commands in a local repository for your personal fork. Note: you do not have to name the new branch NEW-BRANCH-NAME.

$ git checkout -b NEW-BRANCH-NAME
$ git branch -f master 2415f72d50335a927749c36d730c4e05ad1626e1
$ git push -f origin master

Then proceed to create a new pull request with NEW-BRANCH-NAME as the source branch and close this one.

@openjdk openjdk bot added ready Pull request is ready to be integrated rfr Pull request is ready for review labels May 10, 2021
@mlbridge
Copy link

mlbridge bot commented May 10, 2021

Webrevs

@retronym retronym closed this May 10, 2021
@retronym
Copy link
Contributor Author

Resubmitted as #39

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready Pull request is ready to be integrated rfr Pull request is ready for review
2 participants