Skip to content

Demonstrate and fix a bug with JDK proxies.#5

Open
binkley wants to merge 2 commits into
99soft:masterfrom
binkley:master
Open

Demonstrate and fix a bug with JDK proxies.#5
binkley wants to merge 2 commits into
99soft:masterfrom
binkley:master

Conversation

@binkley

@binkley binkley commented Oct 28, 2013

Copy link
Copy Markdown

Apologies for import reordering!

I found and fixed a subtle bug with AbstractMethodTypeListener. JDK proxies come in two flavors:

  1. Proxies of private interfaces adopt the package they are in (or that of their enclosing scope if an inner class)
  2. Proxies of public interfaces get a magical package depending on JDK implementation, and getPackage() returns null for their class

The second type throws an NPE in hear() from a method invocation chain which includes getPackage(). The fix was trivial, and I included a test case.

See http://docs.oracle.com/javase/7/docs/api/java/lang/reflect/Proxy.html.

@binkley

binkley commented Jan 5, 2014

Copy link
Copy Markdown
Author

This also applies to top-level classes (no package).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant