我正在使用QDox解析一个.java文件。该文件包含如下所示的方法:
public int getSomething (Vector<Integer> numbers);
问题是我不知道如何使用QDox提供的反射来获取Integer类。你知道我怎么才能得到它吗?
发布于 2010-09-16 03:52:49
如果是您感兴趣的方法参数的类型,可以从该方法中获取If:
Method method = myclass.getMethod("getSomething", Vector.class);
Type atypes[] = method.getGenericParameterTypes();
if (atypes[0] instanceof ParameterizedType) {
ParameterizedType ptype = (ParameterizedType)atypes[0];
Type aatypes[] = ptype.getActualTypeArguments();
System.out.println(aatypes[0]);
}https://stackoverflow.com/questions/3720795
复制相似问题