Fixed a bug using proxies with the JDK API, found by DanielAdolfsson