Record without components is not processed correctly
Unfortunately, the JVM only recognizes a record as such if a record attribute is present in the class file. ASM only generates such an attribute if at least one record component is defined. As a consequence, the following record is not processed correctly: record EmptyRecord() {}
.
This can be validated easily by replaying an ASMified record:
ClassReader reader = new ClassReader(EmptyRecord.class.getName());
reader.accept(new TraceClassVisitor(null, new ASMifier(), new PrintWriter(System.out)), 0);
I suggest adding an additional ClassVisitor
method: visitRecord
with no arguments.
On a side note, the ClassVisitor
javaDoc does not mention the order in which the new method should be invoked.
For reference, the the code in OpenJDK:
bool is_record() const { return _record_components != NULL; }