View | Details | Raw Unified | Return to bug 259586
Collapse All | Expand All

(-)src/org/aspectj/weaver/bcel/BcelWeaver.java (+31 lines)
Lines 63-68 Link Here
63
import org.aspectj.weaver.IClassFileProvider;
63
import org.aspectj.weaver.IClassFileProvider;
64
import org.aspectj.weaver.IUnwovenClassFile;
64
import org.aspectj.weaver.IUnwovenClassFile;
65
import org.aspectj.weaver.IWeaveRequestor;
65
import org.aspectj.weaver.IWeaveRequestor;
66
import org.aspectj.weaver.MatchHolder;
66
import org.aspectj.weaver.NewParentTypeMunger;
67
import org.aspectj.weaver.NewParentTypeMunger;
67
import org.aspectj.weaver.ReferenceType;
68
import org.aspectj.weaver.ReferenceType;
68
import org.aspectj.weaver.ReferenceTypeDelegate;
69
import org.aspectj.weaver.ReferenceTypeDelegate;
Lines 518-523 Link Here
518
		// because continuing with
519
		// because continuing with
519
		// inconsistent pointcuts could lead to problems
520
		// inconsistent pointcuts could lead to problems
520
		typeMungerList = xcutSet.getTypeMungers();
521
		typeMungerList = xcutSet.getTypeMungers();
522
		
523
		Map/*UnresolvedType>MatchHolder*/ duplicatorAvoidanceMap = new HashMap();		
524
		for (Iterator iterator = typeMungerList.iterator(); iterator.hasNext();) {
525
			ConcreteTypeMunger typeMunger = (ConcreteTypeMunger) iterator.next();
526
			UnresolvedType onTypeU = typeMunger.getSignature().getDeclaringType();
527
			ResolvedType onType = world.resolve(onTypeU);
528
//			System.out.println("Matches check for "+this+" on "+matchType+" decltype="+onType);
529
			if (onType.isRawType()) {
530
				onType = onType.getGenericType();
531
			}
532
			MatchHolder mHolder = (MatchHolder)duplicatorAvoidanceMap.get(onType);
533
			if (mHolder == null) {
534
				mHolder = new MatchHolder(onType);
535
				duplicatorAvoidanceMap.put(onType,mHolder);
536
			}
537
			typeMunger.setAvoider(mHolder);
538
//			Integer i = (Integer)counter.get(typeMunger.getSignature().getDeclaringType());
539
//			if (i!=null) {
540
//				i = new Integer(i.intValue()+1);
541
//				counter.put(typeMunger.getSignature().getDeclaringType(),i);
542
//			} else {
543
//				counter.put(typeMunger.getSignature().getDeclaringType(),new Integer(1));
544
//			}
545
		}
546
//		Set s = counter.keySet();
547
//		for (Iterator iterator = s.iterator(); iterator.hasNext();) {
548
//			Object object = (Object) iterator.next();
549
//			System.out.println("K:"+object+" v:"+counter.get(object));
550
//		}
551
		
521
		lateTypeMungerList = xcutSet.getLateTypeMungers();
552
		lateTypeMungerList = xcutSet.getLateTypeMungers();
522
		declareParentsList = xcutSet.getDeclareParents();
553
		declareParentsList = xcutSet.getDeclareParents();
523
554
(-)src/org/aspectj/weaver/ConcreteTypeMunger.java (+4 lines)
Lines 150-153 Link Here
150
	public boolean shouldOverwrite() {
150
	public boolean shouldOverwrite() {
151
		return true;
151
		return true;
152
	}
152
	}
153
154
	public void setAvoider(MatchHolder holder) {
155
		if (munger!=null) munger.setAvoider(holder);
156
	}
153
}
157
}
(-)src/org/aspectj/weaver/ResolvedTypeMunger.java (-23 / +38 lines)
Lines 57-62 Link Here
57
	private Set /* resolvedMembers */superMethodsCalled = Collections.EMPTY_SET;
57
	private Set /* resolvedMembers */superMethodsCalled = Collections.EMPTY_SET;
58
58
59
	private ISourceLocation location; // Lost during serialize/deserialize !
59
	private ISourceLocation location; // Lost during serialize/deserialize !
60
	private MatchHolder avoider;
60
61
61
	public ResolvedTypeMunger(Kind kind, ResolvedMember signature) {
62
	public ResolvedTypeMunger(Kind kind, ResolvedMember signature) {
62
		this.kind = kind;
63
		this.kind = kind;
Lines 99-132 Link Here
99
	// ConcreteTypeMunger munger = world.concreteTypeMunger(this, aspectType);
100
	// ConcreteTypeMunger munger = world.concreteTypeMunger(this, aspectType);
100
	// return munger;
101
	// return munger;
101
	// }
102
	// }
102
103
	
104
	
103
	public boolean matches(ResolvedType matchType, ResolvedType aspectType) {
105
	public boolean matches(ResolvedType matchType, ResolvedType aspectType) {
104
		ResolvedType onType = matchType.getWorld().resolve(signature.getDeclaringType());
106
		Boolean b = (avoider==null?null:avoider.matches(matchType));
105
		if (onType.isRawType())
107
		if (b==null) {
106
			onType = onType.getGenericType();
108
			ResolvedType onType = matchType.getWorld().resolve(signature.getDeclaringType());
107
		// System.err.println("matching: " + this + " to " + matchType + " onType = " + onType);
109
	//		System.out.println("Matches check for "+this+" on "+matchType+" decltype="+onType);
108
		if (matchType.equals(onType)) {
110
			if (onType.isRawType()) {
109
			if (!onType.isExposedToWeaver()) {
111
				onType = onType.getGenericType();
110
				// if the onType is an interface, and it already has the member we are about
112
			}
111
				// to munge, then this is ok...
113
	//		 System.err.println("matching: " + this + " to " + matchType + " onType = " + onType);
112
				boolean ok = (onType.isInterface() && (onType.lookupMemberWithSupersAndITDs(getSignature()) != null));
114
			if (matchType.equals(onType)) {
113
115
				if (!onType.isExposedToWeaver()) {
114
				if (!ok && onType.getWeaverState() == null) {
116
					// if the onType is an interface, and it already has the member we are about
115
					if (matchType.getWorld().getLint().typeNotExposedToWeaver.isEnabled()) {
117
					// to munge, then this is ok...
116
						matchType.getWorld().getLint().typeNotExposedToWeaver.signal(matchType.getName(), signature
118
					boolean ok = (onType.isInterface() && (onType.lookupMemberWithSupersAndITDs(getSignature()) != null));
117
								.getSourceLocation());
119
	
120
					if (!ok && onType.getWeaverState() == null) {
121
						if (matchType.getWorld().getLint().typeNotExposedToWeaver.isEnabled()) {
122
							matchType.getWorld().getLint().typeNotExposedToWeaver.signal(matchType.getName(), signature
123
									.getSourceLocation());
124
						}
118
					}
125
					}
119
				}
126
				}
127
				b = Boolean.TRUE;
128
			} else {
129
		
130
				if (onType.isInterface()) {
131
					b = Boolean.valueOf(matchType.isTopmostImplementor(onType));
132
				} else {
133
					b = Boolean.FALSE;
134
				}
135
			}
136
			if (avoider!=null) {
137
				avoider.record(matchType,b);
120
			}
138
			}
121
			return true;
122
		}
123
		// System.err.println("NO MATCH DIRECT");
124
125
		if (onType.isInterface()) {
126
			return matchType.isTopmostImplementor(onType);
127
		} else {
128
			return false;
129
		}
139
		}
140
		return b.booleanValue();
130
	}
141
	}
131
142
132
	// ----
143
	// ----
Lines 449-452 Link Here
449
		throw new BCException("Dont call parameterizeWith() on a type munger of this kind: " + this.getClass());
460
		throw new BCException("Dont call parameterizeWith() on a type munger of this kind: " + this.getClass());
450
	}
461
	}
451
462
463
	public void setAvoider(MatchHolder holder) {
464
		this.avoider = holder;
465
	}
466
452
}
467
}
(-)src/org/aspectj/weaver/MatchHolder.java (+34 lines)
Added Link Here
1
/* *******************************************************************
2
 * Copyright (c) 2009 Contributors
3
 * All rights reserved. 
4
 * This program and the accompanying materials are made available 
5
 * under the terms of the Eclipse Public License v1.0 
6
 * which accompanies this distribution and is available at 
7
 * http://www.eclipse.org/legal/epl-v10.html 
8
 *  
9
 * Contributors: 
10
 *     Andy Clement     initial implementation 
11
 * ******************************************************************/
12
package org.aspectj.weaver;
13
14
import java.util.HashMap;
15
import java.util.Map;
16
17
public class MatchHolder {
18
	
19
	private ResolvedType forType;
20
	private Map/*matchType,boolean*/ matches = new HashMap();
21
	
22
	public MatchHolder(ResolvedType forType) {
23
		this.forType = forType;
24
	}
25
26
	public Boolean matches(ResolvedType matchType) {
27
		return (Boolean)matches.get(matchType);
28
	}
29
30
	public void record(ResolvedType matchType, Boolean b) {
31
		matches.put(matchType,b);
32
	}
33
34
}

Return to bug 259586