2008/11/26 Gili <[EMAIL PROTECTED]> > > The main thing I like about Johan's approach is that it maintains full > backwards compatibility with the original class. There is no magic. > You are invoking the original constructors and everything works as > expected. >
except that your redefined class is actually incompatible with the original class because they exist in different classloader spaces - the only way you could use instances of the mocked class alongside the original would be if you cast them to a superclass or interface perhaps I'm reading it wrongly - but how is the bytecode manipulation not magic? > Using Sun's hidden API to construct objects without invoking their > constructors is part of the magic I'd like to do away with. which hidden API is this? I've written my own basic proxies in the past with ASM, they just initialize the superclass via the "<init>" method - and afaik there is no reason why a proxy couldn't call a non-default constructor in fact... checking javassist, I see they also support non-default constructors: http://www.csg.is.titech.ac.jp/~chiba/javassist/html/javassist/util/proxy/ProxyFactory.html#create(java.lang.Class[],%20java.lang.Object[]) so serialization and non-default constructors are technically possible - just as it would also be possible to copy annotations onto the proxy class (given time!) PS: Sun is beta-testing changes to ClassLoader in Java7 so now would > be a really good time to request enhancements in this space if you've > got any. > > Gili > > On Nov 25, 5:27 am, Esko Luontola <[EMAIL PROTECTED]> wrote: > > On Nov 25, 10:29 am, Gili <[EMAIL PROTECTED]> wrote: > > > > > - requiring no-op constructors > > > > I assume that you are referring to the fact a CGLIB proxy calls the > > constructor of its superclass, which means that the class being > > proxied (unless only interfaces are proxied) must have an accessible > > constructor, possibly even a default constructor. > > > > I need to overcome this limitation of requiring an accessible default > > constructor for one project of mine, so I'll be modifying CGLIB so > > that it ignores the superclass's constructors. I have posted a proof > > of concept at the the issue which is tracking this feature request: > http://sourceforge.net/tracker/index.php?func=detail&aid=2070600&grou... > > > > Would this feature be useful for Guice? > > > -- 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 -~----------~----~----~----~------~----~------~--~---
