From d0b8c7a1bfbc2b2f92b22bcf63598ab2442781b6 Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Wed, 17 Sep 2014 10:53:29 -0700 Subject: [PATCH] Fix for 444398: annotation style abstract aspect extends class error --- .../compiler/lookup/EclipseSourceType.java | 18 +++++++----------- tests/bugs183/443477/Coo.java | 12 ++++++++++++ tests/bugs183/444398/Bottom.java | 5 +++++ tests/bugs183/444398/Middle.java | 6 ++++++ tests/bugs183/444398/Top.java | 2 ++ .../src/org/aspectj/systemtest/AllTests18.java | 4 +++- .../aspectj/systemtest/ajc183/Ajc183Tests.java | 12 ++++++++++-- .../org/aspectj/systemtest/ajc183/ajc183.xml | 10 ++++++++++ 8 files changed, 55 insertions(+), 14 deletions(-) create mode 100644 tests/bugs183/443477/Coo.java create mode 100644 tests/bugs183/444398/Bottom.java create mode 100644 tests/bugs183/444398/Middle.java create mode 100644 tests/bugs183/444398/Top.java diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java index 12ffdc9fc..d24ff7a3c 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseSourceType.java @@ -1031,6 +1031,10 @@ public class EclipseSourceType extends AbstractReferenceTypeDelegate { PerClause.Kind getPerClauseForTypeDeclaration(TypeDeclaration typeDeclaration) { Annotation[] annotations = typeDeclaration.annotations; + if (annotations == null) { + // Can happen if an aspect is extending a regular class + return null; + } for (int i = 0; i < annotations.length; i++) { Annotation annotation = annotations[i]; if (annotation != null && annotation.resolvedType != null @@ -1055,15 +1059,8 @@ public class EclipseSourceType extends AbstractReferenceTypeDelegate { // safe // ? return determinePerClause(typeDeclaration, clause); - } else if (annotation instanceof NormalAnnotation) { // this - // kind - // if it - // was - // added - // by - // the - // visitor - // ! + } else if (annotation instanceof NormalAnnotation) { + // this kind if it was added by the visitor! // it is an @Aspect(...something...) NormalAnnotation theAnnotation = (NormalAnnotation) annotation; if (theAnnotation.memberValuePairs == null || theAnnotation.memberValuePairs.length < 1) { @@ -1080,8 +1077,7 @@ public class EclipseSourceType extends AbstractReferenceTypeDelegate { "@Aspect annotation is expected to be SingleMemberAnnotation with 'String value()' as unique element", new EclipseSourceLocation(typeDeclaration.compilationResult, typeDeclaration.sourceStart, typeDeclaration.sourceEnd), null); - return PerClause.SINGLETON;// fallback strategy just to - // avoid NPE + return PerClause.SINGLETON;// fallback strategy just to avoid NPE } } } diff --git a/tests/bugs183/443477/Coo.java b/tests/bugs183/443477/Coo.java new file mode 100644 index 000000000..7b514f3ba --- /dev/null +++ b/tests/bugs183/443477/Coo.java @@ -0,0 +1,12 @@ +public class Coo { + Coo() { + } + + public static void main(String[] args) { + } +} + +aspect Azpect { + before(): !cflow(preinitialization(Coo.new(..))) && execution(* main(..)) { } +} + diff --git a/tests/bugs183/444398/Bottom.java b/tests/bugs183/444398/Bottom.java new file mode 100644 index 000000000..b3d366adf --- /dev/null +++ b/tests/bugs183/444398/Bottom.java @@ -0,0 +1,5 @@ +import org.aspectj.lang.annotation.*; + +@Aspect +public abstract class Bottom extends Middle { +} diff --git a/tests/bugs183/444398/Middle.java b/tests/bugs183/444398/Middle.java new file mode 100644 index 000000000..37c3e82ba --- /dev/null +++ b/tests/bugs183/444398/Middle.java @@ -0,0 +1,6 @@ +import org.aspectj.lang.annotation.*; + +@Aspect + +public abstract class Middle extends Top { +} diff --git a/tests/bugs183/444398/Top.java b/tests/bugs183/444398/Top.java new file mode 100644 index 000000000..a013d980e --- /dev/null +++ b/tests/bugs183/444398/Top.java @@ -0,0 +1,2 @@ +public abstract class Top { +} diff --git a/tests/src/org/aspectj/systemtest/AllTests18.java b/tests/src/org/aspectj/systemtest/AllTests18.java index 5001f9a37..547a17817 100644 --- a/tests/src/org/aspectj/systemtest/AllTests18.java +++ b/tests/src/org/aspectj/systemtest/AllTests18.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013 Contributors + * Copyright (c) 2013, 2014 Contributors * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -16,12 +16,14 @@ import junit.framework.TestSuite; import org.aspectj.systemtest.ajc180.AllTestsAspectJ180; import org.aspectj.systemtest.ajc181.AllTestsAspectJ181; import org.aspectj.systemtest.ajc182.AllTestsAspectJ182; +import org.aspectj.systemtest.ajc183.AllTestsAspectJ183; public class AllTests18 { public static Test suite() { TestSuite suite = new TestSuite("AspectJ System Test Suite - 1.8"); // $JUnit-BEGIN$ + suite.addTest(AllTestsAspectJ183.suite()); suite.addTest(AllTestsAspectJ182.suite()); suite.addTest(AllTestsAspectJ181.suite()); suite.addTest(AllTestsAspectJ180.suite()); diff --git a/tests/src/org/aspectj/systemtest/ajc183/Ajc183Tests.java b/tests/src/org/aspectj/systemtest/ajc183/Ajc183Tests.java index 80541fc0f..3c0257115 100644 --- a/tests/src/org/aspectj/systemtest/ajc183/Ajc183Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc183/Ajc183Tests.java @@ -21,9 +21,17 @@ import org.aspectj.testing.XMLBasedAjcTestCase; */ public class Ajc183Tests extends org.aspectj.testing.XMLBasedAjcTestCase { - public void testAnnoStyleDecp_442425() { - runTest("anno style decp"); + public void testAbstractAspectNPE_444398() { + runTest("abstract aspect npe"); } + +// public void testVerifyError_443447() { +// runTest("verifyerror"); +// } +// +// public void testAnnoStyleDecp_442425() { +// runTest("anno style decp"); +// } // --- diff --git a/tests/src/org/aspectj/systemtest/ajc183/ajc183.xml b/tests/src/org/aspectj/systemtest/ajc183/ajc183.xml index 5a77148b7..35bdca396 100644 --- a/tests/src/org/aspectj/systemtest/ajc183/ajc183.xml +++ b/tests/src/org/aspectj/systemtest/ajc183/ajc183.xml @@ -2,6 +2,11 @@ + + + + + @@ -22,4 +27,9 @@ --> + + + + + -- 2.39.5