Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demonstrate and fix a bug with JDK proxies. #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

binkley
Copy link

@binkley binkley commented Oct 28, 2013

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
Copy link
Author

binkley commented Jan 5, 2014

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