~ubuntu-branches/ubuntu/trusty/aspectj/trusty

« back to all changes in this revision

Viewing changes to org.aspectj/modules/weaver/src/org/aspectj/weaver/bcel/BcelMethod.java

  • Committer: Bazaar Package Importer
  • Author(s): Damien Raude-Morvan
  • Date: 2011-03-15 23:54:31 UTC
  • mfrom: (1.1.5 upstream) (7.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20110315235431-7d8cs3gvs4tnqx7t
Tags: 1.6.11+dfsg-1
* New upstream release.
* Updated Standards-Version to 3.9.1 (no changes needed).
* Fix local Javadoc links:
  - d/patches/07_javadoc_links.diff: Use locally installed
   javadoc packages and hyperlink with them.
  - d/control: Add B-D on default-java-doc and libasm3-java-doc.
* d/control: Drop B-D on itself (our new bootstrap infrastructure doesn't need
  that anymore).
* Split packages into :
  - aspectj: only contains CLI tools.
  - libaspectj-java: JAR librairies for /usr/share/java.
  - libaspectj-java-doc: 4 API's Javadoc.
  - aspectj-doc: Programming Guides and SDK Documentation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
import org.aspectj.bridge.ISourceLocation;
32
32
import org.aspectj.bridge.SourceLocation;
33
33
import org.aspectj.util.GenericSignature;
 
34
import org.aspectj.util.GenericSignature.TypeVariableSignature;
34
35
import org.aspectj.util.GenericSignatureParser;
35
 
import org.aspectj.util.GenericSignature.TypeVariableSignature;
36
36
import org.aspectj.weaver.AjAttribute;
 
37
import org.aspectj.weaver.AjAttribute.WeaverVersionInfo;
37
38
import org.aspectj.weaver.AnnotationAJ;
38
39
import org.aspectj.weaver.BCException;
39
40
import org.aspectj.weaver.ISourceContext;
91
92
                unpackAjAttributes(bcelObjectType.getWorld());
92
93
        }
93
94
 
 
95
        /**
 
96
         * This constructor expects to be passed the attributes, rather than deserializing them.
 
97
         */
 
98
        BcelMethod(BcelObjectType declaringType, Method method, List<AjAttribute> attributes) {
 
99
                super(method.getName().equals("<init>") ? CONSTRUCTOR : (method.getName().equals("<clinit>") ? STATIC_INITIALIZATION
 
100
                                : METHOD), declaringType.getResolvedTypeX(), declaringType.isInterface() ? method.getModifiers()
 
101
                                | Modifier.INTERFACE : method.getModifiers(), method.getName(), method.getSignature());
 
102
                this.method = method;
 
103
                sourceContext = declaringType.getResolvedTypeX().getSourceContext();
 
104
                bcelObjectType = declaringType;
 
105
                unpackJavaAttributes();
 
106
                processAttributes(bcelObjectType.getWorld(), attributes);
 
107
        }
 
108
 
94
109
        // ----
95
110
 
96
111
        private void unpackJavaAttributes() {
97
112
                ExceptionTable exnTable = method.getExceptionTable();
98
113
                checkedExceptions = (exnTable == null) ? UnresolvedType.NONE : UnresolvedType.forNames(exnTable.getExceptionNames());
99
 
 
100
114
        }
101
115
 
102
116
        @Override
126
140
                int len = getArity();
127
141
                if (varTable == null) {
128
142
                        // do we have an annotation with the argNames value specified...
129
 
                        if (hasAnnotations()) {
 
143
                        AnnotationAJ[] annos = getAnnotations();
 
144
                        if (annos != null && annos.length != 0) {
130
145
                                AnnotationAJ[] axs = getAnnotations();
131
146
                                for (int i = 0; i < axs.length; i++) {
132
147
                                        AnnotationAJ annotationX = axs[i];
181
196
        private void unpackAjAttributes(World world) {
182
197
                associatedShadowMunger = null;
183
198
                ResolvedType resolvedDeclaringType = getDeclaringType().resolve(world);
 
199
                WeaverVersionInfo wvinfo = bcelObjectType.getWeaverVersionAttribute();
184
200
                List<AjAttribute> as = Utility.readAjAttributes(resolvedDeclaringType.getClassName(), method.getAttributes(),
185
 
                                resolvedDeclaringType.getSourceContext(), world, bcelObjectType.getWeaverVersionAttribute(),
186
 
                                new BcelConstantPoolReader(method.getConstantPool()));
 
201
                                resolvedDeclaringType.getSourceContext(), world, wvinfo, new BcelConstantPoolReader(method.getConstantPool()));
187
202
                processAttributes(world, as);
188
 
                as = AtAjAttributes.readAj5MethodAttributes(method, this, resolvedDeclaringType, preResolvedPointcut, resolvedDeclaringType
189
 
                                .getSourceContext(), world.getMessageHandler());
 
203
                as = AtAjAttributes.readAj5MethodAttributes(method, this, resolvedDeclaringType, preResolvedPointcut,
 
204
                                resolvedDeclaringType.getSourceContext(), world.getMessageHandler());
190
205
                processAttributes(world, as);
191
206
        }
192
207
 
379
394
                bitflags |= HAS_ANNOTATIONS;
380
395
        }
381
396
 
 
397
        public void removeAnnotation(ResolvedType annotationType) {
 
398
                ensureAnnotationsRetrieved();
 
399
                if ((bitflags & HAS_ANNOTATIONS) == 0) {
 
400
                        // nothing to do, why did we get called?
 
401
                } else {
 
402
                        int len = annotations.length;
 
403
                        if (len == 1) {
 
404
                                bitflags &= ~HAS_ANNOTATIONS;
 
405
                                annotations = null;
 
406
                                annotationTypes = null;
 
407
                                return;
 
408
                        }
 
409
                        AnnotationAJ[] ret = new AnnotationAJ[len - 1];
 
410
                        int p = 0;
 
411
                        for (AnnotationAJ annotation : annotations) {
 
412
                                if (!annotation.getType().equals(annotationType)) {
 
413
                                        ret[p++] = annotation;
 
414
                                }
 
415
                        }
 
416
                        annotations = ret;
 
417
 
 
418
                        ResolvedType[] newAnnotationTypes = new ResolvedType[len - 1];
 
419
                        p = 0;
 
420
                        for (AnnotationAJ annotation : annotations) {
 
421
                                if (!annotation.getType().equals(annotationType)) {
 
422
                                        newAnnotationTypes[p++] = annotationType;
 
423
                                }
 
424
                        }
 
425
                        annotationTypes = newAnnotationTypes;
 
426
                }
 
427
                bitflags |= HAS_ANNOTATIONS;
 
428
        }
 
429
 
382
430
        public static final AnnotationAJ[] NO_PARAMETER_ANNOTATIONS = new AnnotationAJ[] {};
383
431
 
384
432
        public void addParameterAnnotation(int param, AnnotationAJ anno) {