Classfile API proposal to integrate basic print functionality directly to ClassModel and MethodModel
Michael van Acken
michael.van.acken at gmail.com
Thu Jul 21 15:42:30 UTC 2022
Am Do., 21. Juli 2022 um 16:15 Uhr schrieb Brian Goetz <
brian.goetz at oracle.com>:
> I think the root of the problem here is that CodeBuilder combines the
> “build my method” with stackmap generation, and if the latter fails,
> nothing is produced. And when stack map generation fails, you’d like to
> see a javap-like output so you can see what you did wrong.
>
> You can suppress stack map generation with an Option, and then you’ll get
> a classfile out, but that is probably a little hard to discover.
>
> This is a more general problem, not just for stack maps; there are other
> things that can cause code generation to fail (e.g., forward branch to a
> label that is never defined; invalid labels in exception tables; etc.) The
> main vector we have for feeding back information is the exception message,
> but putting the entire javap output of the method body in the exception
> message might be too much (but might not be, since any exception from
> building a classfile will trigger a round of debugging.)
>
> Any thoughts on how you would like to see this information fed back?
>
For me as a user building a compiler, the Classfile API is a black box.
When it
throws an exception that is caused by faulty input, one of the first
questions I
need to answer is "What did I do?" Well, I called lots and lots of methods
on
builder instances (for the most part CodeBuilder, of course). This is my
primary
point of contact to the API, and a textual log of those method calls would
be
helpful. Something along the lines of how Unix strace prints a log of
system
calls. Symbolic information of call details that allows to piece
information
together, if need be from thousands of lines of text.
Having such call log lines emitted on demand as part of a Classfile.build()
would be the most straightforward way to do this.
-- mva
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/classfile-api-dev/attachments/20220721/0b1bbed8/attachment-0001.htm>
More information about the classfile-api-dev
mailing list