0

Hi all,

I have two Java Classes as follows :

public class A {
public int a =5;
}

and --

public class B {
public static void main(String[] args) {
System.out.println(new A().a);
}

}

Now i want to generate a log file (when the execution of main() method of class B ends) which tells me that "THE VARIABLE NAMED 'a' OF CLASS 'A' IS ACCESSED ONCE" .

PLEASE NOTE THAT I DON'T HAVE PERMISSION TO MODIFY THE SOURCE CODE OF EXISTING CLASS ..

So please tell me how to proceed to get the solution ..

Thanks.
Ganesh

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by ganesh.guddu
0

PLEASE NOTE THAT I DON'T HAVE PERMISSION TO MODIFY THE SOURCE CODE OF EXISTING CLASS ..

So please tell me how to proceed to get the solution ..

If you can't modify the source code of class A or class B, then what are you allowed to do?

0

I will have to write my own application and hook it in existing apps (something similar to what debugger does ). In the Case of Private variable i have getters / setters. so i have instrumented those getter/setter to get its access log. But in the case of a public variable i am not able to decide even how to proceed .

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.