Classfile API proposal to integrate basic print functionality directly to ClassModel and MethodModel
Adam Sotona
adam.sotona at oracle.com
Thu Jul 21 10:17:32 UTC 2022
Hi,
I would like to propose removal of solo class jdk.classfile.util.ClassPrinter (as the only class remaining in jdk.classfile.util package).
And integrate print functionality directly to ClassModel:
/**
* Print this classfile.
*
* @param output handler to receive printed text
* @param printOptions optional print configuration
*/
default void print(Consumer<String> output, PrintOption... printOptions) {
new ClassPrinterImpl(output, printOptions).printClass(this);
}
And to MethodModel:
/**
* Print this method.
*
* @param output handler to receive printed text
* @param printOptions optional print configuration
*/
default void print(Consumer<String> output, PrintOption... printOptions) {
new ClassPrinterImpl(output, printOptions).printMethod(this);
}
With help of very simple PrintOption:
/**
* An option that affects the printing.
*/
public sealed interface PrintOption {
/**
* Selection of available print output formats.
*/
public enum Format implements PrintOption {
JSON, XML, YAML
}
/**
* Verbosity level of the print.
*/
public enum Verbosity implements PrintOption {
MEMBERS_ONLY, CRITICAL_ATTRIBUTES, TRACE_ALL
}
}
Any comments are welcome.
Thanks,
Adam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/classfile-api-dev/attachments/20220721/b25a9a03/attachment-0001.htm>
More information about the classfile-api-dev
mailing list