I generally do not know how to make a file offline, which will always be blocked when reading.
If I tried to find the stack trace when a certain function was called, I would run the program under the debugger and set a breakpoint for this function. Although the control points of the method slow down your program and give you different results than usual if time is important.
If you have access to the source code of the program, you can create a fake FileInputStream that extends the real one, but always blocks reading. All you have to do is disable import instructions throughout the code. However, this will not lead to a capture of places where you cannot turn off import instructions, and it can be painful if there is a lot of code.
If you want to use your own FileInputStream without changing the source code of the program or compilation, you can create a custom class loader that loads your own FileInputStream class instead of the real one. You can specify which class loader to use on the command line:
java -Djava.system.class.loader=com.test.MyClassLoader xxx
Now, when I think about it, I have an even better idea, instead of creating a custom FileInputStream that blocks read (), create your own FileInputStream that displays stack traces on read (). The custom class can then call the real version of read (). This way you get all the stack traces for all calls.
Ofnothing
source share