Przeglądaj źródła

Fix for Bugzilla Bug 49638 exception logging: after() throwing advice can't convert Throwable obj to string and ajc aborts

tags/mostlyLastEclipse2xTree_20040112
jhugunin 20 lat temu
rodzic
commit
7b081f2e0b

+ 6
- 1
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/parser/AjParser.java Wyświetl plik

@@ -737,7 +737,12 @@ public class AjParser extends Parser {
} else if (CharOperation.equals(name, "returning".toCharArray())) {
adviceDecl.kind = AdviceKind.AfterReturning;
} else {
//XXX illegal name here
problemReporter().parseError(
start,
end,
name,
String.valueOf(name),
new String[] {"throwing", "returning", ":"});
}
}


+ 12
- 1
tests/ajcTests.xml Wyświetl plik

@@ -6897,5 +6897,16 @@
</message>
</compile>
</ajc-test>

<ajc-test dir="bugs"
title="Appropriate message for 'after() thowing(Throwable th)' syntax error"
pr="49638"
>
<compile
files="AfterThrowingAdviceSyntaxError.java" >
<message kind="error" line="21" />
<message kind="error" line="23" />
</compile>
</ajc-test>
</suite>

+ 28
- 0
tests/bugs/AfterThrowingAdviceSyntaxError.java Wyświetl plik

@@ -0,0 +1,28 @@
import org.aspectj.lang.*;

public class AfterThrowingAdviceSyntaxError {

public static void main(String[] args) {
perform();
}

private static void perform() {
Object nullObj = null;
nullObj.toString();
}
}

aspect ExceptionLoggerAspectV2
{

pointcut exceptionLogMethods()
: call(* *.*(..)) && !within(ExceptionLoggerAspectV2);

after() thowing(Throwable ex) : exceptionLogMethods() {
Signature sig = thisJoinPointStaticPart.getSignature();
System.out.printl("WARNING: "
+ sig.getDeclaringType().getName() + " "
+ sig.getName() + " "
+ "Exception logger aspect " + ex);
}
}

Ładowanie…
Anuluj
Zapisz