diff options
Diffstat (limited to 'src/proguard/classfile/attribute/annotation')
42 files changed, 1738 insertions, 40 deletions
diff --git a/src/proguard/classfile/attribute/annotation/Annotation.java b/src/proguard/classfile/attribute/annotation/Annotation.java index b2f18d5..3e24a9e 100644 --- a/src/proguard/classfile/attribute/annotation/Annotation.java +++ b/src/proguard/classfile/attribute/annotation/Annotation.java @@ -2,7 +2,7 @@ * ProGuard -- shrinking, optimization, obfuscation, and preverification * of Java bytecode. * - * Copyright (c) 2002-2013 Eric Lafortune (eric@graphics.cornell.edu) + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free diff --git a/src/proguard/classfile/attribute/annotation/AnnotationDefaultAttribute.java b/src/proguard/classfile/attribute/annotation/AnnotationDefaultAttribute.java index b8f29cc..1b06e82 100644 --- a/src/proguard/classfile/attribute/annotation/AnnotationDefaultAttribute.java +++ b/src/proguard/classfile/attribute/annotation/AnnotationDefaultAttribute.java @@ -2,7 +2,7 @@ * ProGuard -- shrinking, optimization, obfuscation, and preverification * of Java bytecode. * - * Copyright (c) 2002-2013 Eric Lafortune (eric@graphics.cornell.edu) + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free diff --git a/src/proguard/classfile/attribute/annotation/AnnotationElementValue.java b/src/proguard/classfile/attribute/annotation/AnnotationElementValue.java index 8354f5d..1e6365c 100644 --- a/src/proguard/classfile/attribute/annotation/AnnotationElementValue.java +++ b/src/proguard/classfile/attribute/annotation/AnnotationElementValue.java @@ -2,7 +2,7 @@ * ProGuard -- shrinking, optimization, obfuscation, and preverification * of Java bytecode. * - * Copyright (c) 2002-2013 Eric Lafortune (eric@graphics.cornell.edu) + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free diff --git a/src/proguard/classfile/attribute/annotation/AnnotationsAttribute.java b/src/proguard/classfile/attribute/annotation/AnnotationsAttribute.java index a936ff4..dcb7cf6 100644 --- a/src/proguard/classfile/attribute/annotation/AnnotationsAttribute.java +++ b/src/proguard/classfile/attribute/annotation/AnnotationsAttribute.java @@ -2,7 +2,7 @@ * ProGuard -- shrinking, optimization, obfuscation, and preverification * of Java bytecode. * - * Copyright (c) 2002-2013 Eric Lafortune (eric@graphics.cornell.edu) + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -21,7 +21,7 @@ package proguard.classfile.attribute.annotation; import proguard.classfile.*; -import proguard.classfile.attribute.Attribute; +import proguard.classfile.attribute.*; import proguard.classfile.attribute.annotation.visitor.AnnotationVisitor; /** @@ -44,7 +44,7 @@ public abstract class AnnotationsAttribute extends Attribute /** - * Creates an initialized AnnotationsAttribute. + * Creates an initialized AnnotationsAttribute. */ protected AnnotationsAttribute(int u2attributeNameIndex, int u2annotationsCount, @@ -97,4 +97,18 @@ public abstract class AnnotationsAttribute extends Attribute annotationVisitor.visitAnnotation(clazz, method, annotations[index]); } } + + + /** + * Applies the given visitor to all code attribute annotations. + */ + public void annotationsAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, AnnotationVisitor annotationVisitor) + { + for (int index = 0; index < u2annotationsCount; index++) + { + // We don't need double dispatching here, since there is only one + // type of Annotation. + annotationVisitor.visitAnnotation(clazz, method, codeAttribute, annotations[index]); + } + } } diff --git a/src/proguard/classfile/attribute/annotation/ArrayElementValue.java b/src/proguard/classfile/attribute/annotation/ArrayElementValue.java index 0aab49b..4d814c0 100644 --- a/src/proguard/classfile/attribute/annotation/ArrayElementValue.java +++ b/src/proguard/classfile/attribute/annotation/ArrayElementValue.java @@ -2,7 +2,7 @@ * ProGuard -- shrinking, optimization, obfuscation, and preverification * of Java bytecode. * - * Copyright (c) 2002-2013 Eric Lafortune (eric@graphics.cornell.edu) + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free diff --git a/src/proguard/classfile/attribute/annotation/ClassElementValue.java b/src/proguard/classfile/attribute/annotation/ClassElementValue.java index ffeaf71..0e5de1e 100644 --- a/src/proguard/classfile/attribute/annotation/ClassElementValue.java +++ b/src/proguard/classfile/attribute/annotation/ClassElementValue.java @@ -2,7 +2,7 @@ * ProGuard -- shrinking, optimization, obfuscation, and preverification * of Java bytecode. * - * Copyright (c) 2002-2013 Eric Lafortune (eric@graphics.cornell.edu) + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -63,6 +63,15 @@ public class ClassElementValue extends ElementValue /** + * Returns the class info name. + */ + public String getClassName(Clazz clazz) + { + return clazz.getString(u2classInfoIndex); + } + + + /** * Applies the given visitor to all referenced classes. */ public void referencedClassesAccept(ClassVisitor classVisitor) diff --git a/src/proguard/classfile/attribute/annotation/ConstantElementValue.java b/src/proguard/classfile/attribute/annotation/ConstantElementValue.java index 8be4329..5ff51db 100644 --- a/src/proguard/classfile/attribute/annotation/ConstantElementValue.java +++ b/src/proguard/classfile/attribute/annotation/ConstantElementValue.java @@ -2,7 +2,7 @@ * ProGuard -- shrinking, optimization, obfuscation, and preverification * of Java bytecode. * - * Copyright (c) 2002-2013 Eric Lafortune (eric@graphics.cornell.edu) + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free diff --git a/src/proguard/classfile/attribute/annotation/ElementValue.java b/src/proguard/classfile/attribute/annotation/ElementValue.java index 19a7198..9c0f2c9 100644 --- a/src/proguard/classfile/attribute/annotation/ElementValue.java +++ b/src/proguard/classfile/attribute/annotation/ElementValue.java @@ -2,7 +2,7 @@ * ProGuard -- shrinking, optimization, obfuscation, and preverification * of Java bytecode. * - * Copyright (c) 2002-2013 Eric Lafortune (eric@graphics.cornell.edu) + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free diff --git a/src/proguard/classfile/attribute/annotation/EnumConstantElementValue.java b/src/proguard/classfile/attribute/annotation/EnumConstantElementValue.java index cd0f2f9..1105100 100644 --- a/src/proguard/classfile/attribute/annotation/EnumConstantElementValue.java +++ b/src/proguard/classfile/attribute/annotation/EnumConstantElementValue.java @@ -2,7 +2,7 @@ * ProGuard -- shrinking, optimization, obfuscation, and preverification * of Java bytecode. * - * Copyright (c) 2002-2013 Eric Lafortune (eric@graphics.cornell.edu) + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free diff --git a/src/proguard/classfile/attribute/annotation/ParameterAnnotationsAttribute.java b/src/proguard/classfile/attribute/annotation/ParameterAnnotationsAttribute.java index ddaa3a6..4b0cb1c 100644 --- a/src/proguard/classfile/attribute/annotation/ParameterAnnotationsAttribute.java +++ b/src/proguard/classfile/attribute/annotation/ParameterAnnotationsAttribute.java @@ -2,7 +2,7 @@ * ProGuard -- shrinking, optimization, obfuscation, and preverification * of Java bytecode. * - * Copyright (c) 2002-2013 Eric Lafortune (eric@graphics.cornell.edu) + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -25,13 +25,13 @@ import proguard.classfile.attribute.Attribute; import proguard.classfile.attribute.annotation.visitor.AnnotationVisitor; /** - * This Attribute represents a runtime parameter annotations attribute. + * This Attribute represents a parameter annotations attribute. * * @author Eric Lafortune */ public abstract class ParameterAnnotationsAttribute extends Attribute { - public int u2parametersCount; + public int u1parametersCount; public int[] u2parameterAnnotationsCount; public Annotation[][] parameterAnnotations; @@ -48,13 +48,13 @@ public abstract class ParameterAnnotationsAttribute extends Attribute * Creates an initialized ParameterAnnotationsAttribute. */ protected ParameterAnnotationsAttribute(int u2attributeNameIndex, - int u2parametersCount, + int u1parametersCount, int[] u2parameterAnnotationsCount, Annotation[][] parameterAnnotations) { super(u2attributeNameIndex); - this.u2parametersCount = u2parametersCount; + this.u1parametersCount = u1parametersCount; this.u2parameterAnnotationsCount = u2parameterAnnotationsCount; this.parameterAnnotations = parameterAnnotations; } @@ -66,7 +66,7 @@ public abstract class ParameterAnnotationsAttribute extends Attribute public void annotationsAccept(Clazz clazz, Method method, AnnotationVisitor annotationVisitor) { // Loop over all parameters. - for (int parameterIndex = 0; parameterIndex < u2parametersCount; parameterIndex++) + for (int parameterIndex = 0; parameterIndex < u1parametersCount; parameterIndex++) { int annotationsCount = u2parameterAnnotationsCount[parameterIndex]; Annotation[] annotations = parameterAnnotations[parameterIndex]; diff --git a/src/proguard/classfile/attribute/annotation/RuntimeInvisibleAnnotationsAttribute.java b/src/proguard/classfile/attribute/annotation/RuntimeInvisibleAnnotationsAttribute.java index deda8a5..84d9d61 100644 --- a/src/proguard/classfile/attribute/annotation/RuntimeInvisibleAnnotationsAttribute.java +++ b/src/proguard/classfile/attribute/annotation/RuntimeInvisibleAnnotationsAttribute.java @@ -2,7 +2,7 @@ * ProGuard -- shrinking, optimization, obfuscation, and preverification * of Java bytecode. * - * Copyright (c) 2002-2013 Eric Lafortune (eric@graphics.cornell.edu) + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free diff --git a/src/proguard/classfile/attribute/annotation/RuntimeInvisibleParameterAnnotationsAttribute.java b/src/proguard/classfile/attribute/annotation/RuntimeInvisibleParameterAnnotationsAttribute.java index 2fcae88..0a5e1d7 100644 --- a/src/proguard/classfile/attribute/annotation/RuntimeInvisibleParameterAnnotationsAttribute.java +++ b/src/proguard/classfile/attribute/annotation/RuntimeInvisibleParameterAnnotationsAttribute.java @@ -2,7 +2,7 @@ * ProGuard -- shrinking, optimization, obfuscation, and preverification * of Java bytecode. * - * Copyright (c) 2002-2013 Eric Lafortune (eric@graphics.cornell.edu) + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -42,12 +42,12 @@ public class RuntimeInvisibleParameterAnnotationsAttribute extends ParameterAnno * Creates an initialized RuntimeInvisibleParameterAnnotationsAttribute. */ public RuntimeInvisibleParameterAnnotationsAttribute(int u2attributeNameIndex, - int u2parametersCount, + int u1parametersCount, int[] u2parameterAnnotationsCount, Annotation[][] parameterAnnotations) { super(u2attributeNameIndex, - u2parametersCount, + u1parametersCount, u2parameterAnnotationsCount, parameterAnnotations); } diff --git a/src/proguard/classfile/attribute/annotation/RuntimeInvisibleTypeAnnotationsAttribute.java b/src/proguard/classfile/attribute/annotation/RuntimeInvisibleTypeAnnotationsAttribute.java new file mode 100644 index 0000000..2e1ca95 --- /dev/null +++ b/src/proguard/classfile/attribute/annotation/RuntimeInvisibleTypeAnnotationsAttribute.java @@ -0,0 +1,77 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.visitor.AttributeVisitor; + +/** + * This Attribute represents a runtime invisible type annotations attribute. + * + * @author Eric Lafortune + */ +public class RuntimeInvisibleTypeAnnotationsAttribute extends TypeAnnotationsAttribute +{ + /** + * Creates an uninitialized RuntimeInvisibleTypeAnnotationsAttribute. + */ + public RuntimeInvisibleTypeAnnotationsAttribute() + { + } + + + /** + * Creates an initialized RuntimeInvisibleTypeAnnotationsAttribute. + */ + public RuntimeInvisibleTypeAnnotationsAttribute(int u2attributeNameIndex, + int u2annotationsCount, + TypeAnnotation[] annotations) + { + super(u2attributeNameIndex, u2annotationsCount, annotations); + } + + + // Implementations for Attribute. + + public void accept(Clazz clazz, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitRuntimeInvisibleTypeAnnotationsAttribute(clazz, this); + } + + + public void accept(Clazz clazz, Field field, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitRuntimeInvisibleTypeAnnotationsAttribute(clazz, field, this); + } + + + public void accept(Clazz clazz, Method method, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitRuntimeInvisibleTypeAnnotationsAttribute(clazz, method, this); + } + + + public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitRuntimeInvisibleTypeAnnotationsAttribute(clazz, method, codeAttribute, this); + } +} diff --git a/src/proguard/classfile/attribute/annotation/RuntimeVisibleAnnotationsAttribute.java b/src/proguard/classfile/attribute/annotation/RuntimeVisibleAnnotationsAttribute.java index da94f0c..89acf04 100644 --- a/src/proguard/classfile/attribute/annotation/RuntimeVisibleAnnotationsAttribute.java +++ b/src/proguard/classfile/attribute/annotation/RuntimeVisibleAnnotationsAttribute.java @@ -2,7 +2,7 @@ * ProGuard -- shrinking, optimization, obfuscation, and preverification * of Java bytecode. * - * Copyright (c) 2002-2013 Eric Lafortune (eric@graphics.cornell.edu) + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free diff --git a/src/proguard/classfile/attribute/annotation/RuntimeVisibleParameterAnnotationsAttribute.java b/src/proguard/classfile/attribute/annotation/RuntimeVisibleParameterAnnotationsAttribute.java index caa6830..cc273c2 100644 --- a/src/proguard/classfile/attribute/annotation/RuntimeVisibleParameterAnnotationsAttribute.java +++ b/src/proguard/classfile/attribute/annotation/RuntimeVisibleParameterAnnotationsAttribute.java @@ -2,7 +2,7 @@ * ProGuard -- shrinking, optimization, obfuscation, and preverification * of Java bytecode. * - * Copyright (c) 2002-2013 Eric Lafortune (eric@graphics.cornell.edu) + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -42,12 +42,12 @@ public class RuntimeVisibleParameterAnnotationsAttribute extends ParameterAnnota * Creates an initialized RuntimeVisibleParameterAnnotationsAttribute. */ public RuntimeVisibleParameterAnnotationsAttribute(int u2attributeNameIndex, - int u2parametersCount, + int u1parametersCount, int[] u2parameterAnnotationsCount, Annotation[][] parameterAnnotations) { super(u2attributeNameIndex, - u2parametersCount, + u1parametersCount, u2parameterAnnotationsCount, parameterAnnotations); } diff --git a/src/proguard/classfile/attribute/annotation/RuntimeVisibleTypeAnnotationsAttribute.java b/src/proguard/classfile/attribute/annotation/RuntimeVisibleTypeAnnotationsAttribute.java new file mode 100644 index 0000000..084827a --- /dev/null +++ b/src/proguard/classfile/attribute/annotation/RuntimeVisibleTypeAnnotationsAttribute.java @@ -0,0 +1,77 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.visitor.AttributeVisitor; + +/** + * This Attribute represents a runtime visible type annotations attribute. + * + * @author Eric Lafortune + */ +public class RuntimeVisibleTypeAnnotationsAttribute extends TypeAnnotationsAttribute +{ + /** + * Creates an uninitialized RuntimeVisibleTypeAnnotationsAttribute. + */ + public RuntimeVisibleTypeAnnotationsAttribute() + { + } + + + /** + * Creates an initialized RuntimeVisibleTypeAnnotationsAttribute. + */ + public RuntimeVisibleTypeAnnotationsAttribute(int u2attributeNameIndex, + int u2annotationsCount, + TypeAnnotation[] annotations) + { + super(u2attributeNameIndex, u2annotationsCount, annotations); + } + + + // Implementations for Attribute. + + public void accept(Clazz clazz, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitRuntimeVisibleTypeAnnotationsAttribute(clazz, this); + } + + + public void accept(Clazz clazz, Field field, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitRuntimeVisibleTypeAnnotationsAttribute(clazz, field, this); + } + + + public void accept(Clazz clazz, Method method, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitRuntimeVisibleTypeAnnotationsAttribute(clazz, method, this); + } + + + public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, AttributeVisitor attributeVisitor) + { + attributeVisitor.visitRuntimeVisibleTypeAnnotationsAttribute(clazz, method, codeAttribute, this); + } +} diff --git a/src/proguard/classfile/attribute/annotation/TypeAnnotation.java b/src/proguard/classfile/attribute/annotation/TypeAnnotation.java new file mode 100644 index 0000000..86e4ddf --- /dev/null +++ b/src/proguard/classfile/attribute/annotation/TypeAnnotation.java @@ -0,0 +1,162 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.annotation.target.TargetInfo; +import proguard.classfile.attribute.annotation.target.visitor.TargetInfoVisitor; +import proguard.classfile.attribute.annotation.visitor.*; + +/** + * Representation of a type annotation. + * + * @author Eric Lafortune + */ +public class TypeAnnotation extends Annotation +{ + public TargetInfo targetInfo; + public TypePathInfo[] typePath; + + + /** + * Creates an uninitialized TypeAnnotation. + */ + public TypeAnnotation() + { + } + + + /** + * Creates an initialized TypeAnnotation. + */ + public TypeAnnotation(int u2typeIndex, + int u2elementValuesCount, + ElementValue[] elementValues, + TargetInfo targetInfo, + TypePathInfo[] typePath) + { + super(u2typeIndex, u2elementValuesCount, elementValues); + + this.targetInfo = targetInfo; + this.typePath = typePath; + } + + + /** + * Applies the given visitor to the target info. + */ + public void targetInfoAccept(Clazz clazz, TargetInfoVisitor targetInfoVisitor) + { + // We don't need double dispatching here, since there is only one + // type of TypePathInfo. + targetInfo.accept(clazz, this, targetInfoVisitor); + } + + + /** + * Applies the given visitor to the target info. + */ + public void targetInfoAccept(Clazz clazz, Field field, TargetInfoVisitor targetInfoVisitor) + { + // We don't need double dispatching here, since there is only one + // type of TypePathInfo. + targetInfo.accept(clazz, field, this, targetInfoVisitor); + } + + + /** + * Applies the given visitor to the target info. + */ + public void targetInfoAccept(Clazz clazz, Method method, TargetInfoVisitor targetInfoVisitor) + { + // We don't need double dispatching here, since there is only one + // type of TypePathInfo. + targetInfo.accept(clazz, method, this, targetInfoVisitor); + } + + + /** + * Applies the given visitor to the target info. + */ + public void targetInfoAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, TargetInfoVisitor targetInfoVisitor) + { + // We don't need double dispatching here, since there is only one + // type of TypePathInfo. + targetInfo.accept(clazz, method, codeAttribute, this, targetInfoVisitor); + } + + + /** + * Applies the given visitor to all type path elements. + */ + public void typePathInfosAccept(Clazz clazz, TypePathInfoVisitor typePathVisitor) + { + for (int index = 0; index < typePath.length; index++) + { + // We don't need double dispatching here, since there is only one + // type of TypePathInfo. + typePathVisitor.visitTypePathInfo(clazz, this, typePath[index]); + } + } + + + /** + * Applies the given visitor to all type path elements. + */ + public void typePathInfosAccept(Clazz clazz, Field field, TypePathInfoVisitor typePathVisitor) + { + for (int index = 0; index < typePath.length; index++) + { + // We don't need double dispatching here, since there is only one + // type of TypePathInfo. + typePathVisitor.visitTypePathInfo(clazz, field, this, typePath[index]); + } + } + + + /** + * Applies the given visitor to all type path elements. + */ + public void typePathInfosAccept(Clazz clazz, Method method, TypePathInfoVisitor typePathVisitor) + { + for (int index = 0; index < typePath.length; index++) + { + // We don't need double dispatching here, since there is only one + // type of TypePathInfo. + typePathVisitor.visitTypePathInfo(clazz, method, this, typePath[index]); + } + } + + + /** + * Applies the given visitor to all type path elements. + */ + public void typePathInfosAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, TypeAnnotation typeAnnotation, TypePathInfoVisitor typePathVisitor) + { + for (int index = 0; index < typePath.length; index++) + { + // We don't need double dispatching here, since there is only one + // type of TypePathInfo. + typePathVisitor.visitTypePathInfo(clazz, method, codeAttribute, typeAnnotation, typePath[index]); + } + } +} diff --git a/src/proguard/classfile/attribute/annotation/TypeAnnotationsAttribute.java b/src/proguard/classfile/attribute/annotation/TypeAnnotationsAttribute.java new file mode 100644 index 0000000..7606e05 --- /dev/null +++ b/src/proguard/classfile/attribute/annotation/TypeAnnotationsAttribute.java @@ -0,0 +1,98 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation; + +import proguard.classfile.*; +import proguard.classfile.attribute.annotation.visitor.*; + +/** + * This Attribute represents a type annotations attribute. + * + * @author Eric Lafortune + */ +public abstract class TypeAnnotationsAttribute extends AnnotationsAttribute +{ + /** + * Creates an uninitialized TypeAnnotationsAttribute. + */ + protected TypeAnnotationsAttribute() + { + } + + + /** + * Creates an initialized TypeAnnotationsAttribute. + */ + protected TypeAnnotationsAttribute(int u2attributeNameIndex, + int u2annotationsCount, + TypeAnnotation[] annotations) + { + super(u2attributeNameIndex, u2annotationsCount, annotations); + } + + + /** + * Applies the given visitor to all class annotations. + */ + public void typeAnnotationsAccept(Clazz clazz, TypeAnnotationVisitor typeAnnotationVisitor) + { + TypeAnnotation[] annotations = (TypeAnnotation[])this.annotations; + + for (int index = 0; index < u2annotationsCount; index++) + { + // We don't need double dispatching here, since there is only one + // type of Annotation. + typeAnnotationVisitor.visitTypeAnnotation(clazz, annotations[index]); + } + } + + + /** + * Applies the given visitor to all field annotations. + */ + public void typeAnnotationsAccept(Clazz clazz, Field field, TypeAnnotationVisitor typeAnnotationVisitor) + { + TypeAnnotation[] annotations = (TypeAnnotation[])this.annotations; + + for (int index = 0; index < u2annotationsCount; index++) + { + // We don't need double dispatching here, since there is only one + // type of Annotation. + typeAnnotationVisitor.visitTypeAnnotation(clazz, field, annotations[index]); + } + } + + + /** + * Applies the given visitor to all method annotations. + */ + public void typeAnnotationsAccept(Clazz clazz, Method method, TypeAnnotationVisitor typeAnnotationVisitor) + { + TypeAnnotation[] annotations = (TypeAnnotation[])this.annotations; + + for (int index = 0; index < u2annotationsCount; index++) + { + // We don't need double dispatching here, since there is only one + // type of Annotation. + typeAnnotationVisitor.visitTypeAnnotation(clazz, method, annotations[index]); + } + } +} diff --git a/src/proguard/classfile/attribute/annotation/TypePathInfo.java b/src/proguard/classfile/attribute/annotation/TypePathInfo.java new file mode 100644 index 0000000..9b40f7c --- /dev/null +++ b/src/proguard/classfile/attribute/annotation/TypePathInfo.java @@ -0,0 +1,50 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation; + +/** + * Representation of a path element in a type annotation. + * + * @author Eric Lafortune + */ +public class TypePathInfo +{ + public int u1typePathKind; + public int u1typeArgumentIndex; + + + /** + * Creates an uninitialized TypePathInfo. + */ + public TypePathInfo() + { + } + + + /** + * Creates an initialized TypePathInfo. + */ + public TypePathInfo(int u1typePathKind, int u1typeArgumentIndex) + { + this.u1typePathKind = u1typePathKind; + this.u1typeArgumentIndex = u1typeArgumentIndex; + } +} diff --git a/src/proguard/classfile/attribute/annotation/target/CatchTargetInfo.java b/src/proguard/classfile/attribute/annotation/target/CatchTargetInfo.java new file mode 100644 index 0000000..9421b9c --- /dev/null +++ b/src/proguard/classfile/attribute/annotation/target/CatchTargetInfo.java @@ -0,0 +1,82 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation.target; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.annotation.TypeAnnotation; +import proguard.classfile.attribute.annotation.target.visitor.TargetInfoVisitor; + +/** + * Representation of a 'catch' annotation target. + * + * @author Eric Lafortune + */ +public class CatchTargetInfo extends TargetInfo +{ + public int u2exceptionTableIndex; + + + /** + * Creates an uninitialized CatchTargetInfo. + */ + public CatchTargetInfo() + { + } + + + /** + * Creates a partially initialized CatchTargetInfo. + */ + public CatchTargetInfo(byte u1targetType) + { + super(u1targetType); + } + + + /** + * Creates an initialized CatchTargetInfo. + */ + protected CatchTargetInfo(byte u1targetType, + int u2exceptionTableIndex) + { + super(u1targetType); + + this.u2exceptionTableIndex = u2exceptionTableIndex; + } + + + // Implementations for TargetInfo. + + /** + * Lets the visitor visit, with Method and CodeAttribute null. + */ + public void accept(Clazz clazz, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitCatchTargetInfo(clazz, null, null, typeAnnotation, this); + } + + + public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitCatchTargetInfo(clazz, method, codeAttribute, typeAnnotation, this); + } +} diff --git a/src/proguard/classfile/attribute/annotation/target/EmptyTargetInfo.java b/src/proguard/classfile/attribute/annotation/target/EmptyTargetInfo.java new file mode 100644 index 0000000..fb0d794 --- /dev/null +++ b/src/proguard/classfile/attribute/annotation/target/EmptyTargetInfo.java @@ -0,0 +1,72 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation.target; + +import proguard.classfile.*; +import proguard.classfile.attribute.annotation.TypeAnnotation; +import proguard.classfile.attribute.annotation.target.visitor.TargetInfoVisitor; + +/** + * Representation of an empty annotation target. + * + * @author Eric Lafortune + */ +public class EmptyTargetInfo extends TargetInfo +{ + /** + * Creates an uninitialized EmptyTargetInfo. + */ + public EmptyTargetInfo() + { + } + + + /** + * Creates an initialized EmptyTargetInfo. + */ + public EmptyTargetInfo(byte u1targetType) + { + super(u1targetType); + } + + + // Implementations for TargetInfo. + + /** + * Lets the visitor visit, with Field null. + */ + public void accept(Clazz clazz, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitEmptyTargetInfo(clazz, (Field)null, typeAnnotation, this); + } + + + public void accept(Clazz clazz, Field field, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitEmptyTargetInfo(clazz, field, typeAnnotation, this); + } + + + public void accept(Clazz clazz, Method method, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitEmptyTargetInfo(clazz, method, typeAnnotation, this); + } +} diff --git a/src/proguard/classfile/attribute/annotation/target/FormalParameterTargetInfo.java b/src/proguard/classfile/attribute/annotation/target/FormalParameterTargetInfo.java new file mode 100644 index 0000000..04bd9c5 --- /dev/null +++ b/src/proguard/classfile/attribute/annotation/target/FormalParameterTargetInfo.java @@ -0,0 +1,81 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation.target; + +import proguard.classfile.*; +import proguard.classfile.attribute.annotation.TypeAnnotation; +import proguard.classfile.attribute.annotation.target.visitor.TargetInfoVisitor; + +/** + * Representation of a formal parameter annotation target. + * + * @author Eric Lafortune + */ +public class FormalParameterTargetInfo extends TargetInfo +{ + public int u1formalParameterIndex; + + + /** + * Creates an uninitialized FormalParameterTargetInfo. + */ + public FormalParameterTargetInfo() + { + } + + + /** + * Creates a partially initialized FormalParameterTargetInfo. + */ + public FormalParameterTargetInfo(byte u1targetType) + { + super(u1targetType); + } + + + /** + * Creates an initialized FormalParameterTargetInfo. + */ + public FormalParameterTargetInfo(byte u1targetType, + int u1formalParameterIndex) + { + super(u1targetType); + + this.u1formalParameterIndex = u1formalParameterIndex; + } + + + // Implementations for TargetInfo. + + /** + * Lets the visitor visit, with Method null. + */ + public void accept(Clazz clazz, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitFormalParameterTargetInfo(clazz, null, typeAnnotation, this); + } + + + public void accept(Clazz clazz, Method method, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitFormalParameterTargetInfo(clazz, method, typeAnnotation, this); + } +} diff --git a/src/proguard/classfile/attribute/annotation/target/LocalVariableTargetElement.java b/src/proguard/classfile/attribute/annotation/target/LocalVariableTargetElement.java new file mode 100644 index 0000000..bcf41dc --- /dev/null +++ b/src/proguard/classfile/attribute/annotation/target/LocalVariableTargetElement.java @@ -0,0 +1,53 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation.target; + +/** + * Representation of an local variable target table entry. + * + * @author Eric Lafortune + */ +public class LocalVariableTargetElement +{ + public int u2startPC; + public int u2length; + public int u2index; + + /** + * Creates an uninitialized LocalVariableTargetElement. + */ + public LocalVariableTargetElement() + { + } + + + /** + * Creates an initialized LocalVariableTargetElement. + */ + public LocalVariableTargetElement(int u2startPC, + int u2length, + int u2index) + { + this.u2startPC = u2startPC; + this.u2length = u2length; + this.u2index = u2index; + } +} diff --git a/src/proguard/classfile/attribute/annotation/target/LocalVariableTargetInfo.java b/src/proguard/classfile/attribute/annotation/target/LocalVariableTargetInfo.java new file mode 100644 index 0000000..dd9246c --- /dev/null +++ b/src/proguard/classfile/attribute/annotation/target/LocalVariableTargetInfo.java @@ -0,0 +1,99 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation.target; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.annotation.TypeAnnotation; +import proguard.classfile.attribute.annotation.target.visitor.*; + +/** + * Representation of a local variable annotation target. + * + * @author Eric Lafortune + */ +public class LocalVariableTargetInfo extends TargetInfo +{ + public int u2tableLength; + public LocalVariableTargetElement[] table; + + + /** + * Creates an uninitialized LocalVariableTargetInfo. + */ + public LocalVariableTargetInfo() + { + } + + + /** + * Creates a partially initialized LocalVariableTargetInfo. + */ + public LocalVariableTargetInfo(byte u1targetType) + { + super(u1targetType); + } + + + /** + * Creates an initialized LocalVariableTargetInfo. + */ + protected LocalVariableTargetInfo(byte u1targetType, + int u2tableLength, + LocalVariableTargetElement[] table) + { + super(u1targetType); + + this.u2tableLength = u2tableLength; + this.table = table; + } + + + /** + * Applies the given visitor to all target elements. + */ + public void targetElementsAccept(Clazz clazz, Method method, CodeAttribute codeAttribute, TypeAnnotation typeAnnotation, LocalVariableTargetElementVisitor localVariableTargetElementVisitor) + { + for (int index = 0; index < u2tableLength; index++) + { + // We don't need double dispatching here, since there is only one + // type of TypePathInfo. + localVariableTargetElementVisitor.visitLocalVariableTargetElement(clazz, method, codeAttribute, typeAnnotation, this, table[index]); + } + } + + + // Implementations for TargetInfo. + + /** + * Lets the visitor visit, with Method and CodeAttribute null. + */ + public void accept(Clazz clazz, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitLocalVariableTargetInfo(clazz, null, null, typeAnnotation, this); + } + + + public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitLocalVariableTargetInfo(clazz, method, codeAttribute, typeAnnotation, this); + } +} diff --git a/src/proguard/classfile/attribute/annotation/target/OffsetTargetInfo.java b/src/proguard/classfile/attribute/annotation/target/OffsetTargetInfo.java new file mode 100644 index 0000000..312046b --- /dev/null +++ b/src/proguard/classfile/attribute/annotation/target/OffsetTargetInfo.java @@ -0,0 +1,82 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation.target; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.annotation.TypeAnnotation; +import proguard.classfile.attribute.annotation.target.visitor.TargetInfoVisitor; + +/** + * Representation of an offset annotation target. + * + * @author Eric Lafortune + */ +public class OffsetTargetInfo extends TargetInfo +{ + public int u2offset; + + + /** + * Creates an uninitialized OffsetTargetInfo. + */ + public OffsetTargetInfo() + { + } + + + /** + * Creates a partially initialized OffsetTargetInfo. + */ + public OffsetTargetInfo(byte u1targetType) + { + super(u1targetType); + } + + + /** + * Creates an initialized OffsetTargetInfo. + */ + protected OffsetTargetInfo(byte u1targetType, + int u2offset) + { + super(u1targetType); + + this.u2offset = u2offset; + } + + + // Implementations for TargetInfo. + + /** + * Lets the visitor visit, with Method and CodeAttribute null. + */ + public void accept(Clazz clazz, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitOffsetTargetInfo(clazz, null, null, typeAnnotation, this); + } + + + public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitOffsetTargetInfo(clazz, method, codeAttribute, typeAnnotation, this); + } +} diff --git a/src/proguard/classfile/attribute/annotation/target/SuperTypeTargetInfo.java b/src/proguard/classfile/attribute/annotation/target/SuperTypeTargetInfo.java new file mode 100644 index 0000000..0db7ea4 --- /dev/null +++ b/src/proguard/classfile/attribute/annotation/target/SuperTypeTargetInfo.java @@ -0,0 +1,72 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation.target; + +import proguard.classfile.Clazz; +import proguard.classfile.attribute.annotation.TypeAnnotation; +import proguard.classfile.attribute.annotation.target.visitor.TargetInfoVisitor; + +/** + * Representation of a super type annotation target. + * + * @author Eric Lafortune + */ +public class SuperTypeTargetInfo extends TargetInfo +{ + public int u2superTypeIndex; + + + /** + * Creates an uninitialized SuperTypeTargetInfo. + */ + public SuperTypeTargetInfo() + { + } + + + /** + * Creates a partially initialized SuperTypeTargetInfo. + */ + public SuperTypeTargetInfo(byte u1targetType) + { + super(u1targetType); + } + + + /** + * Creates an initialized SuperTypeTargetInfo. + */ + public SuperTypeTargetInfo(byte u1targetType, + int u2superTypeIndex) + { + super(u1targetType); + + this.u2superTypeIndex = u2superTypeIndex; + } + + + // Implementations for TargetInfo. + + public void accept(Clazz clazz, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitSuperTypeTargetInfo(clazz, typeAnnotation, this); + } +} diff --git a/src/proguard/classfile/attribute/annotation/target/TargetInfo.java b/src/proguard/classfile/attribute/annotation/target/TargetInfo.java new file mode 100644 index 0000000..efee2e2 --- /dev/null +++ b/src/proguard/classfile/attribute/annotation/target/TargetInfo.java @@ -0,0 +1,97 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation.target; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.annotation.TypeAnnotation; +import proguard.classfile.attribute.annotation.target.visitor.TargetInfoVisitor; + +/** + * Representation of an annotation target. + * + * @author Eric Lafortune + */ +public abstract class TargetInfo +{ + public byte u1targetType; + + + /** + * Creates an uninitialized TargetInfo. + */ + protected TargetInfo() + { + } + + + /** + * Creates an initialized TargetInfo. + */ + protected TargetInfo(byte u1targetType) + { + this.u1targetType = u1targetType; + } + + + /** + * Returns the type of the target. + */ + public byte getTargetType() + { + return u1targetType; + } + + + // Methods to be implemented by extensions. + + /** + * Accepts the given visitor, in the context of a type annotation on a class. + */ + public void accept(Clazz clazz, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + throw new UnsupportedOperationException("Unsupported type annotation [0x"+Integer.toHexString(u1targetType)+"] on a class"); + } + + /** + * Accepts the given visitor, in the context of a type annotation on a field. + */ + public void accept(Clazz clazz, Field field, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + throw new UnsupportedOperationException("Unsupported type annotation [0x"+Integer.toHexString(u1targetType)+"] on a field"); + } + + /** + * Accepts the given visitor, in the context of a type annotation on a method. + */ + public void accept(Clazz clazz, Method method, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + throw new UnsupportedOperationException("Unsupported type annotation [0x"+Integer.toHexString(u1targetType)+"] on a method"); + } + + /** + * Accepts the given visitor, in the context of a type annotation code. + */ + public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + throw new UnsupportedOperationException("Unsupported type annotation [0x"+Integer.toHexString(u1targetType)+"] on code"); + } +} diff --git a/src/proguard/classfile/attribute/annotation/target/ThrowsTargetInfo.java b/src/proguard/classfile/attribute/annotation/target/ThrowsTargetInfo.java new file mode 100644 index 0000000..d5b2db7 --- /dev/null +++ b/src/proguard/classfile/attribute/annotation/target/ThrowsTargetInfo.java @@ -0,0 +1,81 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation.target; + +import proguard.classfile.*; +import proguard.classfile.attribute.annotation.TypeAnnotation; +import proguard.classfile.attribute.annotation.target.visitor.TargetInfoVisitor; + +/** + * Representation of a 'throws' annotation target. + * + * @author Eric Lafortune + */ +public class ThrowsTargetInfo extends TargetInfo +{ + public int u2throwsTypeIndex; + + + /** + * Creates an uninitialized ThrowsTargetInfo. + */ + public ThrowsTargetInfo() + { + } + + + /** + * Creates a partially initialized ThrowsTargetInfo. + */ + public ThrowsTargetInfo(byte u1targetType) + { + super(u1targetType); + } + + + /** + * Creates an initialized ThrowsTargetInfo. + */ + public ThrowsTargetInfo(byte u1targetType, + int u2throwsTypeIndex) + { + super(u1targetType); + + this.u2throwsTypeIndex = u2throwsTypeIndex; + } + + + // Implementations for TargetInfo. + + /** + * Lets the visitor visit, with Method null. + */ + public void accept(Clazz clazz, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitThrowsTargetInfo(clazz, null, typeAnnotation, this); + } + + + public void accept(Clazz clazz, Method method, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitThrowsTargetInfo(clazz, method, typeAnnotation, this); + } +} diff --git a/src/proguard/classfile/attribute/annotation/target/TypeArgumentTargetInfo.java b/src/proguard/classfile/attribute/annotation/target/TypeArgumentTargetInfo.java new file mode 100644 index 0000000..4aef72e --- /dev/null +++ b/src/proguard/classfile/attribute/annotation/target/TypeArgumentTargetInfo.java @@ -0,0 +1,85 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation.target; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.annotation.TypeAnnotation; +import proguard.classfile.attribute.annotation.target.visitor.TargetInfoVisitor; + +/** + * Representation of an offset annotation target. + * + * @author Eric Lafortune + */ +public class TypeArgumentTargetInfo extends TargetInfo +{ + public int u2offset; + public int u1typeArgumentIndex; + + + /** + * Creates an uninitialized TypeArgumentTargetInfo. + */ + public TypeArgumentTargetInfo() + { + } + + + /** + * Creates a partially initialized TypeArgumentTargetInfo. + */ + public TypeArgumentTargetInfo(byte u1targetType) + { + super(u1targetType); + } + + + /** + * Creates an initialized TypeArgumentTargetInfo. + */ + protected TypeArgumentTargetInfo(byte u1targetType, + int u2offset, + int u1typeArgumentIndex) + { + super(u1targetType); + + this.u2offset = u2offset; + this.u1typeArgumentIndex = u1typeArgumentIndex; + } + + + // Implementations for TargetInfo. + + /** + * Lets the visitor visit, with Method and CodeAttribute null. + */ + public void accept(Clazz clazz, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitTypeArgumentTargetInfo(clazz, null, null, typeAnnotation, this); + } + + + public void accept(Clazz clazz, Method method, CodeAttribute codeAttribute, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitTypeArgumentTargetInfo(clazz, method, codeAttribute, typeAnnotation, this); + } +} diff --git a/src/proguard/classfile/attribute/annotation/target/TypeParameterBoundTargetInfo.java b/src/proguard/classfile/attribute/annotation/target/TypeParameterBoundTargetInfo.java new file mode 100644 index 0000000..0f485ee --- /dev/null +++ b/src/proguard/classfile/attribute/annotation/target/TypeParameterBoundTargetInfo.java @@ -0,0 +1,87 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation.target; + +import proguard.classfile.*; +import proguard.classfile.attribute.annotation.TypeAnnotation; +import proguard.classfile.attribute.annotation.target.visitor.TargetInfoVisitor; + +/** + * Representation of a type parameter bound annotation target. + * + * @author Eric Lafortune + */ +public class TypeParameterBoundTargetInfo extends TargetInfo +{ + public int u1typeParameterIndex; + public int u1boundIndex; + + + /** + * Creates an uninitialized TypeParameterBoundTargetInfo. + */ + public TypeParameterBoundTargetInfo() + { + } + + + /** + * Creates a partially initialized TypeParameterBoundTargetInfo. + */ + public TypeParameterBoundTargetInfo(byte u1targetType) + { + super(u1targetType); + } + + + /** + * Creates an initialized TypeParameterBoundTargetInfo. + */ + public TypeParameterBoundTargetInfo(byte u1targetType, + int u1typeParameterIndex, + int u1boundIndex) + { + super(u1targetType); + + this.u1typeParameterIndex = u1typeParameterIndex; + this.u1boundIndex = u1boundIndex; + } + + + // Implementations for TargetInfo. + + public void accept(Clazz clazz, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitTypeParameterBoundTargetInfo(clazz, typeAnnotation, this); + } + + + public void accept(Clazz clazz, Field field, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitTypeParameterBoundTargetInfo(clazz, field, typeAnnotation, this); + } + + + public void accept(Clazz clazz, Method method, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitTypeParameterBoundTargetInfo(clazz, method, typeAnnotation, this); + } +} diff --git a/src/proguard/classfile/attribute/annotation/target/TypeParameterTargetInfo.java b/src/proguard/classfile/attribute/annotation/target/TypeParameterTargetInfo.java new file mode 100644 index 0000000..3150a26 --- /dev/null +++ b/src/proguard/classfile/attribute/annotation/target/TypeParameterTargetInfo.java @@ -0,0 +1,79 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation.target; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.annotation.TypeAnnotation; +import proguard.classfile.attribute.annotation.target.visitor.TargetInfoVisitor; + +/** + * Representation of a type parameter annotation target. + * + * @author Eric Lafortune + */ +public class TypeParameterTargetInfo extends TargetInfo +{ + public int u1typeParameterIndex; + + + /** + * Creates an uninitialized TypeParameterTargetInfo. + */ + public TypeParameterTargetInfo() + { + } + + + /** + * Creates a partially initialized TypeParameterTargetInfo. + */ + public TypeParameterTargetInfo(byte u1targetType) + { + super(u1targetType); + } + + + /** + * Creates an initialized TypeParameterTargetInfo. + */ + public TypeParameterTargetInfo(byte u1targetType, + int u1typeParameterIndex) + { + super(u1targetType); + + this.u1typeParameterIndex = u1typeParameterIndex; + } + + + // Implementations for TargetInfo. + + public void accept(Clazz clazz, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitTypeParameterTargetInfo(clazz, typeAnnotation, this); + } + + + public void accept(Clazz clazz, Method method, TypeAnnotation typeAnnotation, TargetInfoVisitor targetInfoVisitor) + { + targetInfoVisitor.visitTypeParameterTargetInfo(clazz, method, typeAnnotation, this); + } +} diff --git a/src/proguard/classfile/attribute/annotation/target/visitor/LocalVariableTargetElementVisitor.java b/src/proguard/classfile/attribute/annotation/target/visitor/LocalVariableTargetElementVisitor.java new file mode 100644 index 0000000..62fe148 --- /dev/null +++ b/src/proguard/classfile/attribute/annotation/target/visitor/LocalVariableTargetElementVisitor.java @@ -0,0 +1,37 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation.target.visitor; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.annotation.TypeAnnotation; +import proguard.classfile.attribute.annotation.target.*; + +/** + * This interface specifies the methods for a visitor of LocalVariableTargetElement + * instances. + * + * @author Eric Lafortune + */ +public interface LocalVariableTargetElementVisitor +{ + public void visitLocalVariableTargetElement(Clazz clazz, Method method, CodeAttribute codeAttribute, TypeAnnotation typeAnnotation, LocalVariableTargetInfo localVariableTargetInfo, LocalVariableTargetElement localVariableTargetElement); +} diff --git a/src/proguard/classfile/attribute/annotation/target/visitor/TargetInfoVisitor.java b/src/proguard/classfile/attribute/annotation/target/visitor/TargetInfoVisitor.java new file mode 100644 index 0000000..33e7d32 --- /dev/null +++ b/src/proguard/classfile/attribute/annotation/target/visitor/TargetInfoVisitor.java @@ -0,0 +1,50 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation.target.visitor; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.annotation.*; +import proguard.classfile.attribute.annotation.target.*; + +/** + * This interface specifies the methods for a visitor of <code>TargetInfo</code> + * objects. + * + * @author Eric Lafortune + */ +public interface TargetInfoVisitor +{ + public void visitTypeParameterTargetInfo( Clazz clazz, TypeAnnotation typeAnnotation, TypeParameterTargetInfo typeParameterTargetInfo); + public void visitTypeParameterTargetInfo( Clazz clazz, Method method, TypeAnnotation typeAnnotation, TypeParameterTargetInfo typeParameterTargetInfo); + public void visitSuperTypeTargetInfo( Clazz clazz, TypeAnnotation typeAnnotation, SuperTypeTargetInfo superTypeTargetInfo); + public void visitTypeParameterBoundTargetInfo(Clazz clazz, TypeAnnotation typeAnnotation, TypeParameterBoundTargetInfo typeParameterBoundTargetInfo); + public void visitTypeParameterBoundTargetInfo(Clazz clazz, Field field, TypeAnnotation typeAnnotation, TypeParameterBoundTargetInfo typeParameterBoundTargetInfo); + public void visitTypeParameterBoundTargetInfo(Clazz clazz, Method method, TypeAnnotation typeAnnotation, TypeParameterBoundTargetInfo typeParameterBoundTargetInfo); + public void visitEmptyTargetInfo( Clazz clazz, Field field, TypeAnnotation typeAnnotation, EmptyTargetInfo emptyTargetInfo); + public void visitEmptyTargetInfo( Clazz clazz, Method method, TypeAnnotation typeAnnotation, EmptyTargetInfo emptyTargetInfo); + public void visitFormalParameterTargetInfo( Clazz clazz, Method method, TypeAnnotation typeAnnotation, FormalParameterTargetInfo formalParameterTargetInfo); + public void visitThrowsTargetInfo( Clazz clazz, Method method, TypeAnnotation typeAnnotation, ThrowsTargetInfo throwsTargetInfo); + public void visitLocalVariableTargetInfo( Clazz clazz, Method method, CodeAttribute codeAttribute, TypeAnnotation typeAnnotation, LocalVariableTargetInfo localVariableTargetInfo); + public void visitCatchTargetInfo( Clazz clazz, Method method, CodeAttribute codeAttribute, TypeAnnotation typeAnnotation, CatchTargetInfo catchTargetInfo); + public void visitOffsetTargetInfo( Clazz clazz, Method method, CodeAttribute codeAttribute, TypeAnnotation typeAnnotation, OffsetTargetInfo offsetTargetInfo); + public void visitTypeArgumentTargetInfo( Clazz clazz, Method method, CodeAttribute codeAttribute, TypeAnnotation typeAnnotation, TypeArgumentTargetInfo typeArgumentTargetInfo); +} diff --git a/src/proguard/classfile/attribute/annotation/visitor/AllAnnotationVisitor.java b/src/proguard/classfile/attribute/annotation/visitor/AllAnnotationVisitor.java index 0aadfe3..b4513d7 100644 --- a/src/proguard/classfile/attribute/annotation/visitor/AllAnnotationVisitor.java +++ b/src/proguard/classfile/attribute/annotation/visitor/AllAnnotationVisitor.java @@ -2,7 +2,7 @@ * ProGuard -- shrinking, optimization, obfuscation, and preverification * of Java bytecode. * - * Copyright (c) 2002-2013 Eric Lafortune (eric@graphics.cornell.edu) + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -21,7 +21,7 @@ package proguard.classfile.attribute.annotation.visitor; import proguard.classfile.*; -import proguard.classfile.attribute.Attribute; +import proguard.classfile.attribute.*; import proguard.classfile.attribute.annotation.*; import proguard.classfile.attribute.visitor.AttributeVisitor; import proguard.classfile.util.SimplifiedVisitor; @@ -102,4 +102,60 @@ implements AttributeVisitor // Visit the annotations. parameterAnnotationsAttribute.annotationsAccept(clazz, method, annotationVisitor); } + + + public void visitRuntimeVisibleTypeAnnotationsAttribute(Clazz clazz, RuntimeVisibleTypeAnnotationsAttribute runtimeVisibleTypeAnnotationsAttribute) + { + // Visit the annotations. + runtimeVisibleTypeAnnotationsAttribute.annotationsAccept(clazz, annotationVisitor); + } + + + public void visitRuntimeVisibleTypeAnnotationsAttribute(Clazz clazz, Field field, RuntimeVisibleTypeAnnotationsAttribute runtimeVisibleTypeAnnotationsAttribute) + { + // Visit the annotations. + runtimeVisibleTypeAnnotationsAttribute.annotationsAccept(clazz, field, annotationVisitor); + } + + + public void visitRuntimeVisibleTypeAnnotationsAttribute(Clazz clazz, Method method, RuntimeVisibleTypeAnnotationsAttribute runtimeVisibleTypeAnnotationsAttribute) + { + // Visit the annotations. + runtimeVisibleTypeAnnotationsAttribute.annotationsAccept(clazz, method, annotationVisitor); + } + + + public void visitRuntimeVisibleTypeAnnotationsAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, RuntimeVisibleTypeAnnotationsAttribute runtimeVisibleTypeAnnotationsAttribute) + { + // Visit the annotations. + runtimeVisibleTypeAnnotationsAttribute.annotationsAccept(clazz, method, codeAttribute, annotationVisitor); + } + + + public void visitRuntimeInvisibleTypeAnnotationsAttribute(Clazz clazz, RuntimeInvisibleTypeAnnotationsAttribute runtimeInvisibleTypeAnnotationsAttribute) + { + // Visit the annotations. + runtimeInvisibleTypeAnnotationsAttribute.annotationsAccept(clazz, annotationVisitor); + } + + + public void visitRuntimeInvisibleTypeAnnotationsAttribute(Clazz clazz, Field field, RuntimeInvisibleTypeAnnotationsAttribute runtimeInvisibleTypeAnnotationsAttribute) + { + // Visit the annotations. + runtimeInvisibleTypeAnnotationsAttribute.annotationsAccept(clazz, field, annotationVisitor); + } + + + public void visitRuntimeInvisibleTypeAnnotationsAttribute(Clazz clazz, Method method, RuntimeInvisibleTypeAnnotationsAttribute runtimeInvisibleTypeAnnotationsAttribute) + { + // Visit the annotations. + runtimeInvisibleTypeAnnotationsAttribute.annotationsAccept(clazz, method, annotationVisitor); + } + + + public void visitRuntimeInvisibleTypeAnnotationsAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, RuntimeInvisibleTypeAnnotationsAttribute runtimeInvisibleTypeAnnotationsAttribute) + { + // Visit the annotations. + runtimeInvisibleTypeAnnotationsAttribute.annotationsAccept(clazz, method, codeAttribute, annotationVisitor); + } } diff --git a/src/proguard/classfile/attribute/annotation/visitor/AllElementValueVisitor.java b/src/proguard/classfile/attribute/annotation/visitor/AllElementValueVisitor.java index b728b8b..4413082 100644 --- a/src/proguard/classfile/attribute/annotation/visitor/AllElementValueVisitor.java +++ b/src/proguard/classfile/attribute/annotation/visitor/AllElementValueVisitor.java @@ -2,7 +2,7 @@ * ProGuard -- shrinking, optimization, obfuscation, and preverification * of Java bytecode. * - * Copyright (c) 2002-2013 Eric Lafortune (eric@graphics.cornell.edu) + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -21,11 +21,10 @@ package proguard.classfile.attribute.annotation.visitor; import proguard.classfile.*; -import proguard.classfile.attribute.Attribute; +import proguard.classfile.attribute.*; import proguard.classfile.attribute.annotation.*; import proguard.classfile.attribute.visitor.AttributeVisitor; import proguard.classfile.util.SimplifiedVisitor; -import proguard.util.*; /** * This AttributeVisitor and AnnotationVisitor lets a given ElementValueVisitor @@ -158,6 +157,12 @@ implements AttributeVisitor, } + public void visitAnnotation(Clazz clazz, Method method, CodeAttribute codeAttribute, Annotation annotation) + { + annotation.elementValuesAccept(clazz, this); + } + + // Implementations for ElementValueVisitor. public void visitConstantElementValue(Clazz clazz, Annotation annotation, ConstantElementValue constantElementValue) diff --git a/src/proguard/classfile/attribute/annotation/visitor/AnnotatedClassVisitor.java b/src/proguard/classfile/attribute/annotation/visitor/AnnotatedClassVisitor.java index 305928e..241e9e6 100644 --- a/src/proguard/classfile/attribute/annotation/visitor/AnnotatedClassVisitor.java +++ b/src/proguard/classfile/attribute/annotation/visitor/AnnotatedClassVisitor.java @@ -2,7 +2,7 @@ * ProGuard -- shrinking, optimization, obfuscation, and preverification * of Java bytecode. * - * Copyright (c) 2002-2013 Eric Lafortune (eric@graphics.cornell.edu) + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free diff --git a/src/proguard/classfile/attribute/annotation/visitor/AnnotationToMemberVisitor.java b/src/proguard/classfile/attribute/annotation/visitor/AnnotationToMemberVisitor.java index 7833f7e..6bb2454 100644 --- a/src/proguard/classfile/attribute/annotation/visitor/AnnotationToMemberVisitor.java +++ b/src/proguard/classfile/attribute/annotation/visitor/AnnotationToMemberVisitor.java @@ -2,7 +2,7 @@ * ProGuard -- shrinking, optimization, obfuscation, and preverification * of Java bytecode. * - * Copyright (c) 2002-2013 Eric Lafortune (eric@graphics.cornell.edu) + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free diff --git a/src/proguard/classfile/attribute/annotation/visitor/AnnotationTypeFilter.java b/src/proguard/classfile/attribute/annotation/visitor/AnnotationTypeFilter.java index d6ec3ca..ad7b316 100644 --- a/src/proguard/classfile/attribute/annotation/visitor/AnnotationTypeFilter.java +++ b/src/proguard/classfile/attribute/annotation/visitor/AnnotationTypeFilter.java @@ -2,7 +2,7 @@ * ProGuard -- shrinking, optimization, obfuscation, and preverification * of Java bytecode. * - * Copyright (c) 2002-2013 Eric Lafortune (eric@graphics.cornell.edu) + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -21,8 +21,8 @@ package proguard.classfile.attribute.annotation.visitor; import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; import proguard.classfile.attribute.annotation.Annotation; -import proguard.classfile.util.SimplifiedVisitor; import proguard.util.*; /** @@ -92,6 +92,15 @@ implements AnnotationVisitor } + public void visitAnnotation(Clazz clazz, Method method, CodeAttribute codeAttribute, Annotation annotation) + { + if (accepted(annotation.getType(clazz))) + { + annotationVisitor.visitAnnotation(clazz, method, codeAttribute, annotation); + } + } + + // Small utility methods. private boolean accepted(String name) diff --git a/src/proguard/classfile/attribute/annotation/visitor/AnnotationVisitor.java b/src/proguard/classfile/attribute/annotation/visitor/AnnotationVisitor.java index 8d207af..3225c97 100644 --- a/src/proguard/classfile/attribute/annotation/visitor/AnnotationVisitor.java +++ b/src/proguard/classfile/attribute/annotation/visitor/AnnotationVisitor.java @@ -2,7 +2,7 @@ * ProGuard -- shrinking, optimization, obfuscation, and preverification * of Java bytecode. * - * Copyright (c) 2002-2013 Eric Lafortune (eric@graphics.cornell.edu) + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -21,6 +21,7 @@ package proguard.classfile.attribute.annotation.visitor; import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; import proguard.classfile.attribute.annotation.Annotation; /** @@ -33,8 +34,9 @@ import proguard.classfile.attribute.annotation.Annotation; */ public interface AnnotationVisitor { - public void visitAnnotation(Clazz clazz, Annotation annotation); - public void visitAnnotation(Clazz clazz, Field field, Annotation annotation); - public void visitAnnotation(Clazz clazz, Method method, Annotation annotation); - public void visitAnnotation(Clazz clazz, Method method, int parameterIndex, Annotation annotation); + public void visitAnnotation(Clazz clazz, Annotation annotation); + public void visitAnnotation(Clazz clazz, Field field, Annotation annotation); + public void visitAnnotation(Clazz clazz, Method method, Annotation annotation); + public void visitAnnotation(Clazz clazz, Method method, int parameterIndex, Annotation annotation); + public void visitAnnotation(Clazz clazz, Method method, CodeAttribute codeAttribute, Annotation annotation); } diff --git a/src/proguard/classfile/attribute/annotation/visitor/ElementValueVisitor.java b/src/proguard/classfile/attribute/annotation/visitor/ElementValueVisitor.java index 2d3a20d..453c14b 100644 --- a/src/proguard/classfile/attribute/annotation/visitor/ElementValueVisitor.java +++ b/src/proguard/classfile/attribute/annotation/visitor/ElementValueVisitor.java @@ -2,7 +2,7 @@ * ProGuard -- shrinking, optimization, obfuscation, and preverification * of Java bytecode. * - * Copyright (c) 2002-2013 Eric Lafortune (eric@graphics.cornell.edu) + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free diff --git a/src/proguard/classfile/attribute/annotation/visitor/TypeAnnotationVisitor.java b/src/proguard/classfile/attribute/annotation/visitor/TypeAnnotationVisitor.java new file mode 100644 index 0000000..3a01887 --- /dev/null +++ b/src/proguard/classfile/attribute/annotation/visitor/TypeAnnotationVisitor.java @@ -0,0 +1,41 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation.visitor; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.annotation.*; + +/** + * This interface specifies the methods for a visitor of + * TypeAnnotation instances. Note that there is only a single + * implementation of TypeAnnotation, such that this interface + * is not strictly necessary as a visitor. + * + * @author Eric Lafortune + */ +public interface TypeAnnotationVisitor +{ + public void visitTypeAnnotation(Clazz clazz, TypeAnnotation typeAnnotation); + public void visitTypeAnnotation(Clazz clazz, Field field, TypeAnnotation typeAnnotation); + public void visitTypeAnnotation(Clazz clazz, Method method, TypeAnnotation typeAnnotation); + public void visitTypeAnnotation(Clazz clazz, Method method, CodeAttribute codeAttribute, TypeAnnotation typeAnnotation); +} diff --git a/src/proguard/classfile/attribute/annotation/visitor/TypePathInfoVisitor.java b/src/proguard/classfile/attribute/annotation/visitor/TypePathInfoVisitor.java new file mode 100644 index 0000000..ab7d51b --- /dev/null +++ b/src/proguard/classfile/attribute/annotation/visitor/TypePathInfoVisitor.java @@ -0,0 +1,41 @@ +/* + * ProGuard -- shrinking, optimization, obfuscation, and preverification + * of Java bytecode. + * + * Copyright (c) 2002-2014 Eric Lafortune (eric@graphics.cornell.edu) + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +package proguard.classfile.attribute.annotation.visitor; + +import proguard.classfile.*; +import proguard.classfile.attribute.CodeAttribute; +import proguard.classfile.attribute.annotation.*; + +/** + * This interface specifies the methods for a visitor of + * TypePathInfo instances. Note that there is only a single + * implementation of TypePathInfo, such that this interface + * is not strictly necessary as a visitor. + * + * @author Eric Lafortune + */ +public interface TypePathInfoVisitor +{ + public void visitTypePathInfo(Clazz clazz, TypeAnnotation typeAnnotation, TypePathInfo typePathInfo); + public void visitTypePathInfo(Clazz clazz, Field field, TypeAnnotation typeAnnotation, TypePathInfo typePathInfo); + public void visitTypePathInfo(Clazz clazz, Method method, TypeAnnotation typeAnnotation, TypePathInfo typePathInfo); + public void visitTypePathInfo(Clazz clazz, Method method, CodeAttribute codeAttribute, TypeAnnotation typeAnnotation, TypePathInfo typePathInfo); +} |