[records] Mark generated toString/equals/hashCode in class files somehow?

Tagir Valeev amaembo at gmail.com
Fri Aug 7 03:48:34 UTC 2020


Hello!

I'm working on class-file decompiler for records and discovered that
there's no special flag for generated equals/hashCode/toString (like
ACC_SYNTHETIC). This allows determining whether this method was
explicitly specified in the source code only by looking into method
implementation whether it has an ObjectMethods.bootstrap indy or not.
This looks implementation-dependent and somewhat fragile (though, of
course, we will do this if we have no other options). We also have a
stub decompiler that decompiles declarations only without checking
method bodies at all and it also wants to know whether
equals/hashCode/toString methods were autogenerated. Finally, other
bytecode tools like code coverage may need this to avoid calculating
coverage for methods not present in the source.

Is it possible to mark generated methods via ACC_SYNTHETIC or any
other flag or add any attribute that can be used to differentiate
auto-generated methods from the ones presented in the source code?

Having a synthetic mark for auto-generated canonical constructor or
accessor methods is less critical (as their bodies could be actually
written in the source code like this) but it would be also nice to
have it.

With best regards,
Tagir Valeev.


More information about the amber-spec-experts mailing list