2008/11/25 Stuart McCulloch <[EMAIL PROTECTED]> > 2008/11/25 Gili <[EMAIL PROTECTED]> > >> >> Johan Haleby brought up an interesting approach to proxing classes >> without the limitations introduced by ASM/CGLIB such as: >> >> - requiring no-op constructors >> - preventing the use of final or private methods >> - losing annotations on the original class >> >> I would love to get your opinion on it because frankly if we can get >> rid of these limitations I would be *that* much happier :) Take a >> look: >> http://groups.google.com/group/mockito/browse_thread/thread/2a85cace251eb92c >> > > FWIW, I wouldn't call this a proxy per se - this is bytecode manipulation > which requires access to the original bytes (it uses javassist to do this) >
just want to point out that javassist does provide a "ProxyFactory", but this uses the same approach as ASM/CGLIB ie. extending the given superclass and implementing the interfaces - their proxy is serializable (so proxies can in fact be serializable) ... *but* they warn that serialized proxies should only be used for short-term storage or RMI, because of migration issues FYI, their approach to serialization is to write out a special SerializedProxy instance to the object stream, in place of the proxy instance - this instance stores the superclass, interfaces, etc. in fields which it uses to recreate the proxy in readResolve() when deserializing and only works on non-interface classes... but you can easily fall back > to using standard proxies for interfaces - downside is you end up with > two approaches to maintain > > however I would be wary of calling this a 'silver' bullet because there are > several limitations wrt. bytecode manipulation (security notwithstanding) > - for example, I don't know if javassist works with custom classloaders as > used in EJB containers (and OSGi, etc.) where the original class bytes > may not be available, or where the original class may already be in-use > elsewhere in the JVM > > just warning we may be jumping from known issues into the unknown ;) > > Gili >> >> >> > > > -- > Cheers, Stuart > -- Cheers, Stuart --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "google-guice" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/google-guice?hl=en -~----------~----~----~----~------~----~------~--~---
