On Wed, 17 Jul 2024 08:33:27 GMT, Adam Sotona <asot...@openjdk.org> wrote:

>> `WritableElement` has always been one of the biggest peculiarities of 
>> ClassFile API: it exposes element writing yet has no corresponding reading 
>> ability exposed. Its existence creates a lot of API noise, increasing 
>> maintenance cost in the long run. (This is an iceberg whose tip was exposed 
>> in #14705)
>> 
>> Removal details:
>> - `LocalVariable/LocalVariableType.writeTo`
>> - `WritableElement`
>> - In `BufWriter`:
>>   - `writeList(List<WritableElement>)`
>>   - `writeListIndices`: Hidden as we are not exposing 
>> `BoundAttribute.readEntryList`
>>   - `writeBytes(BufWriter other)`
>> - `ClassReader.compare`: Avoid reading from `BufWriter`
>> 
>> Future implementation cleanup out of scope of this patch:
>> - Annotation writing can be upgraded and move away from `Util.Writable`
>> - The writing of CP indices and attributes can move to their dedicated 
>> methods
>> - reading of entry list can pair up with writing of entry list in 
>> ClassReader/BufWriter in future addition
>
> src/java.base/share/classes/jdk/internal/classfile/impl/AnnotationReader.java 
> line 287:
> 
>> 285:     public static void writeAnnotation(BufWriterImpl buf, Annotation 
>> annotation) {
>> 286:         // handles annotations and type annotations
>> 287:         // TODO annotation cleanup later
> 
> Do you have any specific annotation cleanup in mind?

I am thinking of removing the Writable Hierarchy from annotations, and these 
static methods will handle writing with like a switch (on char, can't use 
pattern match in bootstrap) instead

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/20205#discussion_r1680896744

Reply via email to