Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#60 Generic types are unsupported in Methods

open
nobody
None
5
2007-03-07
2007-03-07
Anonymous
No

Code below throws NoSuchMethodError when is executed after retroweaving:
java.lang.NoSuchMethodError: java.lang.reflect.Method.getGenericParameterTypes()[Lnet/sourceforge/retroweaver/runtime/java/lang/reflect/Type;
at spikes.com.Main.main(Main.java:14)

------------------------------------------
package spikes.retroweaver;

import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.Collection;

public class Main {
private Main() {}

public static void main(String[] args) throws Exception {
Class clazz = Test.class;
Method m = clazz.getDeclaredMethod("genericMethod", new Class[] {Collection.class});
Type[] genericParameterTypes = m.getGenericParameterTypes();
for (Type type : genericParameterTypes) {
System.out.println("type: " + type.toString() + "; " + type.getClass());
}
Type genericReturnType = m.getGenericReturnType();
System.out.println("return type: " + genericReturnType.toString() + "; " + genericReturnType.getClass());
}

private static final class Test {
public Collection<Integer> genericMethod(Collection<Integer> c) { return null;}
}
}

Discussion