From 2483e609ca9c0d9f5c43b60c0f32d7b9cdf51adc Mon Sep 17 00:00:00 2001 From: aclement Date: Tue, 1 Nov 2005 11:22:49 +0000 Subject: [PATCH] test and fix for pr114343 --- tests/bugs150/pr114343/Test.java | 1 + tests/bugs150/pr114343/Test1.java | 10 +++++++++ tests/bugs150/pr114343/Test2.java | 11 ++++++++++ tests/bugs150/pr114343/TestAspect.aj | 21 +++++++++++++++++++ .../systemtest/ajc150/Ajc150Tests.java | 6 +++--- .../org/aspectj/systemtest/ajc150/ajc150.xml | 8 +++++++ weaver/src/org/aspectj/weaver/Advice.java | 13 +++++++++++- weaver/src/org/aspectj/weaver/Lint.java | 3 +++ .../aspectj/weaver/XlintDefault.properties | 2 ++ 9 files changed, 71 insertions(+), 4 deletions(-) create mode 100644 tests/bugs150/pr114343/Test.java create mode 100644 tests/bugs150/pr114343/Test1.java create mode 100644 tests/bugs150/pr114343/Test2.java create mode 100644 tests/bugs150/pr114343/TestAspect.aj diff --git a/tests/bugs150/pr114343/Test.java b/tests/bugs150/pr114343/Test.java new file mode 100644 index 000000000..1a8a201f6 --- /dev/null +++ b/tests/bugs150/pr114343/Test.java @@ -0,0 +1 @@ +public class Test {} diff --git a/tests/bugs150/pr114343/Test1.java b/tests/bugs150/pr114343/Test1.java new file mode 100644 index 000000000..3bd2195a9 --- /dev/null +++ b/tests/bugs150/pr114343/Test1.java @@ -0,0 +1,10 @@ +import java.util.*; + +public class Test1 extends Test { + Set intsSet; + + public Set foo() { + return intsSet; + } +} + diff --git a/tests/bugs150/pr114343/Test2.java b/tests/bugs150/pr114343/Test2.java new file mode 100644 index 000000000..983fc3819 --- /dev/null +++ b/tests/bugs150/pr114343/Test2.java @@ -0,0 +1,11 @@ +import java.util.*; + +public class Test2 extends Test { + Set doubSet; + + + public Set foo() { + return doubSet; + } +} + diff --git a/tests/bugs150/pr114343/TestAspect.aj b/tests/bugs150/pr114343/TestAspect.aj new file mode 100644 index 000000000..b0dcf02f3 --- /dev/null +++ b/tests/bugs150/pr114343/TestAspect.aj @@ -0,0 +1,21 @@ +import java.util.*; + +public privileged aspect TestAspect { + + pointcut p(Test t): + target(t) && + get(!public Set *Set) && + !within(TestAspect); + + Set around(Test t):p(t) { + Set s = proceed(t); + return s; + } + + public static void main(String []argv) { + + Set si = new Test1().foo(); + Set sd = new Test2().foo(); + } + +} diff --git a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java index 87d96f523..3ae36e93f 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java @@ -51,11 +51,11 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase { public void testITDCtor_pr112783() { runTest("Problem with constructor ITDs");} */ - public void testUnboundFormal_pr112027() { runTest("unexpected error unboundFormalInPC");} - public void testCCEGenerics_pr113445() { runTest("Generics ClassCastException");} + public void testUnboundFormal_pr112027() { runTest("unexpected error unboundFormalInPC");} + public void testCCEGenerics_pr113445() { runTest("Generics ClassCastException");} public void testMatthewsAspect_pr113947_1() { runTest("maws generic aspect - 1");} public void testMatthewsAspect_pr113947_2() { runTest("maws generic aspect - 2");} - + public void testFieldGet_pr114343() { runTest("field-get, generics and around advice");} public void testBadDecp_pr110788_1() { runTest("bad generic decp - 1");} public void testBadDecp_pr110788_2() { runTest("bad generic decp - 2");} diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml index a5679fb30..45096e496 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml @@ -16,6 +16,14 @@ + + + + + + + + diff --git a/weaver/src/org/aspectj/weaver/Advice.java b/weaver/src/org/aspectj/weaver/Advice.java index 07d7bc022..173d4c3f9 100644 --- a/weaver/src/org/aspectj/weaver/Advice.java +++ b/weaver/src/org/aspectj/weaver/Advice.java @@ -161,7 +161,18 @@ public abstract class Advice extends ShadowMunger { } else { ResolvedType shadowReturnType = shadow.getReturnType().resolve(world); ResolvedType adviceReturnType = getSignature().getGenericReturnType().resolve(world); - if(!shadowReturnType.isAssignableFrom(adviceReturnType)) { + + if (shadowReturnType.isParameterizedType() && adviceReturnType.isRawType()) { // Set and Set + ResolvedType shadowReturnGenericType = shadowReturnType.getGenericType(); // Set + ResolvedType adviceReturnGenericType = adviceReturnType.getGenericType(); // Set + if (shadowReturnGenericType.isAssignableFrom(adviceReturnGenericType) && + world.getLint().uncheckedAdviceConversion.isEnabled()) { + world.getLint().uncheckedAdviceConversion.signal( + new String[]{shadow.toString(),shadowReturnType.getName(),adviceReturnType.getName()}, + shadow.getSourceLocation(), + new ISourceLocation[]{getSourceLocation()}); + } + } else if(!shadowReturnType.isAssignableFrom(adviceReturnType)) { //System.err.println(this + ", " + sourceContext + ", " + start); world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.INCOMPATIBLE_RETURN_TYPE,shadow), diff --git a/weaver/src/org/aspectj/weaver/Lint.java b/weaver/src/org/aspectj/weaver/Lint.java index aea2432bd..5713af3f9 100644 --- a/weaver/src/org/aspectj/weaver/Lint.java +++ b/weaver/src/org/aspectj/weaver/Lint.java @@ -90,6 +90,9 @@ public class Lint { public final Kind uncheckedArgument = new Kind("uncheckedArgument","unchecked match of {0} with {1} when argument is an instance of {2} at join point {3}"); + public final Kind uncheckedAdviceConversion = + new Kind("uncheckedAdviceConversion","unchecked conversion when advice applied at shadow {0}, expected {1} but advice uses {2}"); + public Lint(World world) { this.world = world; } diff --git a/weaver/src/org/aspectj/weaver/XlintDefault.properties b/weaver/src/org/aspectj/weaver/XlintDefault.properties index 826ee911a..3f14de786 100644 --- a/weaver/src/org/aspectj/weaver/XlintDefault.properties +++ b/weaver/src/org/aspectj/weaver/XlintDefault.properties @@ -11,6 +11,8 @@ unmatchedSuperTypeInCall = warning canNotImplementLazyTjp = warning +uncheckedAdviceConversion = warning + needsSerialVersionUIDField = ignore brokeSerialVersionCompatibility = ignore -- 2.39.5