A list of issues about Classfile API

- liangchenblue at gmail.com
Wed Jun 28 06:32:57 UTC 2023


Hello, I just looked over the Classfile API and found a few design issues,
aside from simple typos addressed in
https://github.com/openjdk/jdk/pull/14686:

Specific issues:
1. LocalVariable and LocalVariableType: They are missing factory methods.
In addition, they shouldn't have writeTo(BufWriter) method exposed in the
public API.
2.
ConstantPoolBuilder::constantValueEntry/loadableConstantEntry/annotationConstantValueEntry
should accept the 4 subword types: Byte, Boolean, Char, Short, which should
simply map to int entries.
3. BufWriter::asByteBuffer is weird: it is a write-allowed buffer that can
modify the buf until the old array is discarded when the backing buf is
expanded. Currently used by stack map generation and stack counting, we
should probably refit this to be user-safe or make this an internal API.
4. FieldRefEntry, MethodRefEntry, InterfaceMethodRefEntry,
ConstantDynamicEntry, InvokeDynamicEntry should have typeSymbol() to easily
access the shared field and method type symbols.
5. AttributeMapper::validSince should be removed, as mentioned by Adam a
while ago; it's unused and its implementations are sometimes incorrect.

General issues:
1. What about the attributes in Code? Currently, attributes in code aren't
delivered in Streaming besides the few hardcoded ones, which means that
custom attributes will be lost after a code model undergoes an accept-all
code transform. Is that the intended behavior?
    1.1. If CodeElement is only for streamable elements, then
StackMapTableAttribute shouldn't be a CodeElement, as it's never delivered
in code streams.
2. For nullable references, currently Classfile API accepts an
Optional<Xxx> argument instead of a nullable argument. Should we switch
those to nullable arguments instead, like parameter name for
MethodParameterInfo?
3. We can add @sealedGraph tag to sealed interfaces in the Classfile API,
which will render an svg image of the sealed class hierarchy (exists in
classes like j.l.i.CallSite already)

Thank you for taking time and reading through this long list. Feel free to
discuss these issues and propose suitable solutions.

Many thanks,
Chen Liang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/classfile-api-dev/attachments/20230628/796b3556/attachment.htm>


More information about the classfile-api-dev mailing list