Re: Constructor Instrumentation : super()
"Nikhil C. Khedkar" <[email protected]>
| Newsgroups | gmane.comp.jakarta.bcel.devel,gmane.comp.jakarta.bcel.user |
|---|---|
| Message-ID | <[email protected]> |
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? If the answer is yes, then I can distinguish super() from new(). - Nikhil --- Erik Corry <[email protected]> wrote: > On Wed, Feb 18, 2004 at 02:14:20AM -0800, Nikhil C. > Khedkar wrote: > > Well no peoblem with detecting the constructor. > The > > approach you have mentioned is not full proof. In > my > > constructor I have the following code, few lines > down > > the line > > > > if (!(type == MAINUI || type == PROJECTWIZARD)) > > { > > throw new RuntimeException("Invalid type"); > > } > > > > Even this chap has INVOKESPECIAL and I end up > skipping > > some of the lines and in fact this line also, if I > use > > your approach, which I had already tried. > > If you do "getClassName" in the INVOKESPECIAL > instruction does > that tell you the class that we are calling? Or > should we > be using a different function. The documentation > is a little > sparse... > > http://jakarta.apache.org/bcel/apidocs/org/apache/bcel/generic/FieldOrMethod.html#getClassType(org.apache.bcel.generic.ConstantPoolGen) > > (linked from > http://jakarta.apache.org/bcel/apidocs/org/apache/bcel/generic/INVOKESPECIAL.html > ) > > -- > 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] > __________________________________ Do you Yahoo!? Yahoo! Mail SpamGuard - Read only the mail you want. http://antispam.yahoo.com/tools