summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Clement <andrew.clement@gmail.com>2012-09-19 10:19:17 -0700
committerAndy Clement <andrew.clement@gmail.com>2012-09-19 10:19:17 -0700
commitb9c7a190f452cf888854e4fa6599269a5a2c0212 (patch)
treeb68bf4923bfd122c2933f2f0502d9119647d9de1
parent6cae3ed57c66d0659492ab1d12bc42cc10ad6f71 (diff)
downloadaspectj-b9c7a190f452cf888854e4fa6599269a5a2c0212.tar.gz
aspectj-b9c7a190f452cf888854e4fa6599269a5a2c0212.zip
389750: fix for ITDs that use generics made on generic types
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AstUtil.java37
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java14
-rw-r--r--tests/bugs172/pr389750/Clazz.java5
-rw-r--r--tests/bugs172/pr389750/Clazz2.java9
-rw-r--r--tests/bugs172/pr389750/Clazz3.java9
-rw-r--r--tests/bugs172/pr389750/Clazz4.java9
-rw-r--r--tests/bugs172/pr389750/Code.aj17
-rw-r--r--tests/bugs172/pr389750/Code2.aj17
-rw-r--r--tests/bugs172/pr389750/Code3.aj17
-rw-r--r--tests/bugs172/pr389750/Code4.aj17
-rw-r--r--tests/src/org/aspectj/systemtest/AllTests17.java2
-rw-r--r--tests/src/org/aspectj/systemtest/ajc172/Ajc172Tests.java51
-rw-r--r--tests/src/org/aspectj/systemtest/ajc172/AllTestsAspectJ172.java25
-rw-r--r--tests/src/org/aspectj/systemtest/ajc172/ajc172.xml29
14 files changed, 258 insertions, 0 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AstUtil.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AstUtil.java
index 23c874795..369e84c51 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AstUtil.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AstUtil.java
@@ -30,6 +30,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ReturnStatement;
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.SingleNameReference;
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Statement;
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
+import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeParameter;
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference;
import org.aspectj.org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.aspectj.org.eclipse.jdt.internal.compiler.codegen.CodeStream;
@@ -43,6 +44,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Scope;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeIds;
+import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
import org.aspectj.weaver.AjAttribute;
import org.aspectj.weaver.patterns.WildTypePattern;
@@ -251,6 +253,41 @@ public class AstUtil {
System.arraycopy(rest, 0, ret, 1, len);
return ret;
}
+
+ public static TypeParameter[] insert(TypeParameter first, TypeParameter[] rest) {
+ if (rest == null) {
+ return new TypeParameter[]{first};
+ }
+ int len = rest.length;
+ TypeParameter[] ret = new TypeParameter[len + 1];
+ ret[0] = first;
+ System.arraycopy(rest, 0, ret, 1, len);
+ return ret;
+ }
+
+ public static TypeVariableBinding[] insert(TypeVariableBinding first, TypeVariableBinding[] rest) {
+ if (rest == null) {
+ return new TypeVariableBinding[]{first};
+ }
+ int len = rest.length;
+ TypeVariableBinding[] ret = new TypeVariableBinding[len + 1];
+ ret[0] = first;
+ System.arraycopy(rest, 0, ret, 1, len);
+ return ret;
+ }
+
+ public static TypeVariableBinding[] insert(TypeVariableBinding[] first, TypeVariableBinding[] rest) {
+ if (rest == null) {
+ TypeVariableBinding[] ret = new TypeVariableBinding[first.length];
+ System.arraycopy(first, 0, ret, 0, first.length);
+ return ret;
+ }
+ int len = rest.length;
+ TypeVariableBinding[] ret = new TypeVariableBinding[first.length+len];
+ System.arraycopy(first,0,ret,0,first.length);
+ System.arraycopy(rest,0,ret,first.length,len);
+ return ret;
+ }
public static Expression[] insert(Expression first, Expression[] rest) {
if (rest == null) {
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java
index aabcc19c0..a5632e498 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java
@@ -22,6 +22,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult;
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Argument;
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.LocalDeclaration;
+import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeParameter;
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference;
import org.aspectj.org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.aspectj.org.eclipse.jdt.internal.compiler.codegen.CodeStream;
@@ -36,6 +37,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TagBits;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
+import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
import org.aspectj.org.eclipse.jdt.internal.compiler.parser.Parser;
import org.aspectj.org.eclipse.jdt.internal.compiler.problem.AbortCompilationUnit;
import org.aspectj.weaver.AjAttribute;
@@ -93,6 +95,18 @@ public class InterTypeMethodDeclaration extends InterTypeDeclaration {
if (!Modifier.isStatic(declaredModifiers)) {
this.arguments = AstUtil.insert(AstUtil.makeFinalArgument("ajc$this_".toCharArray(), onTypeBinding), this.arguments);
binding.parameters = AstUtil.insert(onTypeBinding, binding.parameters);
+
+ // If the inserted argument is a generic type, we should include the associated type variables to ensure
+ // the generated signature is correct (it will be checked by eclipse when this type is consumed in binary form).
+ TypeVariableBinding onTypeTVBs[] = onTypeBinding.typeVariables();
+ if (onTypeTVBs!=null && onTypeTVBs.length!=0) {
+ // The type parameters don't seem to need to be correct
+ // TypeParameter tp = new TypeParameter();
+ // tp.binding = tvb[0];
+ // tp.name = tvb[0].sourceName;
+ // this.typeParameters = AstUtil.insert(tp,this.typeParameters);
+ binding.typeVariables = AstUtil.insert(onTypeBinding.typeVariables(), binding.typeVariables);
+ }
}
super.resolve(upperScope);
diff --git a/tests/bugs172/pr389750/Clazz.java b/tests/bugs172/pr389750/Clazz.java
new file mode 100644
index 000000000..7d32d1206
--- /dev/null
+++ b/tests/bugs172/pr389750/Clazz.java
@@ -0,0 +1,5 @@
+public class Clazz {
+ public static void main(String[] argv) {
+ Code.foo();
+ }
+}
diff --git a/tests/bugs172/pr389750/Clazz2.java b/tests/bugs172/pr389750/Clazz2.java
new file mode 100644
index 000000000..1cf6a69c3
--- /dev/null
+++ b/tests/bugs172/pr389750/Clazz2.java
@@ -0,0 +1,9 @@
+public class Clazz2 {
+ public static void main(String[] argv) {
+ Bar bs = new Bar();
+ String s = bs.bar("abc",null);
+ }
+}
+
+class Bar implements Code2.I<String> {
+}
diff --git a/tests/bugs172/pr389750/Clazz3.java b/tests/bugs172/pr389750/Clazz3.java
new file mode 100644
index 000000000..372c64567
--- /dev/null
+++ b/tests/bugs172/pr389750/Clazz3.java
@@ -0,0 +1,9 @@
+public class Clazz3 {
+ public static void main(String[] argv) {
+ Bar<String> bs = new Bar<String>();
+ String s = bs.bar("abc",null);
+ }
+}
+
+class Bar<A extends java.io.Serializable> implements Code3.I<A> {
+}
diff --git a/tests/bugs172/pr389750/Clazz4.java b/tests/bugs172/pr389750/Clazz4.java
new file mode 100644
index 000000000..cc077abdc
--- /dev/null
+++ b/tests/bugs172/pr389750/Clazz4.java
@@ -0,0 +1,9 @@
+public class Clazz4 {
+ public static void main(String[] argv) {
+ Bar<String> bs = new Bar<String>();
+ String s = bs.bar("abc",new Integer(4));
+ }
+}
+
+class Bar<A extends java.io.Serializable> implements Code4.I<A> {
+}
diff --git a/tests/bugs172/pr389750/Code.aj b/tests/bugs172/pr389750/Code.aj
new file mode 100644
index 000000000..353a61af2
--- /dev/null
+++ b/tests/bugs172/pr389750/Code.aj
@@ -0,0 +1,17 @@
+import java.io.*;
+
+interface Persistable<ID extends Serializable> {
+
+}
+
+public aspect Code {
+
+ public interface I<ID extends Serializable> extends Persistable<ID> {
+ }
+
+ public static void foo() {}
+
+ public boolean I.equals(Persistable<?> that) {
+ return false;
+ }
+}
diff --git a/tests/bugs172/pr389750/Code2.aj b/tests/bugs172/pr389750/Code2.aj
new file mode 100644
index 000000000..b9d43519f
--- /dev/null
+++ b/tests/bugs172/pr389750/Code2.aj
@@ -0,0 +1,17 @@
+import java.io.*;
+
+interface Persistable<ID extends Serializable> {
+
+}
+
+public aspect Code2 {
+
+ public interface I<ID extends Serializable> extends Persistable<ID> {
+ }
+
+ public static void foo() {}
+
+ public Z I<Z>.bar(Z foo, Persistable<?> that) {
+ return foo;
+ }
+}
diff --git a/tests/bugs172/pr389750/Code3.aj b/tests/bugs172/pr389750/Code3.aj
new file mode 100644
index 000000000..ba30b7f69
--- /dev/null
+++ b/tests/bugs172/pr389750/Code3.aj
@@ -0,0 +1,17 @@
+import java.io.*;
+
+interface Persistable<ID extends Serializable> {
+
+}
+
+public aspect Code3 {
+
+ public interface I<ID extends Serializable> extends Persistable<ID> {
+ }
+
+ public static void foo() {}
+
+ public Z I<Z>.bar(Z foo, Persistable<?> that) {
+ return foo;
+ }
+}
diff --git a/tests/bugs172/pr389750/Code4.aj b/tests/bugs172/pr389750/Code4.aj
new file mode 100644
index 000000000..cc10d351e
--- /dev/null
+++ b/tests/bugs172/pr389750/Code4.aj
@@ -0,0 +1,17 @@
+import java.io.*;
+
+interface Persistable<ID extends Serializable> {
+
+}
+
+public aspect Code4 {
+
+ public interface I<ID extends Serializable> extends Persistable<ID> {
+ }
+
+ public static void foo() {}
+
+ public <T> Z I<Z>.bar(Z foo, T that) {
+ return foo;
+ }
+}
diff --git a/tests/src/org/aspectj/systemtest/AllTests17.java b/tests/src/org/aspectj/systemtest/AllTests17.java
index 447ab1d51..9384d501c 100644
--- a/tests/src/org/aspectj/systemtest/AllTests17.java
+++ b/tests/src/org/aspectj/systemtest/AllTests17.java
@@ -8,12 +8,14 @@ import junit.framework.TestSuite;
import org.aspectj.systemtest.ajc170.AllTestsAspectJ170;
import org.aspectj.systemtest.ajc171.AllTestsAspectJ171;
+import org.aspectj.systemtest.ajc172.AllTestsAspectJ172;
public class AllTests17 {
public static Test suite() {
TestSuite suite = new TestSuite("AspectJ System Test Suite - 1.7");
// $JUnit-BEGIN$
+ suite.addTest(AllTestsAspectJ172.suite());
suite.addTest(AllTestsAspectJ171.suite());
suite.addTest(AllTestsAspectJ170.suite());
suite.addTest(AllTests16.suite());
diff --git a/tests/src/org/aspectj/systemtest/ajc172/Ajc172Tests.java b/tests/src/org/aspectj/systemtest/ajc172/Ajc172Tests.java
new file mode 100644
index 000000000..0ad0af282
--- /dev/null
+++ b/tests/src/org/aspectj/systemtest/ajc172/Ajc172Tests.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * 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.ajc172;
+
+import java.io.File;
+
+import junit.framework.Test;
+
+import org.aspectj.testing.XMLBasedAjcTestCase;
+
+/**
+ * @author Andy Clement
+ */
+public class Ajc172Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
+
+ public void testInconsistentClassFile_pr389750() {
+ runTest("inconsistent class file");
+ }
+
+ public void testInconsistentClassFile_pr389750_2() {
+ runTest("inconsistent class file 2");
+ }
+
+ public void testInconsistentClassFile_pr389750_3() {
+ runTest("inconsistent class file 3");
+ }
+
+ public void testInconsistentClassFile_pr389750_4() {
+ runTest("inconsistent class file 4");
+ }
+
+ // ---
+
+ public static Test suite() {
+ return XMLBasedAjcTestCase.loadSuite(Ajc172Tests.class);
+ }
+
+ @Override
+ protected File getSpecFile() {
+ return new File("../tests/src/org/aspectj/systemtest/ajc172/ajc172.xml");
+ }
+
+}
diff --git a/tests/src/org/aspectj/systemtest/ajc172/AllTestsAspectJ172.java b/tests/src/org/aspectj/systemtest/ajc172/AllTestsAspectJ172.java
new file mode 100644
index 000000000..b79cc40fa
--- /dev/null
+++ b/tests/src/org/aspectj/systemtest/ajc172/AllTestsAspectJ172.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.ajc172;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTestsAspectJ172 {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite("AspectJ 1.7.2 tests");
+ // $JUnit-BEGIN$
+ suite.addTest(Ajc172Tests.suite());
+ // $JUnit-END$
+ return suite;
+ }
+}
diff --git a/tests/src/org/aspectj/systemtest/ajc172/ajc172.xml b/tests/src/org/aspectj/systemtest/ajc172/ajc172.xml
new file mode 100644
index 000000000..c88e5abf6
--- /dev/null
+++ b/tests/src/org/aspectj/systemtest/ajc172/ajc172.xml
@@ -0,0 +1,29 @@
+<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]>
+
+<suite>
+
+ <ajc-test dir="bugs172/pr389750" title="inconsistent class file">
+ <compile files="Code.aj" options="-1.5">
+ </compile>
+ <compile files="Clazz.java" options="-1.5"/>
+ </ajc-test>
+
+ <ajc-test dir="bugs172/pr389750" title="inconsistent class file 2">
+ <compile files="Code2.aj" outjar="azpect.jar" options="-1.5">
+ </compile>
+ <compile files="Clazz2.java" aspectpath="azpect.jar" options="-1.5"/>
+ </ajc-test>
+
+ <ajc-test dir="bugs172/pr389750" title="inconsistent class file 3">
+ <compile files="Code3.aj" outjar="azpect.jar" options="-1.5">
+ </compile>
+ <compile files="Clazz3.java" aspectpath="azpect.jar" options="-1.5"/>
+ </ajc-test>
+
+ <ajc-test dir="bugs172/pr389750" title="inconsistent class file 4">
+ <compile files="Code4.aj" outjar="azpect.jar" options="-1.5">
+ </compile>
+ <compile files="Clazz4.java" aspectpath="azpect.jar" options="-1.5"/>
+ </ajc-test>
+
+</suite>