TCLUG Development Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

tough java question



I'm writing a preprocessor of sorts for java and I have a method foo().
I have a method like so:
public void foo() {
  // do something
}
After done with the pre-parser I want to insert code into the method foo so
that if foo is overriding a method I want the first line to call super.foo(),
otherwise leave the method alone.  The trick is I don't want to have to parse
all of the super classes of the containing class.  What would be really nice
would be to insert something like this:

public void foo() {
  if(superClassMethodExists()) {
    super.foo();
  }
// do something
}

And then let it be determined at Runtime, however this won't compile unless
super.foo() does exist.

Anyone have any ideas?  I've tried some work with reflection, but that wants
to do the regular dynamic method resolution which means that foo() gets call
rather than super.foo()..

-- 
Jon Schewe 
http://eggplant.mtu.net/~jpschewe
schewe@tcfreenet.org