~ubuntu-branches/ubuntu/wily/aspectj/wily-proposed

« back to all changes in this revision

Viewing changes to org.aspectj/modules/org.aspectj.matcher/src/org/aspectj/weaver/Shadow.java

  • Committer: Bazaar Package Importer
  • Author(s): Damien Raude-Morvan
  • Date: 2011-03-15 23:54:31 UTC
  • mfrom: (1.2.5 upstream)
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: james.westby@ubuntu.com-20110315235431-iq2gxbsx08kpwuiw
* 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:
85
85
         * @throws IllegalStateException if there is no this here
86
86
         */
87
87
        public final UnresolvedType getThisType() {
88
 
                if (!hasThis())
 
88
                if (!hasThis()) {
89
89
                        throw new IllegalStateException("no this");
 
90
                }
90
91
                if (getKind().isEnclosingKind()) {
91
92
                        return getSignature().getDeclaringType();
92
93
                } else {
120
121
         * @throws IllegalStateException if there is no target here
121
122
         */
122
123
        public final UnresolvedType getTargetType() {
123
 
                if (!hasTarget())
 
124
                if (!hasTarget()) {
124
125
                        throw new IllegalStateException("no target");
 
126
                }
125
127
                return getSignature().getDeclaringType();
126
128
        }
127
129
 
133
135
        public abstract Var getTargetVar();
134
136
 
135
137
        public UnresolvedType[] getArgTypes() {
136
 
                if (getKind() == FieldSet)
 
138
                if (getKind() == FieldSet) {
137
139
                        return new UnresolvedType[] { getSignature().getReturnType() };
 
140
                }
138
141
                return getSignature().getParameterTypes();
139
142
        }
140
143
 
153
156
                int dims = 1;
154
157
                while (pos < s.length()) {
155
158
                        pos++;
156
 
                        if (pos < s.length())
 
159
                        if (pos < s.length()) {
157
160
                                dims += (s.charAt(pos) == '[' ? 1 : 0);
 
161
                        }
158
162
                }
159
 
                if (dims == 1)
 
163
                if (dims == 1) {
160
164
                        return new ResolvedType[] { ResolvedType.INT };
 
165
                }
161
166
                ResolvedType[] someInts = new ResolvedType[dims];
162
 
                for (int i = 0; i < dims; i++)
 
167
                for (int i = 0; i < dims; i++) {
163
168
                        someInts[i] = ResolvedType.INT;
 
169
                }
164
170
                return someInts;
165
171
        }
166
172
 
171
177
                if (isShadowForMonitor()) {
172
178
                        return UnresolvedType.ARRAY_WITH_JUST_OBJECT;
173
179
                }
174
 
                if (getKind() == FieldSet)
 
180
                if (getKind() == FieldSet) {
175
181
                        return new UnresolvedType[] { getResolvedSignature().getGenericReturnType() };
 
182
                }
176
183
                return getResolvedSignature().getGenericParameterTypes();
177
184
        }
178
185
 
179
186
        public UnresolvedType getArgType(int arg) {
180
 
                if (getKind() == FieldSet)
 
187
                if (getKind() == FieldSet) {
181
188
                        return getSignature().getReturnType();
 
189
                }
182
190
                return getSignature().getParameterTypes()[arg];
183
191
        }
184
192
 
185
193
        public int getArgCount() {
186
 
                if (getKind() == FieldSet)
 
194
                if (getKind() == FieldSet) {
187
195
                        return 1;
 
196
                }
188
197
                return getSignature().getParameterTypes().length;
189
198
        }
190
199
 
263
272
        }
264
273
 
265
274
        public UnresolvedType getReturnType() {
266
 
                if (kind == ConstructorCall)
 
275
                if (kind == ConstructorCall) {
267
276
                        return getSignature().getDeclaringType();
268
 
                else if (kind == FieldSet)
269
 
                        return ResolvedType.VOID;
270
 
                else if (kind == SynchronizationLock || kind == SynchronizationUnlock)
271
 
                        return ResolvedType.VOID;
 
277
                } else if (kind == FieldSet) {
 
278
                        return ResolvedType.VOID;
 
279
                } else if (kind == SynchronizationLock || kind == SynchronizationUnlock) {
 
280
                        return ResolvedType.VOID;
 
281
                }
272
282
                return getResolvedSignature().getGenericReturnType();
273
283
        }
274
284
 
337
347
        public static int howMany(int i) {
338
348
                int count = 0;
339
349
                for (int j = 0; j < SHADOW_KINDS.length; j++) {
340
 
                        if ((i & SHADOW_KINDS[j].bit) != 0)
 
350
                        if ((i & SHADOW_KINDS[j].bit) != 0) {
341
351
                                count++;
 
352
                        }
342
353
                }
343
354
                return count;
344
355
        }
423
434
 
424
435
                public String getSimpleName() {
425
436
                        int dash = getName().lastIndexOf('-');
426
 
                        if (dash == -1)
 
437
                        if (dash == -1) {
427
438
                                return getName();
428
 
                        else
 
439
                        } else {
429
440
                                return getName().substring(dash + 1);
 
441
                        }
430
442
                }
431
443
 
432
444
                public static Kind read(DataInputStream s) throws IOException {
471
483
         */
472
484
        protected boolean checkMunger(ShadowMunger munger) {
473
485
                if (munger.mustCheckExceptions()) {
474
 
                        for (Iterator i = munger.getThrownExceptions().iterator(); i.hasNext();) {
475
 
                                if (!checkCanThrow(munger, (ResolvedType) i.next()))
 
486
                        for (Iterator<ResolvedType> i = munger.getThrownExceptions().iterator(); i.hasNext();) {
 
487
                                if (!checkCanThrow(munger, i.next())) {
476
488
                                        return false;
 
489
                                }
477
490
                        }
478
491
                }
479
492
                return true;
506
519
        private boolean isDeclaredException(ResolvedType resolvedTypeX, Member member) {
507
520
                ResolvedType[] excs = getIWorld().resolve(member.getExceptions(getIWorld()));
508
521
                for (int i = 0, len = excs.length; i < len; i++) {
509
 
                        if (excs[i].isAssignableFrom(resolvedTypeX))
 
522
                        if (excs[i].isAssignableFrom(resolvedTypeX)) {
510
523
                                return true;
 
524
                        }
511
525
                }
512
526
                return false;
513
527
        }
514
528
 
515
529
        public void addMunger(ShadowMunger munger) {
516
530
                if (checkMunger(munger)) {
517
 
                        if (mungers == Collections.EMPTY_LIST)
 
531
                        if (mungers == Collections.EMPTY_LIST) {
518
532
                                mungers = new ArrayList();
 
533
                        }
519
534
                        this.mungers.add(munger);
520
535
                }
521
536
        }
522
537
 
523
538
        public final void implement() {
524
539
                sortMungers();
525
 
                if (mungers == null)
 
540
                if (mungers == null) {
526
541
                        return;
 
542
                }
527
543
                prepareForMungers();
528
544
                implementMungers();
529
545
        }
537
553
 
538
554
                if (sorted == null) {
539
555
                        // this means that we have circular dependencies
540
 
                        for (Iterator i = mungers.iterator(); i.hasNext();) {
541
 
                                ShadowMunger m = (ShadowMunger) i.next();
 
556
                        for (ShadowMunger m : mungers) {
542
557
                                getIWorld().getMessageHandler().handleMessage(
543
558
                                                MessageUtil.error(WeaverMessages.format(WeaverMessages.CIRCULAR_DEPENDENCY, this), m.getSourceLocation()));
544
559
                        }
552
567
 
553
568
                        // Stores a set of strings of the form 'aspect1:aspect2' which indicates there is no
554
569
                        // precedence specified between the two aspects at this shadow.
555
 
                        Set clashingAspects = new HashSet();
 
570
                        Set<String> clashingAspects = new HashSet<String>();
556
571
                        int max = mungers.size();
557
572
 
558
573
                        // Compare every pair of advice mungers
580
595
                                                                if (order != null && order.equals(new Integer(0))) {
581
596
                                                                        String key = adviceA.getDeclaringAspect() + ":" + adviceB.getDeclaringAspect();
582
597
                                                                        String possibleExistingKey = adviceB.getDeclaringAspect() + ":" + adviceA.getDeclaringAspect();
583
 
                                                                        if (!clashingAspects.contains(possibleExistingKey))
 
598
                                                                        if (!clashingAspects.contains(possibleExistingKey)) {
584
599
                                                                                clashingAspects.add(key);
 
600
                                                                        }
585
601
                                                                }
586
602
                                                        }
587
603
                                                }
588
604
                                        }
589
605
                                }
590
606
                        }
591
 
                        for (Iterator iter = clashingAspects.iterator(); iter.hasNext();) {
592
 
                                String element = (String) iter.next();
 
607
                        for (Iterator<String> iter = clashingAspects.iterator(); iter.hasNext();) {
 
608
                                String element = iter.next();
593
609
                                String aspect1 = element.substring(0, element.indexOf(":"));
594
610
                                String aspect2 = element.substring(element.indexOf(":") + 1);
595
 
                                getIWorld().getLint().unorderedAdviceAtShadow.signal(new String[] { this.toString(), aspect1, aspect2 }, this
596
 
                                                .getSourceLocation(), null);
 
611
                                getIWorld().getLint().unorderedAdviceAtShadow.signal(new String[] { this.toString(), aspect1, aspect2 },
 
612
                                                this.getSourceLocation(), null);
597
613
                        }
598
614
                }
599
615
        }
655
671
         * Convert a bit array for the shadow kinds into a set of them... should only be used for testing - mainline code should do bit
656
672
         * manipulation!
657
673
         */
658
 
        public static Set toSet(int i) {
659
 
                Set results = new HashSet();
 
674
        public static Set<Kind> toSet(int i) {
 
675
                Set<Kind> results = new HashSet<Kind>();
660
676
                for (int j = 0; j < Shadow.SHADOW_KINDS.length; j++) {
661
677
                        Kind k = Shadow.SHADOW_KINDS[j];
662
 
                        if (k.isSet(i))
 
678
                        if (k.isSet(i)) {
663
679
                                results.add(k);
 
680
                        }
664
681
                }
665
682
                return results;
666
683
        }