Java Spike: Dynamic Proxies

Motivation

It'd be nice to have a concise way to delegate all or a large collection of method calls to another object in Java. Something like the doesNotUnderstand: method that's available in Smalltalk would be nice, but Java is statically typed. However, you can dynamically create an implementation of an interface. Your call into that dynamic implementation is forwarded to an "InvocationHandler" that has a different method declaration that receives the call details as parameters. 

Features

DemoProxy.java creates a java.lang.reflect.Proxy that implements an interface called DemoProxyFunction. All that does is declare a method called evaluate that takes two int values and returns an int. Our InvocationHandler implementation in DemoProxy implements addition behind that interface.