Classfile API proposal to integrate basic print functionality directly to ClassModel and MethodModel

Brian Goetz brian.goetz at oracle.com
Fri Jul 22 17:44:29 UTC 2022


I’ve significantly progressed in the prototype as you propose to process ClassPrint (to use Maps and Lists) and I’m experimenting with minimal set of formatting features.

Cool, let’s see where it leads.  I wasn’t saying that the map-of-maps is the only way to get there, as much as it seemed a viable way to get to a cleanly factored and flexible result.  So let’s see where it goes, and if it runs off the road, we’ll try something else.

We can drop many features and it still looks OK, except for expanded vs compact lists and maps. Compact map can be represented as array, however I’m not aware of anything similar for Map. Or we can use explicit delimiter class Compact, where everything inside is treated as compact form. Or we can avoid compact maps and use Maps and Lists for expanded form and arrays for compact lists.

I am not sure what you mean by “compact lists and maps”?  Can you give an example so I see what you are aiming at?


Who is the audience for the JSON/XML/YAML-formatted results?  Is someone going to parse it with Jackson and do analysis on it?  If human-readability is important, why is the javap formatting not sufficient?
Audience for JSON/XML/YAML are all test writers validating anything in the generated code.
Yes, people prefer to parse structured text in a specific format over full-text or regexp searches across unstructured log output.

OK, so the idea here is that we think it is easier to grovel over the result with (say) XPath to make assertions, than to traverse the CM directly?  Perhaps we need to provide more navigation operators on the models to make it easier to make such assertions?

I would propose do it the other way:
- clean and refactor ClassPrinter
- integrate ClassPrinter with Classfile API (also for internal debugging purposes)
- extend javap about options to produce JSON/XML/YAML output as thin layer delegating to ClassfileAPI
- extend javap about verification option as thin layer delegating to ClassfileAPI (however that is a different topic :)

Yes, either way I think more of javap moves into ClassFile API, which is good.  Let’s see where this leads.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/classfile-api-dev/attachments/20220722/194bef0f/attachment-0001.htm>


More information about the classfile-api-dev mailing list