Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


#2 Make Dynamic Objects work with any class

Chris Nokleberg

I didn't really want to subscribe to the dev list, and
you don't have any forums, so I hope you find my
message this way :-)

I'm a developer with cglib.sf.net. It uses bcel to
dynamically create classes at runtime, for a variety of
use cases. If you switched your dynamic Mock class to
use cglib instead of java.lang.reflect.Proxy, you could:

- be compatible with JDK 1.2
- mock almost any class (must have a non-private
constructor, and private or final methods cannot be mocked)
- perhaps realize a speed increase (creation of
object is slower, but method invocations are faster)

I'll probably be using mock objects more soon, so I
might do this anyway, but if you are interested let me
know, I can point you in the right direction.

chris at sixlegs dot com


  • Logged In: YES

    I agree with this, and it would be pretty easy to slide in,
    perhaps as an optional dependency. This would significantly
    enhance the utility of DynaMock. (Great already though!) I
    already have a hacked version that does this; I bet several
    other people do also.

  • Mark Walker
    Mark Walker

    Logged In: YES

    I am conflicted about this: whereas I sympathise with the
    desire to make the project java 1.2 compatible, and would like
    the flexibility to be able to mock a broader range of classes, I
    am hesitant about the idea to introduce a dependency on a
    3rd party library, rather than on the JDK.

    If, as steve molitor says, it would be an optional feature - full
    steam ahead.