Re: instrumentation on anonymous class.

Zhongxian Gu <[email protected]>
Newsgroups gmane.comp.java.objectweb.asm
Message-ID <[email protected]>
Hi,

I just found the problem.

Seems not the problem of anonymous class, it's my programming error in
manipulating the stack.

Thanks.

Best

Zhongxian

On Tue, Nov 2, 2010 at 2:18 AM, David Brosius <[email protected]>wrote:

> the error is shown in a constructor, does the error only occur in
> constructors?
>
> your code would seem to be like this, which doesn't complain in eclipse
>
> public class Outer extends JButton {
>     public Outer() {
>         addActionListener(new ActionListener() {
>             {
>
> OuterWrapper.writeToFile(Integer.valueOf(System.identityHashCode(this)));
>             }
>
>             public void actionPerformed(ActionEvent ae) {
>             }
>         });
>     }
> }
>
> Can you post the javap of the met! hod Test$1, method: <init> signature:
> (I)V  ?
>
> *----- Original Message -----*
> *From:* "Zhongxian Gu" <[email protected]>
> *Sent:* Mon, November 1, 2010 13:15
> *Subject:* [asm] instrumentation on anonymous class.
>
>  Hi,
>
> I encountered some problems when instrument the byte code of some anonymous
> classes. The scenario is like the following,
>
> in a function call, if it is not a static function, I want to record the
> receiver of this function call, which usually be local variable 0.
>
> So my code is like the following:
>
> mv.visitVarInsn(ALOAD, 0);
> mv.visitMethodInsn(INVOKESTATIC, "java/lan! g/System", "identityHashCode",
> "(Ljava/lang/Object ;)I");
>
> mv.visitMethodInsn(INVOKESTATIC, "java/lang/Integer", "valueOf",
> "(I)Ljava/lang/Integer;");
> mv.visitMethodInsn(INVOKESTATIC, "OutputWrapper", "writeToFile",
> "(Ljava/lang/Object;)V");
>
> Is there any problem with this?
>
> I got the following exception: Exception in thread "main"
> java.lang.VerifyError: (class: Test$1, method: <init> signature: (I)V)
> Expecting to find object/array on stack
>
> Thank you guys.
>
> Best
>
> Zhongxian
> --
> Zhongxian Gu
> http://wwwcsif.cs.ucdavis.edu/~gu/ <http://wwwcsif.cs.ucdavis.edu/%7Egu/>
> Ph.D. Student in Computer Science, UC Davis
> 2249 Kemper Hall
>



-- 
Zhongxian Gu
http://wwwcsif.cs.ucdavis.edu/~gu/
Ph.D. Student in Computer Science, UC Davis
2249 Kemper Hall
message-footer.txt (text/plain, 238 B)
-- 
You receive this message as a subscriber of the [email protected] mailing list.
To unsubscribe: mailto:[email protected]
For general help: mailto:[email protected]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.