From 693945fed3ea7482c5c312063dfac881f0d0d1c9 Mon Sep 17 00:00:00 2001 From: aclement Date: Sun, 29 Jan 2006 10:12:10 +0000 Subject: [PATCH] fix and test for 123901. test for 125475 (commented out) --- .../internal/compiler/ast/AccessForInlineVisitor.java | 8 +++++--- tests/bugs151/pr123901/A.java | 5 +++++ tests/bugs151/pr123901/B.java | 8 ++++++++ tests/bugs151/pr125475/TestEmptyPointcutAtAspect.java | 6 ++++++ .../src/org/aspectj/systemtest/ajc151/Ajc151Tests.java | 2 ++ tests/src/org/aspectj/systemtest/ajc151/ajc151.xml | 10 ++++++++++ 6 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 tests/bugs151/pr123901/A.java create mode 100644 tests/bugs151/pr123901/B.java create mode 100644 tests/bugs151/pr125475/TestEmptyPointcutAtAspect.java diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java index 657b3b520..fc6d8a5bb 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java @@ -41,6 +41,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BlockScope; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.FieldBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ParameterizedMethodBinding; +import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ProblemFieldBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.VariableBinding; @@ -96,11 +97,12 @@ public class AccessForInlineVisitor extends ASTVisitor { //!!! understand and fix this case later receiverType = ref.otherBindings[0].declaringClass; } - - for (int i=0, len=ref.otherBindings.length; i < len; i++) { + boolean cont = true; // don't continue if we come across a problem + for (int i=0, len=ref.otherBindings.length; i < len && cont; i++) { FieldBinding binding = ref.otherBindings[i]; ref.otherBindings[i] = getAccessibleField(binding, receiverType); - receiverType = binding.type; + if (!(binding instanceof ProblemFieldBinding)) receiverType = binding.type; + else cont=false; } } } diff --git a/tests/bugs151/pr123901/A.java b/tests/bugs151/pr123901/A.java new file mode 100644 index 000000000..5ed3cb783 --- /dev/null +++ b/tests/bugs151/pr123901/A.java @@ -0,0 +1,5 @@ +package a; + +public class A { + public void x(){} +} diff --git a/tests/bugs151/pr123901/B.java b/tests/bugs151/pr123901/B.java new file mode 100644 index 000000000..df8baf065 --- /dev/null +++ b/tests/bugs151/pr123901/B.java @@ -0,0 +1,8 @@ +package a; +public aspect B { + void around():call(void *(..)){ + A a = new A(); + a.A.a.x(); // This line raises the NPE + proceed(); + } +} diff --git a/tests/bugs151/pr125475/TestEmptyPointcutAtAspect.java b/tests/bugs151/pr125475/TestEmptyPointcutAtAspect.java new file mode 100644 index 000000000..12334f4b9 --- /dev/null +++ b/tests/bugs151/pr125475/TestEmptyPointcutAtAspect.java @@ -0,0 +1,6 @@ +@Aspect +public class TestEmptyPointcutAtAspect { + + @Pointcut("") + protected void scope () {} +} diff --git a/tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java b/tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java index 5dda12f07..79ff78c44 100644 --- a/tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java @@ -33,6 +33,8 @@ public class Ajc151Tests extends org.aspectj.testing.XMLBasedAjcTestCase { public void testCallInheritedGenericMethod_pr124999() { runTest("calling inherited generic method from around advice");} public void testIncorrectlyReferencingPointcuts_pr122452() { runTest("incorrectly referencing pointcuts");} public void testIncorrectlyReferencingPointcuts_pr122452_2() { runTest("incorrectly referencing pointcuts - 2");} + //public void testEmptyPointcut_pr125475() { runTest("empty pointcut in atAJ");} + public void testInlinevisitorNPE_pr123901() { runTest("inlinevisitor NPE");} public void testMixingNumbersOfTypeParameters_pr125080() { runTest("mixing numbers of type parameters"); diff --git a/tests/src/org/aspectj/systemtest/ajc151/ajc151.xml b/tests/src/org/aspectj/systemtest/ajc151/ajc151.xml index f3d9c5b84..212ac5589 100644 --- a/tests/src/org/aspectj/systemtest/ajc151/ajc151.xml +++ b/tests/src/org/aspectj/systemtest/ajc151/ajc151.xml @@ -5,6 +5,12 @@ + + + + + + @@ -98,4 +104,8 @@ + + + + \ No newline at end of file -- 2.39.5