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:
parent
3f92b72c8b
commit
15cd31252e
14 changed files with 654 additions and 224 deletions
|
|
@ -8,7 +8,7 @@ use ristretto_classfile::attributes::{
|
|||
LocalVariableTypeTable as RtLocalType, Record as RtRecord,
|
||||
};
|
||||
|
||||
use super::annotations::annotation;
|
||||
use super::annotations;
|
||||
use super::helpers;
|
||||
use super::pool::Pool;
|
||||
use crate::error::ClassfileError;
|
||||
|
|
@ -181,50 +181,38 @@ pub(super) fn convert(attr: &Attribute, pool: &mut Pool) -> Result<RtAttr, Class
|
|||
},
|
||||
Attribute::RuntimeVisibleAnnotations(annos) => RtAttr::RuntimeVisibleAnnotations {
|
||||
name_index: pool.utf8("RuntimeVisibleAnnotations")?,
|
||||
annotations: annos
|
||||
.iter()
|
||||
.map(|anno| annotation(anno, pool))
|
||||
.collect::<Result<_, _>>()?,
|
||||
annotations: annotations::list(annos, pool)?,
|
||||
},
|
||||
Attribute::RuntimeInvisibleAnnotations(annos) => RtAttr::RuntimeInvisibleAnnotations {
|
||||
name_index: pool.utf8("RuntimeInvisibleAnnotations")?,
|
||||
annotations: annos
|
||||
.iter()
|
||||
.map(|anno| annotation(anno, pool))
|
||||
.collect::<Result<_, _>>()?,
|
||||
annotations: annotations::list(annos, pool)?,
|
||||
},
|
||||
Attribute::RuntimeVisibleParameterAnnotations(params) => {
|
||||
RtAttr::RuntimeVisibleParameterAnnotations {
|
||||
name_index: pool.utf8("RuntimeVisibleParameterAnnotations")?,
|
||||
parameter_annotations: params
|
||||
.iter()
|
||||
.map(|param| {
|
||||
Ok(ristretto_classfile::attributes::ParameterAnnotation {
|
||||
annotations: param
|
||||
.iter()
|
||||
.map(|anno| annotation(anno, pool))
|
||||
.collect::<Result<_, _>>()?,
|
||||
})
|
||||
})
|
||||
.collect::<Result<_, _>>()?,
|
||||
parameter_annotations: annotations::parameters(params, pool)?,
|
||||
}
|
||||
}
|
||||
Attribute::RuntimeInvisibleParameterAnnotations(params) => {
|
||||
RtAttr::RuntimeInvisibleParameterAnnotations {
|
||||
name_index: pool.utf8("RuntimeInvisibleParameterAnnotations")?,
|
||||
parameter_annotations: params
|
||||
.iter()
|
||||
.map(|param| {
|
||||
Ok(ristretto_classfile::attributes::ParameterAnnotation {
|
||||
annotations: param
|
||||
.iter()
|
||||
.map(|anno| annotation(anno, pool))
|
||||
.collect::<Result<_, _>>()?,
|
||||
})
|
||||
})
|
||||
.collect::<Result<_, _>>()?,
|
||||
parameter_annotations: annotations::parameters(params, pool)?,
|
||||
}
|
||||
}
|
||||
Attribute::RuntimeVisibleTypeAnnotations(annos) => RtAttr::RuntimeVisibleTypeAnnotations {
|
||||
name_index: pool.utf8("RuntimeVisibleTypeAnnotations")?,
|
||||
type_annotations: annotations::type_list(annos, pool)?,
|
||||
},
|
||||
Attribute::RuntimeInvisibleTypeAnnotations(annos) => {
|
||||
RtAttr::RuntimeInvisibleTypeAnnotations {
|
||||
name_index: pool.utf8("RuntimeInvisibleTypeAnnotations")?,
|
||||
type_annotations: annotations::type_list(annos, pool)?,
|
||||
}
|
||||
}
|
||||
Attribute::AnnotationDefault(value) => RtAttr::AnnotationDefault {
|
||||
name_index: pool.utf8("AnnotationDefault")?,
|
||||
element: annotations::element(value, pool)?,
|
||||
},
|
||||
Attribute::Raw { name, data } => RtAttr::Unknown {
|
||||
name_index: pool.utf8(name)?,
|
||||
info: data.clone(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue