hashCode(), equals(), toString()과 같은 표준 Object 메서드를 프록시하지 않는 InvocationHandler 구현을 보고합니다.

이러한 메서드를 처리하지 못하면 프록시 인스턴스에서 해당 메서드 호출 시 예기치 않은 문제가 발생할 수 있습니다.

예:


  InvocationHandler myHandler = (proxy, method, params) -> {
    System.out.println("Hello World!");
    return null;
  };
  Runnable myProxy = (Runnable) Proxy.newProxyInstance(
    Thread.currentThread().getContextClassLoader(),
    new Class[] {Runnable.class}, myHandler
  );

이 코드 스니펫은 Runnable.run() 메서드만 프록시하도록 설계되어 있습니다. 하지만 hashCode()와 같은 Object 메서드 호출 또한 프록시됩니다. 이 때문에 예를 들어 myProxyHashSet에 추가하는 경우에 NullPointerException과 같은 문제가 발생할 수 있습니다.

2020.2의 새로운 기능