0
에서 제네릭 메서드를 가져 오는 것은 리플렉션을 통해 제네릭 클래스에서 일반 (매개 변수화 된) 메서드를 가져올 수 있습니까? 내가 제네릭을 실행하면Java reflection - 비 제너릭 클래스
public interface GenericInterface<T> {
public T publicMethod(T arg);
}
public class NonGenericClassWithGenericMethods {
private <T> void privateMethod(GenericInterface<T> arg) {
}
}
public class Generics {
public static void main(String[] args) {
try {
NonGenericClassWithGenericMethods.class.getMethod("privateMethod", GenericInterface.class).setAccessible(true);
}
catch(Exception ex) {
ex.printStackTrace();
}
}
}
, 내가 얻을 : 여기에 내가 무엇을 원하는 샘플의
java.lang.NoSuchMethodException : NonGenericClassWithGenericMethods.privateMethod (GenericInterface)
고마워요
고맙습니다! 나는 그것이 단지 가시성의 문제라고 알아 차림으로써 타입 지우기에 너무 집중되어있다. :) – lencinhaus