Monthly Archives: March 2009

Java Dynamic Proxies – equals(), hashCode(), toString()

Some meaty documentation for dynamic proxies can be found in the javadoc for java.lang.reflect.Proxy. One detail specifically called out is how calls to a proxy instance’s equals(), hashCode() and toString() are dispatched to the invocation handler. The design subtlety turns out be important and well thought-out. To understand why, it is first important to grasp [...]

Learning Java Dynamic Proxies – Basics

Java 1.3 introduced java.lang.reflect.Proxy, which allows code to dynamically implement interfaces. This is done by asking Java to create a proxy around an InvocationHandler that you define. Whenever a method on the proxy is invoked, the proxy delegates the invocation to the invocation handler. For example, the call someMethod(“arg1″, “arg2″) is invoked on proxy3 would [...]

Handy Convenience Methods with Varargs and Generic Methods

Convenient ways to instantiate genericized types, pre-populated Lists, Sets and Java arrays using varargs and generic methods. These are very useful when writing code that needs to create several collections of pre-defined content, unit tests being classic examples.

Follow

Get every new post delivered to your Inbox.