RFR: 8170595: Optimize Class.isAnonymousClass

Claes Redestad claes.redestad at oracle.com
Thu Dec 1 13:38:23 UTC 2016


due to recent interest to optimize Class.isAnonymousClass[1] I took
a look at the implementation and found that we can further improve
performance of this method, especially when asking non-anonymous

As such calls are a common occurrence during startup and bootstrap
of lambdas this actually appears rather worthwhile:

Webrev: http://cr.openjdk.java.net/~redestad/8170595/webrev.01/
Bug: https://bugs.openjdk.java.net/browse/JDK-8170595



Benchmark                       Mode  Cnt    Score    Error  Units
Clazz.isAnonymousClass_Anon     avgt   50  200.900 ± 15.503  ns/op
Clazz.isAnonymousClass_Regular  avgt   50  136.896 ±  9.605  ns/op

Clazz.isAnonymousClass_Anon     avgt   50  186.564 ± 12.219  ns/op
Clazz.isAnonymousClass_Regular  avgt   50   33.878 ±  1.524  ns/op

See bug for benchmark source

More information about the core-libs-dev mailing list