From 85aa1520881e7271e658b9377dfd020fde28868c Mon Sep 17 00:00:00 2001 From: acolyer Date: Thu, 10 Mar 2005 13:34:55 +0000 Subject: [PATCH] fix for Bugzilla Bug 87376 NPE when unresolved type of a bound var in a pointcut expression (EclipseFactory.java:224) --- .../internal/core/builder/AsmHierarchyBuilder.java | 8 ++++++-- tests/bugs150/pr87376/I.java | 5 +++++ tests/bugs150/pr87376/NPE.aj | 14 ++++++++++++++ .../org/aspectj/systemtest/ajc150/Ajc150Tests.java | 4 ++++ tests/src/org/aspectj/systemtest/ajc150/ajc150.xml | 7 +++++++ 5 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 tests/bugs150/pr87376/I.java create mode 100644 tests/bugs150/pr87376/NPE.aj diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java index f77f10f0a..da6f43a17 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java @@ -381,8 +381,12 @@ public class AsmHierarchyBuilder extends ASTVisitor { World world = ((AjLookupEnvironment)declaration.scope.environment()).factory.getWorld(); TypeX onType = rp.onType; if (onType == null) { - Member member = EclipseFactory.makeResolvedMember(declaration.binding); - onType = member.getDeclaringType(); + if (declaration.binding != null) { + Member member = EclipseFactory.makeResolvedMember(declaration.binding); + onType = member.getDeclaringType(); + } else { + return null; + } } ResolvedMember[] members = onType.getDeclaredPointcuts(world); if (members != null) { diff --git a/tests/bugs150/pr87376/I.java b/tests/bugs150/pr87376/I.java new file mode 100644 index 000000000..78dd3459b --- /dev/null +++ b/tests/bugs150/pr87376/I.java @@ -0,0 +1,5 @@ +package a.b.c; + +public interface I { + +} \ No newline at end of file diff --git a/tests/bugs150/pr87376/NPE.aj b/tests/bugs150/pr87376/NPE.aj new file mode 100644 index 000000000..77d7510ff --- /dev/null +++ b/tests/bugs150/pr87376/NPE.aj @@ -0,0 +1,14 @@ +package a.b.d; +//import a.b.c.I; + + + +public aspect NPE { + + pointcut ii(I i) : execution(* I.*(..)) && this(i); + + after(I i) returning : ii(i) { + System.out.println(i); + } + +} diff --git a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java index 556f2d4ea..82e1aed27 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java @@ -125,6 +125,10 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase { } } + public void npeOnTypeNotFound() { + runTest("structure model npe on type not found"); + } + // helper methods..... public SyntheticRepository createRepos(File cpentry) { diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml index 7329d2996..e043fc878 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml @@ -40,6 +40,13 @@ + + + + + + + -- 2.39.5