Browse Source

fixes for Bugzilla Bug 40858

	  	super-qualified pointcut reference cause weaver stack trace
and Bugzilla Bug 40814
	  	no error when defining interface pointcuts
tags/V1_1_1
jhugunin 21 years ago
parent
commit
29457c3d6d

+ 19
- 3
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java View File

@@ -19,6 +19,8 @@ import org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory;
import org.aspectj.ajdt.internal.core.builder.EclipseSourceContext;
import org.aspectj.weaver.AjAttribute;
import org.aspectj.weaver.ResolvedPointcutDefinition;
import org.aspectj.weaver.ResolvedTypeX;
import org.aspectj.weaver.TypeX;
import org.aspectj.weaver.patterns.Pointcut;
import org.eclipse.jdt.internal.compiler.ClassFile;
import org.eclipse.jdt.internal.compiler.CompilationResult;
@@ -72,8 +74,20 @@ public class PointcutDeclaration extends MethodDeclaration {
this.declaredName = new String(selector);
selector = CharOperation.concat(mangledPrefix, '$', selector, '$',
Integer.toHexString(sourceStart).toCharArray());
if (pointcutDesignator == null) return; //XXX
pointcutDesignator.postParse(typeDec, this);
if (Modifier.isAbstract(this.declaredModifiers) &&
!(typeDec instanceof AspectDeclaration))
{
typeDec.scope.problemReporter().signalError(sourceStart, sourceEnd,
"The abstract pointcut " + new String(declaredName) +
" can only be defined in an aspect");
ignoreFurtherInvestigation = true;
return;
}
if (pointcutDesignator != null) {
pointcutDesignator.postParse(typeDec, this);
}
}

public void resolveStatements() {
@@ -86,7 +100,9 @@ public class PointcutDeclaration extends MethodDeclaration {

if (Modifier.isAbstract(this.declaredModifiers)&& (pointcutDesignator != null)) {
scope.problemReporter().signalError(sourceStart, sourceEnd, "abstract pointcut can't have body");
}
ignoreFurtherInvestigation = true;
return;
}
if (pointcutDesignator != null) {
pointcutDesignator.finishResolveTypes(this, this.binding, arguments.length,

+ 22
- 0
tests/ajcTests.xml View File

@@ -6477,5 +6477,27 @@
<compile files="PointcutLibraryTest.java"/>
<run class="PointcutLibraryTest"/>
</ajc-test>
<ajc-test dir="bugs"
pr="40858"
comment="super is not permitted in pointcuts in 1.1"
title="weaver trace on mis-qualified pointcut reference">
<compile files="SuperPointcutCE.java">
<message kind="error" line="23"/>
<message kind="error" line="26"/>
</compile>
</ajc-test>

<ajc-test dir="bugs"
pr="40814"
title="compile error expected for interface pointcuts">
<compile files="AbstractPointcutCE.java">
<message kind="error" line="7"/>
<message kind="error" line="11"/>
<message kind="error" line="15"/>
</compile>
</ajc-test>



</suite>

+ 2
- 21
tests/ajcTestsFailing.xml View File

@@ -4,24 +4,6 @@
<!-- contains valid tests that the compiler has never passed -->

<suite>
<ajc-test dir="bugs"
pr="40858"
comment="shouldn't super ref be permitted?"
title="weaver trace on mis-qualified pointcut reference">
<compile files="SuperPointcutCE.java">
<message kind="error" line="26"/>
</compile>
</ajc-test>

<ajc-test dir="bugs"
pr="40814"
title="compile error expected for interface pointcuts">
<compile files="InterfacePointcutCE.java">
<message kind="error" line="5"/>
<message kind="error" line="6"/>
</compile>
</ajc-test>

<ajc-test dir="bugs"
pr="40805"
title="interface call signatures when declaring method in aspect">
@@ -36,7 +18,6 @@
<message kind="warning" line="35" text="call ICanGetSomething.getSomething"/>
<message kind="warning" line="38" text="call getSomething"/>
<message kind="warning" line="38" text="call ICanGetSomething.getSomething"/>
</compile>
</ajc-test>

</compile>
</ajc-test>
</suite>

+ 16
- 0
tests/bugs/AbstractPointcutCE.java View File

@@ -0,0 +1,16 @@


/** @testcase PR#40814 compile error expected for pointcuts in interfaces
* revised to check for error on abstract pointcuts in interfaces or classes
**/
interface I {
abstract pointcut pc(); // CE
}

abstract class C {
abstract pointcut pc(); // CE
}

class Concrete {
abstract pointcut pc(); // CE
}

+ 0
- 7
tests/bugs/InterfacePointcutCE.java View File

@@ -1,7 +0,0 @@


/** @testcase PR#40814 compile error expected for pointcuts in interfaces */
interface I {
abstract pointcut pc(); // CE
pointcut publicCalls() : call(public * *(..)) || call(public new(..)); // CE
}

+ 2
- 2
tests/bugs/SuperPointcutCE.java View File

@@ -1,6 +1,6 @@


public class MissingTypeSigatureCE {
public class SuperPointcutCE {
public static void main(String[] a) {
new C().run();
}
@@ -20,7 +20,7 @@ abstract aspect AA {
/** @testcase PR#40858 weaver trace on mis-qualified pointcut reference */
aspect B extends AA {
pointcut pc() : super.pc()
pointcut pc() : super.pc() // CE super not allowed in 1.1
&& !call(void println(..));
pointcut blah() : UnknownType.pc(); // CE

+ 2
- 0
weaver/src/org/aspectj/weaver/patterns/ReferencePointcut.java View File

@@ -113,6 +113,8 @@ public class ReferencePointcut extends Pointcut {
public void resolveBindings(IScope scope, Bindings bindings) {
if (onTypeSymbolic != null) {
onType = onTypeSymbolic.resolveExactType(scope, bindings);
// in this case we've already signalled an error
if (onType == ResolvedTypeX.MISSING) return;
}
ResolvedTypeX searchType;

Loading…
Cancel
Save