diff options
author | avasseur <avasseur> | 2005-07-22 14:57:40 +0000 |
---|---|---|
committer | avasseur <avasseur> | 2005-07-22 14:57:40 +0000 |
commit | 619a6adf4771e9b7a10776893583e8c5a96c0de3 (patch) | |
tree | 6d60191b90f0ec4f4e55ac13c6fb0ad856e85cc9 /tests/java5/ataspectj | |
parent | 70f83a34b8e5c1d30876facaa8772a8d1a9058bf (diff) | |
download | aspectj-619a6adf4771e9b7a10776893583e8c5a96c0de3.tar.gz aspectj-619a6adf4771e9b7a10776893583e8c5a96c0de3.zip |
fix #104212 very bad bug on static method call jp that has been around since java 1.4 is there
Diffstat (limited to 'tests/java5/ataspectj')
-rw-r--r-- | tests/java5/ataspectj/ataspectj/Bug104212.java | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/java5/ataspectj/ataspectj/Bug104212.java b/tests/java5/ataspectj/ataspectj/Bug104212.java new file mode 100644 index 000000000..d529973d6 --- /dev/null +++ b/tests/java5/ataspectj/ataspectj/Bug104212.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * Copyright (c) 2005 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 + * http://eclipse.org/legal/epl-v10.html + * + * Contributors: + * Alexandre Vasseur initial implementation + *******************************************************************************/ +package ataspectj; + +import junit.framework.TestCase; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.reflect.MethodSignature; + +/** + * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a> + */ +public class Bug104212 extends TestCase { + + static int s_i = 0; + + public static void main(String[] args) { + TestHelper.runAndThrowOnFailure(suite()); + } + + public static junit.framework.Test suite() { + return new junit.framework.TestSuite(Bug104212.class); + } + + public void testStaticMethodFromSuperClass() { + Child.doSome(); + assertEquals(1, s_i); + } + + static class Parent { + static void foo() {} + } + + static class Child extends Parent { + static void doSome() { + foo();// this is the bug + } + } + + @Aspect + public static class TestAspect { + + @Before("call(* ataspectj.Bug104212.Parent.foo()) && within(ataspectj.Bug104212.Child)") + public void before(JoinPoint jp) { + // AJ bug was here since Java 1.4... + // was: call(Bug104212.Child.foo()) + assertEquals("call(Bug104212.Parent.foo())", jp.toShortString()); + assertEquals(Parent.class, jp.getSignature().getDeclaringType()); + assertNotNull(((MethodSignature)jp.getSignature()).getMethod()); + s_i++; + } + } + +} |