Skip to content

Commit

Permalink
fix: descriptor being able to be empty in annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
jumanji144 committed Aug 27, 2023
1 parent 48e4220 commit 59289b6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public String mapMethodDesc(String methodDescriptor) {

@Override
public String mapDesc(String descriptor) {
if(descriptor.isEmpty()) return descriptor;
if (descriptor.charAt(0) == '(') {
return mapMethodDesc(descriptor);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ public AnnotationVisitor visitAnnotationDefault() {
@Override
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
AnnotationVisitor av = super.visitAnnotation(desc, visible);
if(desc.isEmpty()) return av;
String type = desc.substring(1, desc.length() - 1);
whenMatched(type, null, null,
builder -> addMethodAnno(builder, methodInfo, type));
Expand All @@ -203,6 +204,7 @@ public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
@Override
public AnnotationVisitor visitTypeAnnotation(int typeRef, TypePath typePath, String desc, boolean visible) {
AnnotationVisitor av = super.visitTypeAnnotation(typeRef, typePath, desc, visible);
if(desc.isEmpty()) return av;
String type = desc.substring(1, desc.length() - 1);
whenMatched(type, null, null,
builder -> addMethodAnno(builder, methodInfo, type));
Expand All @@ -212,6 +214,7 @@ public AnnotationVisitor visitTypeAnnotation(int typeRef, TypePath typePath, Str
@Override
public AnnotationVisitor visitParameterAnnotation(int parameter, String desc, boolean visible) {
AnnotationVisitor av = super.visitParameterAnnotation(parameter, desc, visible);
if(desc.isEmpty()) return av;
String type = desc.substring(1, desc.length() - 1);
whenMatched(type, null, null,
builder -> addMethodAnno(builder, methodInfo, type));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,15 @@ public AnnotationVisitor visitAnnotationDefault() {
@Override
public AnnotationVisitor visitParameterAnnotation(int parameter, String desc, boolean visible) {
AnnotationVisitor av = super.visitParameterAnnotation(parameter, desc, visible);
if(desc.isEmpty()) return av;
return new TextAnnotationVisitor(av, builder -> addMethodAnno(builder,
methodInfo.getName(), methodInfo.getDescriptor(), desc));
}

@Override
public AnnotationVisitor visitInsnAnnotation(int typeRef, TypePath typePath, String desc, boolean visible) {
AnnotationVisitor av = super.visitInsnAnnotation(typeRef, typePath, desc, visible);
if(desc.isEmpty()) return av;
return new TextAnnotationVisitor(av, builder -> addMethodAnno(builder,
methodInfo.getName(), methodInfo.getDescriptor(), desc));
}
Expand All @@ -213,6 +215,7 @@ public AnnotationVisitor visitInsnAnnotation(int typeRef, TypePath typePath, Str
public AnnotationVisitor visitTryCatchAnnotation(int typeRef, TypePath typePath, String desc,
boolean visible) {
AnnotationVisitor av = super.visitTryCatchAnnotation(typeRef, typePath, desc, visible);
if(desc.isEmpty()) return av;
return new TextAnnotationVisitor(av, builder -> addMethodAnno(builder,
methodInfo.getName(), methodInfo.getDescriptor(), desc));
}
Expand All @@ -223,6 +226,7 @@ public AnnotationVisitor visitLocalVariableAnnotation(int typeRef, TypePath type
String desc, boolean visible) {
AnnotationVisitor av = super.visitLocalVariableAnnotation(typeRef, typePath, start, end,
index, desc, visible);
if(desc.isEmpty()) return av;
return new TextAnnotationVisitor(av, builder -> addMethodAnno(builder,
methodInfo.getName(), methodInfo.getDescriptor(), desc));
}
Expand Down

0 comments on commit 59289b6

Please sign in to comment.