Classfile API proposal to integrate basic print functionality directly to ClassModel and MethodModel
Adam Sotona
adam.sotona at oracle.com
Mon Jul 25 16:58:11 UTC 2022
During the experiments I found generic map-of-maps is too loose and missing any formatting information.
The API below has been derived from the requirements of the actual ClassPrinter and made as a minimal set of formatting features unified for producing JSON, YAML and XML.
The API also tries to avoid problematic combinations (for example list of lists is not possible, but list of maps of lists works perfectly).
Each Classfile API model can provide its printable form in the future.
Printers implementations are generic and very simple (~80 lines of code each, mainly one big switch expression) and custom printers can be implemented.
Please let me know your comments before I start rewriting the ClassPrinter into this intermediate form.
Thanks,
Adam
BTW: this is re-send of a too-big email with code and examples referencing to gist.github.com instead of attachements
Here is a small API to specify printable fragments and an example how sample class file could compose its printable form:
https://gist.github.com/asotona/cfc559c2c82e48d27551e32d2ef89474
And here is YAML print of the example above:
https://gist.github.com/asotona/dc62246e0ea2922a3f6b01018b02679a
XML print:
https://gist.github.com/asotona/3b731e820f98093731353f4826cd34ce
And JSON print:
https://gist.github.com/asotona/a1d0300d4ed68773d2d502db25892ade
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/classfile-api-dev/attachments/20220725/b1184019/attachment-0001.htm>
More information about the classfile-api-dev
mailing list