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

Jason Zaugg jzaugg at openjdk.java.net
Mon May 10 13:29:50 UTC 2021


On Mon, 10 May 2021 09:07:09 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

>> 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)
>
> jmh-core-ct/src/test/java/UnnamedPackageTest.java line 45:
> 
>> 43:     public void test(S s) {
>> 44: 
>> 45:     }
> 
> For the matter of this test, we can leave only:
> 
> 
> @Benchmark
> public void test() {}
> 
> 
> ...right?

Yes! I was rushing here and left this copy/paste detritus.

> jmh-generator-asm/src/main/java/org/openjdk/jmh/generators/asm/ASMClassInfo.java line 89:
> 
>> 87:         } else {
>> 88:             packageName = "";
>> 89:         }
> 
> This is not the same as the previous code. Previous code handles "inner" classes with `$` additionally. See my previous comment how this should be resolved. This is why GHA have new failures.

D'oh, now I can't even get the copy part of copy/paste right. Selected your entire patch and re-applied this time.

-------------

PR: https://git.openjdk.java.net/jmh/pull/38


More information about the jmh-dev mailing list