Nikhil C. Khedkar wrote:
Hi Erik and Andrew, Finally able to get this thing fixed. Here's the approach I have followed (Just for everyone's information).
1)Firstly detect that a method is constructor from its name "<init>". 2)Put a try catch block. 3)Take care to skip super() calls which should be the first line in the constructor. [Andrew won't agree with this. He has indeed provided me with some code, but I think my assumption is true for normal Sun javac compiler. Andrew please confirm] 4)Now the approach to find super() call and distinguish it from an explict new() call. Scan all the instructions in the constructor from 0 onwards. Keep a counter initialized at 0. Increment the counter when you encounter a NEW instruction. Decrement it when you encounter a INVOKESPECIAL (that's how you create an object). When this counter becomes negative, you have encountered a super() call. When this counter becomes 0, its the new() call. [Thanks Eric]
That's all.
Thanks, Nikhil Khedkar
-- "I say to you that the VCR is to the American film producer and the American public as the Boston strangler is to the woman home alone." -Jack Valenti, President, Motion Picture Association of America, Inc., before The House Subcommittee on Courts, Civil Liberties, and The Administration of Justice, August, 1982, http://cryptome.org/hrcw-hear.htm
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
