From: Andy Clement Date: Wed, 5 Nov 2014 16:27:45 +0000 (-0800) Subject: Fix 449739: support is(FinalType) X-Git-Tag: V1_8_4~2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=11fba64f400694713cc6571c97e194eaf3b99f40;p=aspectj.git Fix 449739: support is(FinalType) --- diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PatternParser.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PatternParser.java index 6bcb4ce4a..106376aad 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PatternParser.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/PatternParser.java @@ -1064,6 +1064,8 @@ public class PatternParser { typeIsPattern = new TypeCategoryTypePattern(TypeCategoryTypePattern.ENUM); } else if (category.equals("AnnotationType")) { typeIsPattern = new TypeCategoryTypePattern(TypeCategoryTypePattern.ANNOTATION); + } else if (category.equals("FinalType")) { + typeIsPattern = new TypeCategoryTypePattern(TypeCategoryTypePattern.FINAL); } } if (typeIsPattern == null) { diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/TypeCategoryTypePattern.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/TypeCategoryTypePattern.java index 9f565b20d..72efea400 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/TypeCategoryTypePattern.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/TypeCategoryTypePattern.java @@ -14,6 +14,7 @@ package org.aspectj.weaver.patterns; import java.io.IOException; +import java.lang.reflect.Modifier; import java.util.Map; import org.aspectj.util.FuzzyBoolean; @@ -40,6 +41,7 @@ public class TypeCategoryTypePattern extends TypePattern { public static final int ANONYMOUS = 5; public static final int ENUM = 6; public static final int ANNOTATION = 7; + public static final int FINAL = 8; private int category; @@ -104,6 +106,7 @@ public class TypeCategoryTypePattern extends TypePattern { writeLocation(s); } + @SuppressWarnings("unused") public static TypePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException { int version = s.readInt(); int category = s.readInt(); @@ -131,6 +134,8 @@ public class TypeCategoryTypePattern extends TypePattern { return type.isEnum(); case ANNOTATION: return type.isAnnotation(); + case FINAL: + return Modifier.isFinal(type.getModifiers()); } return false; } diff --git a/tests/bugs184/449739/Code.java b/tests/bugs184/449739/Code.java new file mode 100644 index 000000000..452c1d730 --- /dev/null +++ b/tests/bugs184/449739/Code.java @@ -0,0 +1,20 @@ +public class Code { + public static void main(String[] argv) { + new Code().run(); + } + + public void run() { + new Code2().run(); + } +} + +final class Code2 { + public void run() { + } +} + +aspect X { + before(): execution(* (!is(FinalType)).run(..)) { + System.out.println(thisJoinPointStaticPart); + } +} diff --git a/tests/bugs184/449739/Code2.java b/tests/bugs184/449739/Code2.java new file mode 100644 index 000000000..1ad0fee50 --- /dev/null +++ b/tests/bugs184/449739/Code2.java @@ -0,0 +1,20 @@ +public class Code2 { + public static void main(String[] argv) { + new Code2().run(); + } + + public void run() { + new Helper().run(); + } +} + +final class Helper { + public void run() { + } +} + +aspect X { + before(): execution(* (is(FinalType)).run(..)) { + System.out.println(thisJoinPointStaticPart); + } +} diff --git a/tests/src/org/aspectj/systemtest/ajc184/Ajc184Tests.java b/tests/src/org/aspectj/systemtest/ajc184/Ajc184Tests.java index 7ba5654ab..7e1265a0b 100644 --- a/tests/src/org/aspectj/systemtest/ajc184/Ajc184Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc184/Ajc184Tests.java @@ -97,6 +97,15 @@ public class Ajc184Tests extends org.aspectj.testing.XMLBasedAjcTestCase { // abstract aspects runTest("thisAspectInstance - 15"); } + + public void testIsFinal_449739() { + runTest("is final"); + } + + public void testIsFinal_449739_2() { + runTest("is final - 2"); + } + // --- public static Test suite() { diff --git a/tests/src/org/aspectj/systemtest/ajc184/ajc184.xml b/tests/src/org/aspectj/systemtest/ajc184/ajc184.xml index 01d4d2312..3010ce169 100644 --- a/tests/src/org/aspectj/systemtest/ajc184/ajc184.xml +++ b/tests/src/org/aspectj/systemtest/ajc184/ajc184.xml @@ -133,6 +133,24 @@ + + + + + + + + + + + + + + + + + +