From ee2a860fcdf78383350e33c2a1d16be814e30f83 Mon Sep 17 00:00:00 2001 From: aclement Date: Fri, 28 Nov 2008 20:44:35 +0000 Subject: [PATCH] 256937: test and fix --- tests/bugs163/pr256937/Ship.java | 5 +++ tests/bugs163/pr256937/ShipAccessor.java | 14 ++++++++ .../systemtest/ajc163/Ajc163Tests.java | 34 +++++++++++++++++++ .../org/aspectj/systemtest/ajc163/ajc163.xml | 4 +++ 4 files changed, 57 insertions(+) create mode 100644 tests/bugs163/pr256937/Ship.java create mode 100644 tests/bugs163/pr256937/ShipAccessor.java diff --git a/tests/bugs163/pr256937/Ship.java b/tests/bugs163/pr256937/Ship.java new file mode 100644 index 000000000..866271b22 --- /dev/null +++ b/tests/bugs163/pr256937/Ship.java @@ -0,0 +1,5 @@ +public class Ship { + public void moveTo(int newX, int newY) { + this.h(); + } +} diff --git a/tests/bugs163/pr256937/ShipAccessor.java b/tests/bugs163/pr256937/ShipAccessor.java new file mode 100644 index 000000000..c1f0e5280 --- /dev/null +++ b/tests/bugs163/pr256937/ShipAccessor.java @@ -0,0 +1,14 @@ +public privileged aspect ShipAccessor { + + + + + + + + + public java.util.List Ship.h() { + return null; + } +} + diff --git a/tests/src/org/aspectj/systemtest/ajc163/Ajc163Tests.java b/tests/src/org/aspectj/systemtest/ajc163/Ajc163Tests.java index 6107200df..48b904560 100644 --- a/tests/src/org/aspectj/systemtest/ajc163/Ajc163Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc163/Ajc163Tests.java @@ -11,6 +11,8 @@ package org.aspectj.systemtest.ajc163; import java.io.File; +import java.util.Iterator; +import java.util.List; import junit.framework.Test; @@ -18,11 +20,43 @@ import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.apache.bcel.classfile.LocalVariable; import org.aspectj.apache.bcel.classfile.LocalVariableTable; import org.aspectj.apache.bcel.classfile.Method; +import org.aspectj.asm.AsmManager; +import org.aspectj.asm.IHierarchy; +import org.aspectj.asm.IProgramElement; import org.aspectj.testing.Utils; import org.aspectj.testing.XMLBasedAjcTestCase; public class Ajc163Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + public void testFQType_pr256937() { + runTest("fully qualified return type"); + IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy(); + IProgramElement itd = findElementAtLine(top.getRoot(), 10); + String type = itd.getCorrespondingType(true); + assertEquals("java.util.List", type); + } + + private IProgramElement findElementAtLine(IProgramElement whereToLook, int line) { + if (whereToLook == null) { + return null; + } + if (whereToLook.getSourceLocation() != null && whereToLook.getSourceLocation().getLine() == line) { + return whereToLook; + } + List kids = whereToLook.getChildren(); + for (Iterator iterator = kids.iterator(); iterator.hasNext();) { + IProgramElement object = (IProgramElement) iterator.next(); + if (object.getSourceLocation() != null && object.getSourceLocation().getLine() == line) { + return object; + } + IProgramElement gotSomething = findElementAtLine(object, line); + if (gotSomething != null) { + return gotSomething; + } + } + return null; + } + public void testParameterAnnotationsOnITDs_pr256669() { // regular itd runTest("parameter annotations on ITDs"); } diff --git a/tests/src/org/aspectj/systemtest/ajc163/ajc163.xml b/tests/src/org/aspectj/systemtest/ajc163/ajc163.xml index ac29d0aa3..a35e25473 100644 --- a/tests/src/org/aspectj/systemtest/ajc163/ajc163.xml +++ b/tests/src/org/aspectj/systemtest/ajc163/ajc163.xml @@ -2,6 +2,10 @@ + + + + -- 2.39.5