问题
I wrote a JMH test about the cost of new
instruction, and checked the class files it generates. Except the usual classes, there're tons of derived classes in generated
folder:
This really shocked me, for just few annotations will lead to so many class bounded together through inheritance. I am curious about what things are in those class, so I use a decompile tool (BTW I learned this tool from one talk on KotlinConf 2019) called procyon
to decompile these generated class, most of them are control related, like measure time (they are explicitly specified can't be inlined) and collect metrics. But there're tons of weird boolean in those class:
there're many booleans in other generted class files as well. I googled this, and seems they're somewhat derived from JMH sourse code. So I want to ask what is these booleans used for? I will assume they are closely related to the working principle underlying the JMH... seems no comments about the booleans in JMH source code.
Also, any suggestions about improving the JMH test I mentioned from the very beginning...? I know testing such thing can be very tricky and vulnerable, so I don't know if they are accurate, or reliable enough.
Many thanks.
回答1:
Just guessing.
As you can see, the booleans are private and unused in the source file. They might be used somewhere via reflection, but I'd bet they aren't. So the only thing left is ensuring that markerBegin
and the other field belong to a different cache in order to prevent false sharing.
来源:https://stackoverflow.com/questions/59846710/what-are-these-weird-booleans-used-for-in-jmh