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

Brian Goetz brian.goetz at oracle.com
Mon Jul 25 17:28:29 UTC 2022


That's a good move.  Can we push further?  We have types here for 
mapping a key to a:

  - list of simple values
  - list of arbitrary fragments
  - list of printables
  - list of list of printable (blocklist)



On 7/25/2022 1:20 PM, Adam Sotona wrote:
>
> Or maybe we could let the printer to auto-quote as needed by the 
> actual value in the context of the actual format 😊
>
> So yes, it can be reduced:
>
> publicsealedinterface*Printable* {
>
> publicString *key*();
>
> publicsealedinterface*/Fragment/* extendsPrintable {}
>
> publicrecord/Value/(String key, String ConstantDesc value) 
> implements/Fragment/ {}
>
> publicrecord/Quoted/(String key, String value) implements/Fragment/ {}
>
> publicrecord/Decimal/(String key, intvalue) implements/Fragment/ {}
>
> publicrecord/ValueList/(String key, List<StringConstantDesc> values) 
> implements/Fragment/ {}
>
> publicrecord/QuotedList/(String key, List<String> values) 
> implements/Fragment/ {}
>
> publicrecord/Mapping/(String key, List</Fragment/> fragments) 
> implementsPrintable {}
>
> publicrecord/BlockMapping/(String key, List<Printable> printables) 
> implementsPrintable {}
>
> publicrecord/BlockList/(String key, List</BlockMapping/> 
> blockMappings) implementsPrintable {}
>
> publicrecord/Comment/(String key) implementsPrintable {}
>
> On 25.07.2022 19:03, "classfile-api-dev" 
> <classfile-api-dev-retn at openjdk.org> wrote:
>
> Unfortunately it is format-specific.
>
> We can unify it down to “all-quoted” however the visual benefits will 
> be lost.
>
> On 25.07.2022 19:00, "Brian Goetz" <brian.goetz at oracle.com> wrote:
>
>
> This seems like nice progress.  I wonder if we can boil it down 
> further?  Can we, for example, get rid of Quoted by Plain(key, 
> "\"value\""), and such?
>
>
> On 7/25/2022 12:40 PM, Adam Sotona wrote:
>
>     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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/classfile-api-dev/attachments/20220725/ae008a50/attachment-0001.htm>


More information about the classfile-api-dev mailing list