<run class="TryFinallyInAround"/>
</ajc-test>
+ <ajc-test dir="new" pr="36778"
+ title="advise join points in subclass of empty interface">
+ <compile files="EmptyInterface.java"/>
+ <run class="EmptyInterface"/>
+ </ajc-test>
+
+ <ajc-test dir="new" pr="36778"
+ title="can't put around advice on interface static initializer"
+ comment="this tests for a nice message given a compiler limitation">
+ <compile files="EmptyInterfaceCE.java">
+ <message kind="error" line="20"/>
+ <message kind="error" line="23"/>
+ </compile>
+ </ajc-test>
+
</suite>
<!-- contains valid tests that the compiler has never passed -->
<suite>
- <ajc-test dir="new" pr="36778"
- title="advise join points in subclass of empty interface">
- <compile files="EmptyInterface.java"/>
- <run class="EmptyInterface"/>
- </ajc-test>
+
</suite>
<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd">
<suite>
- <ajc-test dir="bugs" pr="36056"
- title="Ajc 1.1 rc1 java.lang.VerifyError with messy arounds and naming">
- <compile files="AroundNames.java"/>
- <run class="AroundNames"/>
- </ajc-test>
+
<!--
aspect Log {
static int hits;
static StringBuffer log = new StringBuffer();
- interface LoggedType {}
+ interface LoggedType {
+ }
declare parents: C implements LoggedType;
- void around() : within(LoggedType+)
- && !initialization(new(..))
- && !preinitialization(new(..)) // 1.1 only
+ after() : within(LoggedType+)
+ //&& !initialization(new(..))
+ //&& !preinitialization(new(..)) // 1.1 only
{
hits++;
log.append(thisJoinPoint + ";");
--- /dev/null
+
+
+import org.aspectj.testing.Tester;
+
+/** @testcase PR#36778 advise join points in subclass of empty interface */
+public class EmptyInterfaceCE {
+
+ public static void main(String[] args) {
+ new C().go();
+ // at least constructor and method execution
+ if (2 > Log.hits) {
+ Tester.check(false, Log.log.toString());
+ }
+ }
+}
+
+aspect Log {
+ static int hits;
+ static StringBuffer log = new StringBuffer();
+ interface LoggedType {
+ }
+ declare parents: C implements LoggedType;
+ void around() : staticinitialization(LoggedType) // CE: limitation
+ {
+ hits++;
+ log.append(thisJoinPoint + ";");
+ }
+}
+
+class C {
+ void go() {}
+}
"around on pre-initialization not supported (compiler limitation)",
getSourceLocation(), shadow.getSourceLocation());
return false;
- } else if (shadow.getKind() == Shadow.Initialization) {
- world.showMessage(IMessage.ERROR,
- "around on initialization not supported (compiler limitation)",
- getSourceLocation(), shadow.getSourceLocation());
+ } else if (shadow.getKind() == Shadow.Initialization) {
+ world.showMessage(IMessage.ERROR,
+ "around on initialization not supported (compiler limitation)",
+ getSourceLocation(), shadow.getSourceLocation());
+ return false;
+ } else if (shadow.getKind() == Shadow.StaticInitialization &&
+ shadow.getEnclosingType().isInterface(world))
+ {
+ world.showMessage(IMessage.ERROR,
+ "around on staticinitialization of interface \'" +
+ shadow.getEnclosingType().getName() +
+ "\' not supported (compiler limitation)",
+ getSourceLocation(), shadow.getSourceLocation());
return false;
} else {
//System.err.println(getSignature().getReturnType() + " from " + shadow.getReturnType());