summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Clement <andrew.clement@gmail.com>2012-07-10 10:18:35 -0700
committerAndy Clement <andrew.clement@gmail.com>2012-07-10 10:18:35 -0700
commitbf949d3260232dd69a5fd3a2b81a19cb3dd1a6a6 (patch)
treea128790e3b29e568bc3044ae9ef6cf2c1162b315
parent5d0e1860cb5069b266ba70d33bc356d36e285a90 (diff)
downloadaspectj-bf949d3260232dd69a5fd3a2b81a19cb3dd1a6a6.tar.gz
aspectj-bf949d3260232dd69a5fd3a2b81a19cb3dd1a6a6.zip
384398: some fixes for generics/itds/inner classes
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java31
-rwxr-xr-xtests/bugs171/pr384398/A.java9
-rwxr-xr-xtests/bugs171/pr384398/B.java13
-rwxr-xr-xtests/bugs171/pr384398/BAspect.aj15
-rwxr-xr-xtests/bugs171/pr384398_2/A.java9
-rwxr-xr-xtests/bugs171/pr384398_2/B.java14
-rwxr-xr-xtests/bugs171/pr384398_2/BAspect.aj16
-rw-r--r--tests/src/org/aspectj/systemtest/AllTests17.java2
-rw-r--r--tests/src/org/aspectj/systemtest/ajc171/Ajc171Tests.java43
-rw-r--r--tests/src/org/aspectj/systemtest/ajc171/AllTestsAspectJ171.java25
-rw-r--r--tests/src/org/aspectj/systemtest/ajc171/ajc171.xml37
11 files changed, 213 insertions, 1 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java
index ae2d2d04e..154746fa4 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseFactory.java
@@ -273,7 +273,17 @@ public class EclipseFactory {
// pr168044 - sometimes (whilst resolving types) we are working with 'half finished' types and so (for example) the
// underlying generic type for a raw type hasnt been set yet
// if (!baseType.isGenericType() && arguments!=null) baseType = baseType.getGenericType();
- baseTypeSignature = baseType.getErasureSignature();
+// pr384398 - secondary testcase in 1.7.1 tests - this needs work as this code
+// currently discards the parameterization on the outer type, which is important info
+// ReferenceBinding enclosingTypeBinding = ptb.enclosingType();
+// if (enclosingTypeBinding!=null) {
+// UnresolvedType ttt = fromBinding(enclosingTypeBinding);
+// baseTypeSignature = ttt.getSignature();
+// baseTypeSignature= baseTypeSignature.substring(0,baseTypeSignature.length()-1);
+// baseTypeSignature = baseTypeSignature + "."+new String(ptb.sourceName)+";";
+// } else {
+ baseTypeSignature = baseType.getErasureSignature();
+// }
} else {
baseTypeSignature = UnresolvedType.forName(getName(binding)).getSignature();
}
@@ -283,6 +293,10 @@ public class EclipseFactory {
// be type variables that we haven't fixed up yet.
if (arguments == null) {
arguments = new UnresolvedType[0];
+ // for pr384398
+ if (!hasAnyArguments(ptb)) {
+ return UnresolvedType.forRawTypeName(getName(binding));
+ }
}
// StringBuffer parameterizedSig = new StringBuffer();
// parameterizedSig.append(ResolvedType.PARAMETERIZED_TYPE_IDENTIFIER);
@@ -331,6 +345,21 @@ public class EclipseFactory {
}
/**
+ * Search up a parameterized type binding for any arguments at any level.
+ */
+ private boolean hasAnyArguments(ParameterizedTypeBinding ptb) {
+ if (ptb.arguments!=null && ptb.arguments.length>0) {
+ return true;
+ }
+ ReferenceBinding enclosingType = ptb.enclosingType();
+ if (enclosingType instanceof ParameterizedTypeBinding) {
+ return hasAnyArguments((ParameterizedTypeBinding)enclosingType);
+ } else {
+ return false;
+ }
+ }
+
+ /**
* Some type variables refer to themselves recursively, this enables us to avoid recursion problems.
*/
private static Map typeVariableBindingsInProgress = new HashMap();
diff --git a/tests/bugs171/pr384398/A.java b/tests/bugs171/pr384398/A.java
new file mode 100755
index 000000000..bc79f0699
--- /dev/null
+++ b/tests/bugs171/pr384398/A.java
@@ -0,0 +1,9 @@
+package de.example;
+
+public class A<T> {
+ public static class InnerA{
+
+ }
+
+
+}
diff --git a/tests/bugs171/pr384398/B.java b/tests/bugs171/pr384398/B.java
new file mode 100755
index 000000000..4673547a0
--- /dev/null
+++ b/tests/bugs171/pr384398/B.java
@@ -0,0 +1,13 @@
+package de.example;
+
+public class B extends A<String> {
+/*
+ InnerA someMethod(){
+ return new InnerA();
+ }
+
+ InnerA someOtherMethod(){
+ return someMethod();
+ }
+*/
+}
diff --git a/tests/bugs171/pr384398/BAspect.aj b/tests/bugs171/pr384398/BAspect.aj
new file mode 100755
index 000000000..2a580f238
--- /dev/null
+++ b/tests/bugs171/pr384398/BAspect.aj
@@ -0,0 +1,15 @@
+package de.example;
+
+import de.example.A.InnerA;
+
+public aspect BAspect {
+
+ InnerA B.someMethod(){
+ return new InnerA();
+ }
+
+ InnerA B.someOtherMethod(){
+ return someMethod();
+ }
+
+}
diff --git a/tests/bugs171/pr384398_2/A.java b/tests/bugs171/pr384398_2/A.java
new file mode 100755
index 000000000..9b7049050
--- /dev/null
+++ b/tests/bugs171/pr384398_2/A.java
@@ -0,0 +1,9 @@
+package de.example;
+
+public class A<T> {
+ public class InnerA {
+ T aaa;
+ }
+
+
+}
diff --git a/tests/bugs171/pr384398_2/B.java b/tests/bugs171/pr384398_2/B.java
new file mode 100755
index 000000000..3e3868445
--- /dev/null
+++ b/tests/bugs171/pr384398_2/B.java
@@ -0,0 +1,14 @@
+package de.example;
+
+public class B extends A<String> {
+/*
+ InnerA someMethod(){
+ A<String> as = new A<String>();
+ return as.new InnerA();
+ }
+
+ InnerA someOtherMethod() {
+ return someMethod();
+ }
+*/
+}
diff --git a/tests/bugs171/pr384398_2/BAspect.aj b/tests/bugs171/pr384398_2/BAspect.aj
new file mode 100755
index 000000000..fcba89b39
--- /dev/null
+++ b/tests/bugs171/pr384398_2/BAspect.aj
@@ -0,0 +1,16 @@
+package de.example;
+
+import de.example.A.InnerA;
+
+public aspect BAspect {
+
+ InnerA B.someMethod(){
+ A<String> as = new A<String>();
+ return as.new InnerA();
+ }
+
+ InnerA B.someOtherMethod(){
+ return someMethod();
+ }
+
+}
diff --git a/tests/src/org/aspectj/systemtest/AllTests17.java b/tests/src/org/aspectj/systemtest/AllTests17.java
index f026ae59a..37a02c350 100644
--- a/tests/src/org/aspectj/systemtest/AllTests17.java
+++ b/tests/src/org/aspectj/systemtest/AllTests17.java
@@ -7,12 +7,14 @@ import junit.framework.Test;
import junit.framework.TestSuite;
import org.aspectj.systemtest.ajc170.AllTestsAspectJ170;
+import org.aspectj.systemtest.ajc171.AllTestsAspectJ171;
public class AllTests17 {
public static Test suite() {
TestSuite suite = new TestSuite("AspectJ System Test Suite - JDK 1.7");
// $JUnit-BEGIN$
+ suite.addTest(AllTestsAspectJ171.suite());
suite.addTest(AllTestsAspectJ170.suite());
suite.addTest(AllTests16.suite());
suite.addTest(AllTests15.suite());
diff --git a/tests/src/org/aspectj/systemtest/ajc171/Ajc171Tests.java b/tests/src/org/aspectj/systemtest/ajc171/Ajc171Tests.java
new file mode 100644
index 000000000..17c8ea4f5
--- /dev/null
+++ b/tests/src/org/aspectj/systemtest/ajc171/Ajc171Tests.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andy Clement - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.systemtest.ajc171;
+
+import java.io.File;
+
+import junit.framework.Test;
+
+import org.aspectj.testing.XMLBasedAjcTestCase;
+
+/**
+ * @author Andy Clement
+ */
+public class Ajc171Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
+
+ public void testGenerics_384398() {
+ runTest("generics itds");
+ }
+
+// public void testGenerics_384398_2() {
+// runTest("generics itds 2");
+// }
+
+ // ---
+
+ public static Test suite() {
+ return XMLBasedAjcTestCase.loadSuite(Ajc171Tests.class);
+ }
+
+ @Override
+ protected File getSpecFile() {
+ return new File("../tests/src/org/aspectj/systemtest/ajc171/ajc171.xml");
+ }
+
+}
diff --git a/tests/src/org/aspectj/systemtest/ajc171/AllTestsAspectJ171.java b/tests/src/org/aspectj/systemtest/ajc171/AllTestsAspectJ171.java
new file mode 100644
index 000000000..78e321b84
--- /dev/null
+++ b/tests/src/org/aspectj/systemtest/ajc171/AllTestsAspectJ171.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andy Clement - initial API and implementation
+ *******************************************************************************/
+package org.aspectj.systemtest.ajc171;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTestsAspectJ171 {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite("AspectJ 1.7.1 tests");
+ // $JUnit-BEGIN$
+ suite.addTest(Ajc171Tests.suite());
+ // $JUnit-END$
+ return suite;
+ }
+}
diff --git a/tests/src/org/aspectj/systemtest/ajc171/ajc171.xml b/tests/src/org/aspectj/systemtest/ajc171/ajc171.xml
new file mode 100644
index 000000000..d22d2d71a
--- /dev/null
+++ b/tests/src/org/aspectj/systemtest/ajc171/ajc171.xml
@@ -0,0 +1,37 @@
+<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]>
+
+<suite>
+
+ <ajc-test dir="bugs171/pr384398" title="generics itds">
+ <compile files="A.java B.java BAspect.aj" options="-1.5">
+ <!--
+ <message kind="weave" text="Join point 'constructor-call(void java.util.LinkedList.&lt;init&gt;())' in Type 'Foo' (Foo.java:41) advised by around advice from 'Bar' (Foo.java:14)"/>
+ -->
+ </compile>
+ <!--
+ <run class="Foo">
+ <stdout>
+ <line text="superaspect getNumber returns -2"/>
+ <line text="Bar.method() running"/>
+ <line text="abstract method returns []"/>
+ </stdout>
+ </run> -->
+ </ajc-test>
+
+ <ajc-test dir="bugs171/pr384398_2" title="generics itds 2">
+ <compile files="A.java B.java BAspect.aj" options="-1.5">
+ <!--
+ <message kind="weave" text="Join point 'constructor-call(void java.util.LinkedList.&lt;init&gt;())' in Type 'Foo' (Foo.java:41) advised by around advice from 'Bar' (Foo.java:14)"/>
+ -->
+ </compile>
+ <!--
+ <run class="Foo">
+ <stdout>
+ <line text="superaspect getNumber returns -2"/>
+ <line text="Bar.method() running"/>
+ <line text="abstract method returns []"/>
+ </stdout>
+ </run> -->
+ </ajc-test>
+
+</suite>