Dynamic Proxies for Classes: Towards Type-Safe and Decoupled Remote Object Interaction

A dynamic proxy object is a typed proxy, created at runtime, conforming to a type specified by the application. Such an object can be used wherever an expression of the type it was created for is expected, yet reifies all invocations performed on it. This simple but powerful concept has been introduced into Java at version 1.3 (and has later also appeared in the .NET platform). A dynamic proxy is created for a set of interfaces as an instance of a class, generated automatically on the fly without support from the Java compiler or virtual machine, implementing those interfaces. Unfortunately, dynamic proxies are only available ``for interfaces''. The case of creating dynamic proxies for a set of types including a class type, due to the increased complexity, has not been considered, meaning that it is currently not possible to create a dynamic proxy mimicking an instance of a class. We present a pragmatic approach to supporting dynamic proxies ``for classes'', building on the existing solution to dynamic proxies for interfaces. We discuss the costs of such an extension, in terms of safety, security, and performance, and illustrate its usefulness through a novel abstraction for decoupled remote interaction, unifying (implicit future) remote method invocations and (type-based) publish/subscribe.


 Record created 2005-07-13, last modified 2018-03-17

Download fulltext

Rate this document:

Rate this document:
(Not yet reviewed)