Skip to content

Instantly share code, notes, and snippets.

@rugi
Created September 2, 2013 02:43
Show Gist options
  • Save rugi/6408809 to your computer and use it in GitHub Desktop.
Save rugi/6408809 to your computer and use it in GitHub Desktop.
public static void main(String[] args) throws ClassNotFoundException, IOException {
ClassInfoUtil ciu = ClassUtil.getClassInfoFromClassInJar("/Users/rugi/Downloads/commons-collections-3.2.1.jar", "org/apache/commons/collections/BeanMap.class");
Method[] m = ciu.getMethods();
Constructor[] c = ciu.getConstructors();
System.out.println("--------------------");
System.out.println("Constructores:"+c.length);
for (int i = 0; i < c.length; i++) {
System.out.println(" Constructor["+i+"]");
Constructor constructor = c[i];
System.out.println(" "+constructor.getName());
Class[] parameterTypes = constructor.getParameterTypes();
System.out.println(" Parametros:"+parameterTypes.length);
for (int j = 0; j < parameterTypes.length; j++) {
Class class1 = parameterTypes[j];
System.out.println(" Parametro[" + i + "]:" + class1.getCanonicalName());
}
}
System.out.println("--------------------");
System.out.println("Metodos"+m.length);
for (int i = 0; i < m.length; i++) {
Method method = m[i];
System.out.println("---------------------------");
System.out.println(method.getName());
Class[] parameterTypes = method.getParameterTypes();
System.out.println("Parametros:");
for (int j = 0; j < parameterTypes.length; j++) {
Class class1 = parameterTypes[j];
System.out.println(" Parametro[" + i + "]:" + class1.getCanonicalName());
}
System.out.println("Tipo de retorno");
Class returnType = method.getReturnType();
System.out.println(" Return:" + returnType);
System.out.println("---------------------------");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment