diff options
Diffstat (limited to 'src/proguard/classfile/attribute/annotation/target')
14 files changed, 1057 insertions, 0 deletions
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); +} |