diff options
author | chibash <chiba@javassist.org> | 2015-01-06 01:17:34 +0900 |
---|---|---|
committer | chibash <chiba@javassist.org> | 2015-01-06 01:17:34 +0900 |
commit | ec3afdfb5d58b98ae8091d59f84d0d2f7f97a725 (patch) | |
tree | f1b1544f83f34fba403281e09c0a32a520286214 /src/main/javassist/bytecode/AttributeInfo.java | |
parent | f2093c28be24336593e1ebd9c2c633ee0f8c5b5c (diff) | |
download | javassist-ec3afdfb5d58b98ae8091d59f84d0d2f7f97a725.tar.gz javassist-ec3afdfb5d58b98ae8091d59f84d0d2f7f97a725.zip |
fixed JASSIST-240. support for Runtime[In]VisibleTypeAnnotations
Diffstat (limited to 'src/main/javassist/bytecode/AttributeInfo.java')
-rw-r--r-- | src/main/javassist/bytecode/AttributeInfo.java | 100 |
1 files changed, 56 insertions, 44 deletions
diff --git a/src/main/javassist/bytecode/AttributeInfo.java b/src/main/javassist/bytecode/AttributeInfo.java index 7dee7829..5f26d5c9 100644 --- a/src/main/javassist/bytecode/AttributeInfo.java +++ b/src/main/javassist/bytecode/AttributeInfo.java @@ -74,53 +74,65 @@ public class AttributeInfo { { int name = in.readUnsignedShort(); String nameStr = cp.getUtf8Info(name); - if (nameStr.charAt(0) < 'L') { - if (nameStr.equals(AnnotationDefaultAttribute.tag)) - return new AnnotationDefaultAttribute(cp, name, in); - else if (nameStr.equals(BootstrapMethodsAttribute.tag)) - return new BootstrapMethodsAttribute(cp, name, in); - else if (nameStr.equals(CodeAttribute.tag)) - return new CodeAttribute(cp, name, in); - else if (nameStr.equals(ConstantAttribute.tag)) - return new ConstantAttribute(cp, name, in); - else if (nameStr.equals(DeprecatedAttribute.tag)) - return new DeprecatedAttribute(cp, name, in); - else if (nameStr.equals(EnclosingMethodAttribute.tag)) - return new EnclosingMethodAttribute(cp, name, in); - else if (nameStr.equals(ExceptionsAttribute.tag)) - return new ExceptionsAttribute(cp, name, in); - else if (nameStr.equals(InnerClassesAttribute.tag)) - return new InnerClassesAttribute(cp, name, in); + char first = nameStr.charAt(0); + if (first < 'M') { + if (first < 'E') { + if (nameStr.equals(AnnotationDefaultAttribute.tag)) + return new AnnotationDefaultAttribute(cp, name, in); + else if (nameStr.equals(BootstrapMethodsAttribute.tag)) + return new BootstrapMethodsAttribute(cp, name, in); + else if (nameStr.equals(CodeAttribute.tag)) + return new CodeAttribute(cp, name, in); + else if (nameStr.equals(ConstantAttribute.tag)) + return new ConstantAttribute(cp, name, in); + else if (nameStr.equals(DeprecatedAttribute.tag)) + return new DeprecatedAttribute(cp, name, in); + } + else { + if (nameStr.equals(EnclosingMethodAttribute.tag)) + return new EnclosingMethodAttribute(cp, name, in); + else if (nameStr.equals(ExceptionsAttribute.tag)) + return new ExceptionsAttribute(cp, name, in); + else if (nameStr.equals(InnerClassesAttribute.tag)) + return new InnerClassesAttribute(cp, name, in); + else if (nameStr.equals(LineNumberAttribute.tag)) + return new LineNumberAttribute(cp, name, in); + else if (nameStr.equals(LocalVariableAttribute.tag)) + return new LocalVariableAttribute(cp, name, in); + else if (nameStr.equals(LocalVariableTypeAttribute.tag)) + return new LocalVariableTypeAttribute(cp, name, in); + } } else { - /* Note that the names of Annotations attributes begin with 'R'. - */ - if (nameStr.equals(LineNumberAttribute.tag)) - return new LineNumberAttribute(cp, name, in); - else if (nameStr.equals(LocalVariableAttribute.tag)) - return new LocalVariableAttribute(cp, name, in); - else if (nameStr.equals(LocalVariableTypeAttribute.tag)) - return new LocalVariableTypeAttribute(cp, name, in); - else if (nameStr.equals(MethodParametersAttribute.tag)) - return new MethodParametersAttribute(cp, name, in); - else if (nameStr.equals(AnnotationsAttribute.visibleTag) - || nameStr.equals(AnnotationsAttribute.invisibleTag)) { - // RuntimeVisibleAnnotations or RuntimeInvisibleAnnotations - return new AnnotationsAttribute(cp, name, in); + if (first < 'S') { + /* Note that the names of Annotations attributes begin with 'R'. + */ + if (nameStr.equals(MethodParametersAttribute.tag)) + return new MethodParametersAttribute(cp, name, in); + else if (nameStr.equals(AnnotationsAttribute.visibleTag) + || nameStr.equals(AnnotationsAttribute.invisibleTag)) { + // RuntimeVisibleAnnotations or RuntimeInvisibleAnnotations + return new AnnotationsAttribute(cp, name, in); + } + else if (nameStr.equals(ParameterAnnotationsAttribute.visibleTag) + || nameStr.equals(ParameterAnnotationsAttribute.invisibleTag)) + return new ParameterAnnotationsAttribute(cp, name, in); + else if (nameStr.equals(TypeAnnotationsAttribute.visibleTag) + || nameStr.equals(TypeAnnotationsAttribute.invisibleTag)) + return new TypeAnnotationsAttribute(cp, name, in); + } + else { + if (nameStr.equals(SignatureAttribute.tag)) + return new SignatureAttribute(cp, name, in); + else if (nameStr.equals(SourceFileAttribute.tag)) + return new SourceFileAttribute(cp, name, in); + else if (nameStr.equals(SyntheticAttribute.tag)) + return new SyntheticAttribute(cp, name, in); + else if (nameStr.equals(StackMap.tag)) + return new StackMap(cp, name, in); + else if (nameStr.equals(StackMapTable.tag)) + return new StackMapTable(cp, name, in); } - else if (nameStr.equals(ParameterAnnotationsAttribute.visibleTag) - || nameStr.equals(ParameterAnnotationsAttribute.invisibleTag)) - return new ParameterAnnotationsAttribute(cp, name, in); - else if (nameStr.equals(SignatureAttribute.tag)) - return new SignatureAttribute(cp, name, in); - else if (nameStr.equals(SourceFileAttribute.tag)) - return new SourceFileAttribute(cp, name, in); - else if (nameStr.equals(SyntheticAttribute.tag)) - return new SyntheticAttribute(cp, name, in); - else if (nameStr.equals(StackMap.tag)) - return new StackMap(cp, name, in); - else if (nameStr.equals(StackMapTable.tag)) - return new StackMapTable(cp, name, in); } return new AttributeInfo(cp, name, in); |