declaring interface methods should work as it does in interface and Bugzilla Bug 45676 AspectJ enhanced code can not be used with plain old java anymo and Bugzilla Bug 43972 Static crosscutting makes interfaces unusable for javactags/v_preCompileLoopAlteration
@@ -72,6 +72,16 @@ public class InterTypeMethodDeclaration extends InterTypeDeclaration { | |||
super.resolve(upperScope); | |||
} | |||
public void resolveStatements() { | |||
if ((modifiers & AccSemicolonBody) != 0) { | |||
if ((declaredModifiers & AccAbstract) == 0) | |||
scope.problemReporter().methodNeedingAbstractModifier(this); | |||
} else { | |||
// the method HAS a body --> abstract native modifiers are forbiden | |||
if (((declaredModifiers & AccAbstract) != 0)) | |||
scope.problemReporter().methodNeedingNoBody(this); | |||
} | |||
if (!Modifier.isAbstract(declaredModifiers)) super.resolveStatements(); | |||
if (Modifier.isStatic(declaredModifiers)) { | |||
// Check the target for ITD is not an interface |
@@ -308,6 +308,8 @@ public class AjLookupEnvironment extends LookupEnvironment { | |||
} | |||
} | |||
//???onType.checkInterTypeMungers(); | |||
onType.checkInterTypeMungers(); | |||
for (Iterator i = onType.getInterTypeMungers().iterator(); i.hasNext();) { | |||
EclipseTypeMunger munger = (EclipseTypeMunger) i.next(); | |||
//System.out.println("applying: " + munger + " to " + new String(sourceType.sourceName)); |
@@ -23,6 +23,7 @@ import java.util.List; | |||
import org.aspectj.bridge.IMessage; | |||
import org.aspectj.bridge.ISourceLocation; | |||
import org.aspectj.bridge.Message; | |||
import org.aspectj.bridge.MessageUtil; | |||
import org.aspectj.weaver.patterns.Declare; | |||
import org.aspectj.weaver.patterns.PerClause; | |||
@@ -928,6 +929,70 @@ public abstract class ResolvedTypeX extends TypeX { | |||
public List getInterTypeMungers() { | |||
return interTypeMungers; | |||
} | |||
private List getInterTypeMungersIncludingSupers() { | |||
ArrayList ret = new ArrayList(); | |||
collectInterTypeMungers(ret); | |||
return ret; | |||
} | |||
/** | |||
* ??? This method is O(N*M) where N = number of methods and M is number of | |||
* inter-type declarations in my super | |||
*/ | |||
private void collectInterTypeMungers(List collector) { | |||
for (Iterator iter = getDirectSupertypes(); iter.hasNext();) { | |||
ResolvedTypeX superType = (ResolvedTypeX) iter.next(); | |||
superType.collectInterTypeMungers(collector); | |||
} | |||
outer: for (Iterator iter1 = collector.iterator(); iter1.hasNext(); ) { | |||
ConcreteTypeMunger superMunger = (ConcreteTypeMunger) iter1.next(); | |||
if ( superMunger.getSignature() == null) continue; | |||
if ( !superMunger.getSignature().isAbstract()) continue; | |||
for (Iterator iter = getInterTypeMungers().iterator(); iter.hasNext();) { | |||
ConcreteTypeMunger myMunger = (ConcreteTypeMunger) iter.next(); | |||
if (conflictingSignature(myMunger.getSignature(), superMunger.getSignature())) { | |||
iter1.remove(); | |||
continue outer; | |||
} | |||
} | |||
if (!superMunger.getSignature().isPublic()) continue; | |||
for (Iterator iter = getMethods(); iter.hasNext(); ) { | |||
ResolvedMember method = (ResolvedMember)iter.next(); | |||
if (conflictingSignature(method, superMunger.getSignature())) { | |||
iter1.remove(); | |||
continue outer; | |||
} | |||
} | |||
} | |||
collector.addAll(getInterTypeMungers()); | |||
} | |||
/** | |||
* Check that we don't have any abstract type mungers unless this | |||
* type is abstract. | |||
*/ | |||
public void checkInterTypeMungers() { | |||
if (isAbstract()) return; | |||
for (Iterator iter = getInterTypeMungersIncludingSupers().iterator(); iter.hasNext();) { | |||
ConcreteTypeMunger element = (ConcreteTypeMunger) iter.next(); | |||
if (element.getSignature() != null && element.getSignature().isAbstract()) { | |||
world.getMessageHandler().handleMessage( | |||
new Message("must implement abstract inter-type declaration: " + element.getSignature(), | |||
"", IMessage.ERROR, getSourceLocation(), null, | |||
new ISourceLocation[] { element.getSourceLocation() })); | |||
} | |||
} | |||
} | |||
/** | |||
* Returns a ResolvedTypeX object representing the declaring type of this type, or | |||
@@ -1277,4 +1342,5 @@ public abstract class ResolvedTypeX extends TypeX { | |||
public WeaverStateInfo getWeaverState() { | |||
return null; | |||
} | |||
} |
@@ -232,7 +232,9 @@ public class BcelTypeMunger extends ConcreteTypeMunger { | |||
BcelWorld.makeBcelTypes(member.getParameterTypes()), | |||
TypeX.getNames(member.getExceptions()), | |||
gen); | |||
ret.makeSynthetic(); | |||
// 43972 : Static crosscutting makes interfaces unusable for javac | |||
// ret.makeSynthetic(); | |||
return ret; | |||
} | |||
@@ -325,7 +327,7 @@ public class BcelTypeMunger extends ConcreteTypeMunger { | |||
if (onType.equals(gen.getType())) { | |||
ResolvedMember introMethod = | |||
AjcMemberMaker.interMethod(signature, aspectType, onInterface); | |||
LazyMethodGen mg = makeMethodGen(gen, introMethod); | |||
if (!onInterface && !Modifier.isAbstract(introMethod.getModifiers())) { | |||
@@ -366,8 +368,6 @@ public class BcelTypeMunger extends ConcreteTypeMunger { | |||
AjcMemberMaker.interMethod(signature, aspectType, false); | |||
LazyMethodGen mg = makeMethodGen(gen, introMethod); | |||
// | |||
Type[] paramTypes = BcelWorld.makeBcelTypes(introMethod.getParameterTypes()); | |||
Type returnType = BcelWorld.makeBcelType(introMethod.getReturnType()); | |||
@@ -444,7 +444,6 @@ public class BcelTypeMunger extends ConcreteTypeMunger { | |||
ResolvedMember newConstructorMember = newConstructorTypeMunger.getSyntheticConstructor(); | |||
TypeX onType = newConstructorMember.getDeclaringType(); | |||
if (! onType.equals(currentClass.getType())) return false; | |||
ResolvedMember explicitConstructor = newConstructorTypeMunger.getExplicitConstructor(); | |||
@@ -519,7 +518,6 @@ public class BcelTypeMunger extends ConcreteTypeMunger { | |||
body.append(Utility.createInvoke(fact, null, postMethod)); | |||
// don't forget to return!! | |||
body.append(InstructionConstants.RETURN); | |||
return true; |
@@ -471,6 +471,8 @@ public class BcelWeaver implements IWeaver { | |||
JavaClass javaClass = classType.getJavaClass(); | |||
List shadowMungers = fastMatch(shadowMungerList, classType.getResolvedTypeX()); | |||
List typeMungers = classType.getResolvedTypeX().getInterTypeMungers(); | |||
classType.getResolvedTypeX().checkInterTypeMungers(); | |||
LazyClassGen clazz = null; | |||