classfile,passes: model RuntimeVisibleTypeAnnotations and AnnotationDefault

Type annotations (method- and code-level) and annotation defaults were
passed through as Raw bytes with the original pool indices; the writer
rebuilds the pool, so those indices pointed at the wrong utf8 or past
the pool end. HotSpot tolerates the garbage (lazy reflection parsing),
but ASM's ClassReader dies with ArrayIndexOutOfBoundsException while
Paper's plugin converter reads every method - 76 of 275 LoParkour
classes failed to convert. Target_info and type_path carry no pool
references and stay opaque bytes; type descriptors and element values
are modeled and rewritten by rename like plain annotations.
This commit is contained in:
Loki 2026-10-13 10:17:10 +02:00
parent 3f92b72c8b
commit 15cd31252e
Signed by: boba
GPG key ID: 253067914055423B
14 changed files with 654 additions and 224 deletions

View file

@ -4,7 +4,7 @@ pub mod annotations;
pub mod builder;
pub mod version;
pub use annotations::{Annotation, AnnotationValue};
pub use annotations::{Annotation, AnnotationValue, TypeAnnotation};
pub use version::Version;
use crate::format::StackMapFrame;
@ -54,6 +54,15 @@ pub enum Attribute {
RuntimeVisibleParameterAnnotations(Vec<Vec<Annotation>>),
/// `RuntimeInvisibleParameterAnnotations` (JVMS §4.7.19).
RuntimeInvisibleParameterAnnotations(Vec<Vec<Annotation>>),
/// `RuntimeVisibleTypeAnnotations` (JVMS §4.7.20): type-use
/// annotations. Parsed - raw pool indices go stale on write and ASM
/// dies with `ArrayIndexOutOfBoundsException` reading them back.
RuntimeVisibleTypeAnnotations(Vec<TypeAnnotation>),
/// `RuntimeInvisibleTypeAnnotations` (JVMS §4.7.21).
RuntimeInvisibleTypeAnnotations(Vec<TypeAnnotation>),
/// `AnnotationDefault` (JVMS §4.7.22): the default value of one
/// annotation member - a single `element_value` with pool references.
AnnotationDefault(AnnotationValue),
/// Everything else: name + raw `info` bytes (careful with pool indices).
Raw {
name: String,