From d6b8b38cd0a707741788f8d4fae3850b213f50a4 Mon Sep 17 00:00:00 2001 From: jhugunin Date: Tue, 11 Mar 2003 21:04:59 +0000 Subject: [PATCH] added tests and fixes fixed two bugs in ajcTestsFailing --- .../ast/InterTypeFieldDeclaration.java | 10 +++++++ .../compiler/lookup/EclipseFactory.java | 3 +- tests/ajcTests.xml | 20 +++++++++++++ tests/ajcTestsBroken.xml | 6 +++- tests/ajcTestsFailing.xml | 26 ++++------------- tests/bugs/AspectInitError.java | 23 +++++++++++++++ tests/bugs/ThisJoinPointAndVerifier.java | 28 +++++++++++++++++++ tests/jimTests.xml | 21 ++++++++++++++ 8 files changed, 115 insertions(+), 22 deletions(-) create mode 100644 tests/bugs/AspectInitError.java create mode 100644 tests/bugs/ThisJoinPointAndVerifier.java diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeFieldDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeFieldDeclaration.java index 583edca78..ef833b13e 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeFieldDeclaration.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeFieldDeclaration.java @@ -67,6 +67,14 @@ public class InterTypeFieldDeclaration extends InterTypeDeclaration { EclipseFactory world = EclipseFactory.fromScopeLookupEnvironment(upperScope); ResolvedMember sig = munger.getSignature(); TypeX aspectType = EclipseFactory.fromBinding(upperScope.referenceContext.binding); + + if (sig.getReturnType() == ResolvedTypeX.VOID || + (sig.getReturnType().isArray() && (sig.getReturnType().getComponentType() == ResolvedTypeX.VOID))) + { + upperScope.problemReporter().signalError(sourceStart, sourceEnd, + "field type can not be void"); + } + // // System.err.println("sig: " + sig); // System.err.println("field: " + world.makeFieldBinding( @@ -129,6 +137,8 @@ public class InterTypeFieldDeclaration extends InterTypeDeclaration { EclipseFactory world = EclipseFactory.fromScopeLookupEnvironment(classScope); resolveOnType(classScope); + if (classScope.referenceContext.binding == null) return null; + binding = classScope.referenceContext.binding.resolveTypesFor(binding); if (ignoreFurtherInvestigation) return null; diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java index d1744dafb..68c875bfc 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java @@ -108,13 +108,14 @@ public class EclipseFactory { if (binding instanceof HelperInterfaceBinding) { return ((HelperInterfaceBinding) binding).getTypeX(); } - if (binding.qualifiedSourceName() == null) { + if (binding == null || binding.qualifiedSourceName() == null) { return ResolvedTypeX.MISSING; } return TypeX.forName(getName(binding)); } public static TypeX[] fromBindings(TypeBinding[] bindings) { + if (bindings == null) return TypeX.NONE; int len = bindings.length; TypeX[] ret = new TypeX[len]; for (int i=0; i + + + + + + + + + + + + + + + + + diff --git a/tests/ajcTestsBroken.xml b/tests/ajcTestsBroken.xml index 6fc14b27f..d919e26e4 100644 --- a/tests/ajcTestsBroken.xml +++ b/tests/ajcTestsBroken.xml @@ -67,5 +67,9 @@ - + + + + diff --git a/tests/ajcTestsFailing.xml b/tests/ajcTestsFailing.xml index 2073f0e7c..051196a60 100644 --- a/tests/ajcTestsFailing.xml +++ b/tests/ajcTestsFailing.xml @@ -52,19 +52,6 @@ - - - - - - - - - - - @@ -72,13 +59,6 @@ - - - - - - + + + + + diff --git a/tests/bugs/AspectInitError.java b/tests/bugs/AspectInitError.java new file mode 100644 index 000000000..3a46b9c5a --- /dev/null +++ b/tests/bugs/AspectInitError.java @@ -0,0 +1,23 @@ + + +/** Bugzilla Bug 34206 + before():execution(new(..)) does not throw NoAspectBoundException */ +public class AspectInitError { + public static void main(String[] args) { + //Watchcall.aspectOf(); + AspectInitError c = new AspectInitError(); + } + +} + +aspect Watchcall { + pointcut myConstructor(): execution(new(..)); + + before(): myConstructor() { + System.err.println("Entering Constructor"); + } + + after(): myConstructor() { + System.err.println("Leaving Constructor"); + } +} diff --git a/tests/bugs/ThisJoinPointAndVerifier.java b/tests/bugs/ThisJoinPointAndVerifier.java new file mode 100644 index 000000000..a3b609c40 --- /dev/null +++ b/tests/bugs/ThisJoinPointAndVerifier.java @@ -0,0 +1,28 @@ + + +/** Bugzilla Bug 34210 + thisJoinPoint.getArgs() causes IncompatibleClassChangeError */ +public class ThisJoinPointAndVerifier { + public void method() { + System.out.println("Executed method"); + } + public static void main(String args[]) { + ThisJoinPointAndVerifier td = new ThisJoinPointAndVerifier(); + td.method(); + } +} + +aspect Log1 { + pointcut logged_method() : + call(* ThisJoinPointAndVerifier.*(..)); + after() : logged_method() { + Object[] args = thisJoinPoint.getArgs(); + System.out.println ("Log1a: leaving " + thisJoinPoint.getSignature()); + } + // comment this advice for scenario 2 + after() : logged_method() { + //VM crash on scenario 1 + //Object[] args = thisJoinPoint.getArgs(); + System.out.println ("Log1b: leaving " + thisJoinPoint.getSignature()); + } +} \ No newline at end of file diff --git a/tests/jimTests.xml b/tests/jimTests.xml index e7e9b8b97..17db88e59 100644 --- a/tests/jimTests.xml +++ b/tests/jimTests.xml @@ -1,5 +1,26 @@ + + + + + + + + + + + + + + + + + + +