Other usages of Classfile API
Brian Goetz
brian.goetz at oracle.com
Wed Mar 15 20:02:44 UTC 2023
All of these are potential uses in the long run.
On 3/15/2023 3:17 PM, - wrote:
> Since Classfile API is already seeing increased usage within JDK for
> its convenience, I wonder about the feasibility of a few potential
> usages:
>
> 1. In other JDK projects that change bytecode format, such as
> Valhalla. I guess the Classfile API within these projects will just
> adapt to the custom additions due to how it's distributed. Do we plan
> to switch the bytecode generation in Valhalla to Classfile too? It
> seems its constant API, which doesn't consider value or primitive
> classes, needs an update in the first place.
This is really three questions ;)
- Once the classfile API is in the JDK, Valhalla can extend it to
support the new classfile flags, new bytecodes, and new descriptor
strings. Later, when Valhalla integrates, these changes to the API will
come in with it.
- The compiler and related tools currently have their own classfile
library. It would be nice, eventually, to replace this with the
official classfile API. We will likely start with `javap`, but the
compiler is likely to be the last piece to change.
- The constants API will need some changes to support value class
descriptors, but this is waiting for the Valhalla translation scheme to
be locked down. (It is still possible we will find a way to do without
Q descriptors.)
> 2. External tools, like asmtools. Don't know if Classfile API can
> simplify its logic or not, and whether it can use Classfile API in the
> first place.
Over time, we will migrate internal tools and JDK usages to the
classfile API. This is an area where the community can likely help, if
you're looking :)
> 3. Reflection API for Annotations. The reflection API currently pulls
> annotation attribute bytes directly from the class bytes in the VM,
> and Classfile API might be able to handle the bytes to annotation
> conversion better.
I hadn't considered this one, but yes, this is a possible application.
It will surely take a long time to fully migrate away from ASM,
classreader, and other forms of bytecode analysis, but we'd like to get
there.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/classfile-api-dev/attachments/20230315/8f57d29d/attachment.htm>
More information about the classfile-api-dev
mailing list