On Wed, Feb 18, 2004 at 04:34:02AM -0800, Nikhil C. Khedkar wrote:
> I think I am nearing the solution. Yes I can check if
> teh INVOKESPECIAL is of some super class. Just have
> one more problem now. What if I instantiate the super
> class in the constructor by a new statement? How can I
> distinguish super() from new(). Both the INVOKESPECIAL
> are exactly the same. The only hope now is the DUP
> instruction. My assumption is DUP is inserted whenever
> new() is used in the code? Am I right?
I think you are wrong. If the statement is:
new Myclass();
Doesn't need to keep the reference to the new object around
so why should it do a dup?
Why look for the dup instruction when you can look for the
'new' instruction?
> If the answer
> is yes, then I can distinguish super() from new().
I guess if you want a 100% solution you have to trace
where the objects come from so that you can see whether
the object that you are calling init on is the first
parameter or whether it comes from a call to new.
Alternatively (not 100% but probably works in practice):
Have a counter that starts at 0. Scan the instructions
linearly. When you hit a new instruction increment it. When
you hit a call to <init> decrement it. If it goes negative
then you have found the correct call to the superclass of
the constructor. If it never goes negative there is no call.
Do some sanity checking to make sure the constructor call
you have found has the right type.
I wonder what the verifier does.
--
Erik Corry I'd be a Libertarian, if they weren't all a
[EMAIL PROTECTED] bunch of tax-dodging professional whiners. - B. Breathed.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]