Look for the various *STORE instructions (ISTORE, DSTORE, FSTORE, etc.).
Also look for PUTFIELD and PUTSTATIC.

As others have pointed out, this will not help you if the fields are
modified utilizing reflection techniques.

-----Original Message-----
From: vicki kozel [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 23, 2003 12:58 PM
To: BCEL Users List
Subject: RE: help required


Thanks for the response, yes, I do try to find a way to track modifications
of local and global variables, so I'd like to find out, what are the common
instructions would be in such case - I understand that different datatypes
are loaded on the stack with different instructions, so I'll have to come up
with the listing  of instructions to look for, and then insert my own
instructions that will give me the values and names of variables under
modification. If you have any hints for me, please let me know what they are
- I would really appreciate it!
Vicki
 
 

Steven Smith <[EMAIL PROTECTED]> wrote:
Just briefly, "int a" in your example is simply a local variable, modified
by the istore instruction. If your class looked something like the
following, then you would *probably* see the putfield.

Class A
{
int a;

private void m(String s){
String b = s;
a=51;
a=1001;
}
}

-----Original Message-----
From: vicki kozel [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 23, 2003 12:18 PM
To: BCEL Users List
Subject: RE: help required


Hi,
I printed the instruction list of the following method, and I thought
putfield and putstatic would be in the list. But they aren't. I am
interested to capture a modification of a local or a global variable, like
of int a in the following method:

private void m(String s){
String b = s;
int a=51;
a=1001;
}

Here's the instruction list of the method given above:

Method is private void m(String arg0)
Instructions are : 
0: aload_1[43](1)
1: astore_2[77](1)
2: bipush[16](2) 51
4: istore_3[62](1)
5: sipush[17](3) 1001
8: istore_3[62](1)
9: return[177](1)

Any suggestions?
Thanks!
Vicki
Toby Reyelts wrote:

Hi Vicki,

1) We should be careful with our terminology here. I'm talking about using
putfield and putstatic to specifically check for modifications of _instance
and static field members_ This will always catch a write to those fields as
long as it's not through reflection - In fact, this is how JDO checks for
dirty object. I don't see how aload is going to help you here - or anywhere.

2) Somebody has already detailed an approach and problems with reflection.

3) Sorry, no.

God bless,
-Toby Reyelts

-----Original Message-----
From: vicki kozel [mailto:[EMAIL PROTECTED]
Sent: Friday, September 12, 2003 11:54 AM
To: BCEL Users List
Subject: RE: help required


Thanks a lot for the response, Toby! It is very helpful. I hope you can
answer these couple of question about your comments:
1) "you can look for the putfield and putstatic instructions"
Q. I was going to look for ALOAD instructions to spot where variables get
loaded onto stack - you suggest "putfield" and "putstatic" instead of that ?
2)"but that won't catch any modifications that occur through reflection."
Q. So, is there any way at all to find instructions related to modification
of variables through reflection?
3) Can you suggest some code examples or open source tools that do something
similar to what my task is? - I am trying to modify classfile, but not at
the run time.

Thanks a lot!
Vicki

[EMAIL PROTECTED] wrote:
First, you don't necessarily know what local variables are, unless the
original 
compiler included the line number information in the class file. If it did,
you 
could try to scan for store instructions.

Second, you can look for the putfield and putstatic instructions to see when

instance and static variables are modified, but that won't catch any 
modifications that occur through reflection.

God bless,
-Toby Reyelts
> I also was working on a simple BCEL based tool that will allow me to track
all 
> variables, global and LOCAL, at the moment when they are changed. I just
want to 
> insert instructions into the Method of profiled class to printout name and
the 
> value of a variable - local variables too! - when they are changed. Any 
> suggestions??
> thanks!!
> Vicki

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[EMAIL PROTECTED]
415-668-6967 home
415-806-9093 cell

---------------------------------
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software



[EMAIL PROTECTED]
415-668-6967 home
415-806-9093 cell

---------------------------------
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[EMAIL PROTECTED]
415-668-6967 home
415-806-9093 cell

---------------------------------
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to