Extending/replacing a class without a public constructor

From: Hugh Beyer (beyerxyzzy_at_acm.org)
Date: 06/09/04


Date: Wed, 09 Jun 2004 13:38:42 GMT

I'm having a really frustrating problem and I hope you guys can give me some
help.

I'm trying to write a test suite for a graphics-heavy app that uses
MIDP/J2ME. These apps use the Graphics class to do their screen updates.

What I want to do is subclass the Graphics class with my own class that
captures all calls and writes to a log. Unfortunately, all the constructors
of the Graphics class are private. The system passes in a Graphics class when
it's time to update the screen, and you can create a graphics class through a
static factory method (Image.getGraphics()). But either way, I can't get in
and capture the method calls to the resulting Graphics object.

Is there any way at all to do this, or am I SOL? Can anyone think of another
way to accomplish what I want?
            
            Hugh



Relevant Pages