람다가 참조하는 클래스 및 정적 메서드 이름을 프로그래밍 방식으로 읽을 수 있습니까? 예를 들어 :람다가 참조하는 클래스 및 정적 메서드 이름 얻기
public class Testing {
interface Generic { void call(); }
static public void method1() {
System.out.println("In method1");
}
static public void method2() {
System.out.println("In method2");
}
public void test() {
Generic g1 =() -> Testing.method1();
Generic g2 =() -> Testing.method2();
g1.call();
g2.call();
// System.out.println("g1 -> " + getLambdaReference(g1))
}
어떻게 든 그 g1
이 Testing.method1
가리키는 및 g2
이 Test.method2
가리키는 읽고 싶습니다.
하지만'g1'은 "Testing.method1'을 가리키고 있지 않습니다." 'Generic g1 =() -> {Testing.method1(); Testing.method2(); };'? – Tunaki
물론이 특수한 경우에 관심이 있습니다. 직접 알아 보려고하는 간접적 인 방법이 있는지 궁금합니다. –
Nope. 그건 불가능하다. – aioobe