If you have an instance you want to put inside
the generated code, and you trust it, you can
use the new "$V" argument spec to tell JavaPoet
to generate a Supplier lambda to construct the
object and immediately call it.
Design questions:
Is $V an appropriate name for the argument spec?
Currently, users need to explicitly register types as trusted, since serialization/deserialization of arbitrary objects is generally unsafe (although the code only calls getters/setters, it still counts). However, this might be too paranoid.
There is support for inlining records; Records are accessed exclusively using reflection, and Record.class is never loaded (check is done using Class.getName. However, since this project uses Java 8, it is hard to add a test for it. This can be removed; a user could add their own Record inliner if needed using addTypeInliner.
A helpful error message is thrown if generating code fails for any reason (untrusted type, missing public no-args constructor, or missing public setters for non-public instance fields ).
If you have an instance you want to put inside the generated code, and you trust it, you can use the new "$V" argument spec to tell JavaPoet to generate a Supplier lambda to construct the object and immediately call it.
Design questions:
$V
an appropriate name for the argument spec?Class.getName
. However, since this project uses Java 8, it is hard to add a test for it. This can be removed; a user could add their own Record inliner if needed usingaddTypeInliner
.Closes #968