From 396c3fcb58fccfd4debfb87445582423a4a87536 Mon Sep 17 00:00:00 2001 From: aclement Date: Tue, 15 Sep 2009 03:33:52 +0000 Subject: [PATCH] refactoring --- .../aspectj/apache/bcel/classfile/Field.java | 7 +--- .../apache/bcel/classfile/FieldOrMethod.java | 20 ++--------- .../apache/bcel/classfile/JavaClass.java | 36 +------------------ .../aspectj/apache/bcel/classfile/Method.java | 17 +++------ 4 files changed, 9 insertions(+), 71 deletions(-) diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Field.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Field.java index 3453347a7..f34464375 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Field.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Field.java @@ -62,7 +62,7 @@ import org.aspectj.apache.bcel.generic.Type; * This class represents the field info structure, i.e., the representation for a variable in the class. See JVM specification for * details. * - * @version $Id: Field.java,v 1.5 2009/09/10 15:35:05 aclement Exp $ + * @version $Id: Field.java,v 1.6 2009/09/15 03:33:52 aclement Exp $ * @author M. Dahm */ public final class Field extends FieldOrMethod { @@ -126,11 +126,6 @@ public final class Field extends FieldOrMethod { return buf.toString(); } - /** deep copy of this field */ - public final Field copy(ConstantPool constant_pool) { - return (Field) copy_(constant_pool); - } - /** return the type of the field */ public Type getType() { if (fieldType == null) { diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/FieldOrMethod.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/FieldOrMethod.java index ad15e4275..1babd200a 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/FieldOrMethod.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/FieldOrMethod.java @@ -66,10 +66,10 @@ import org.aspectj.apache.bcel.classfile.annotation.RuntimeAnnotations; /** * Abstract super class for fields and methods. * - * @version $Id: FieldOrMethod.java,v 1.10 2009/09/10 15:35:05 aclement Exp $ + * @version $Id: FieldOrMethod.java,v 1.11 2009/09/15 03:33:52 aclement Exp $ * @author M. Dahm */ -public abstract class FieldOrMethod extends Modifiers implements Cloneable, Node { +public abstract class FieldOrMethod extends Modifiers implements Node { protected int nameIndex; protected int signatureIndex; protected Attribute[] attributes; @@ -161,22 +161,6 @@ public abstract class FieldOrMethod extends Modifiers implements Cloneable, Node return getSignature(); } - /** - * @return deep copy of this field - */ - protected FieldOrMethod copy_(ConstantPool constant_pool) { - FieldOrMethod c = null; - - try { - c = (FieldOrMethod) clone(); - } catch (CloneNotSupportedException e) { - } - - c.cpool = constant_pool; - c.attributes = AttributeUtils.copy(attributes, constant_pool); - return c; - } - public AnnotationGen[] getAnnotations() { // Ensure we have unpacked any attributes that contain annotations. // We don't remove these annotation attributes from the attributes list, they diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/JavaClass.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/JavaClass.java index f3f6b70b3..4971d8534 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/JavaClass.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/JavaClass.java @@ -80,7 +80,7 @@ import org.aspectj.apache.bcel.util.SyntheticRepository; * The intent of this class is to represent a parsed or otherwise existing class file. Those interested in programatically * generating classes should see the ClassGen class. * - * @version $Id: JavaClass.java,v 1.19 2009/09/14 20:29:10 aclement Exp $ + * @version $Id: JavaClass.java,v 1.20 2009/09/15 03:33:52 aclement Exp $ * @see org.aspectj.apache.bcel.generic.ClassGen * @author M. Dahm */ @@ -601,40 +601,6 @@ public class JavaClass extends Modifiers implements Cloneable, Node { return buf.toString(); } - /** - * @return deep copy of this class - */ - public JavaClass copy() { - JavaClass c = null; - - try { - c = (JavaClass) clone(); - } catch (CloneNotSupportedException e) { - } - - c.cpool = cpool.copy(); - c.interfaces = interfaces.clone(); - c.interfacenames = interfacenames.clone(); - - c.fields = new Field[fields.length]; - for (int i = 0; i < fields.length; i++) { - c.fields[i] = fields[i].copy(c.cpool); - } - - c.methods = new Method[methods.length]; - for (int i = 0; i < methods.length; i++) { - c.methods[i] = methods[i].copy(c.cpool); - } - - c.attributes = AttributeUtils.copy(attributes, c.cpool); - - // J5SUPPORT: As the annotations exist as attributes against the class, copying - // the attributes will copy the annotations across, so we don't have to - // also copy them individually. - - return c; - } - public final boolean isSuper() { return (modifiers & Constants.ACC_SUPER) != 0; } diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Method.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Method.java index e3d1f78ac..cec26bd34 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/Method.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/Method.java @@ -68,13 +68,12 @@ import org.aspectj.apache.bcel.generic.Type; * This class represents the method info structure, i.e., the representation for a method in the class. See JVM specification for * details. A method has access flags, a name, a signature and a number of attributes. * - * @version $Id: Method.java,v 1.9 2009/09/10 15:35:05 aclement Exp $ + * @version $Id: Method.java,v 1.10 2009/09/15 03:33:52 aclement Exp $ * @author M. Dahm */ public final class Method extends FieldOrMethod { public static final AnnotationGen[][] NO_PARAMETER_ANNOTATIONS = new AnnotationGen[][] {}; - public static final AnnotationGen[] NO_ANNOTATIONS = new AnnotationGen[] {}; public static final Method[] NoMethods = new Method[0]; @@ -182,13 +181,6 @@ public final class Method extends FieldOrMethod { return buf.toString(); } - /** - * Return a deep copy of this method - */ - public final Method copy(ConstantPool constant_pool) { - return (Method) copy_(constant_pool); - } - /** * @return return type of method */ @@ -248,7 +240,7 @@ public final class Method extends FieldOrMethod { count += invisibleOnes.length; } - AnnotationGen[] complete = NO_ANNOTATIONS; + AnnotationGen[] complete = AnnotationGen.NO_ANNOTATIONS; if (count != 0) { complete = new AnnotationGen[visibleOnes.length + invisibleOnes.length]; System.arraycopy(visibleOnes, 0, complete, 0, visibleOnes.length); @@ -267,8 +259,9 @@ public final class Method extends FieldOrMethod { public AnnotationGen[] getAnnotationsOnParameter(int i) { ensureParameterAnnotationsUnpacked(); - if (unpackedParameterAnnotations == NO_PARAMETER_ANNOTATIONS) - return NO_ANNOTATIONS; + if (unpackedParameterAnnotations == NO_PARAMETER_ANNOTATIONS) { + return AnnotationGen.NO_ANNOTATIONS; + } return unpackedParameterAnnotations[i]; } -- 2.39.5