How to disable dead code elimination in the Java compiler?
This may seem a strange question... Why would anyone want to disable such a thing? But I know what I'm doing (and why I want/need to do this) and I real开发者_运维问答ly want to disable dead code elimination.
Is it possible somehow?
I use Eclipse by the way, if it's relevant...
Is it possible somehow?
I haven't come across any method for doing this. There don't seem to be any relevant options.
But to be clear, dead code elimination could (potentially) be done by either or both of the bytecode compiler and the JIT. So you need to be clear which case you are concerned about. (I guess it is the bytecode compiler ...)
The first thought that popped into my head is to write some kind of crazy aspect and use compile time weaving, so that your dead code isn't dead anymore... but then my head exploded.
I would suggest you to think again, and try to achieve your goal with some different way. What are you trying to do looks like a 'hack' and even if you succeed, you will never be sure, that your dead code retention mechanism still works.
精彩评论