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

Recommended Answers

All 2 Replies

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?

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 .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.