How to disable code deletion in the Java compiler?

This may seem like a strange question ... Why does anyone want to disable such a thing? But I know what I'm doing (and why I want / should do it), and I really want to disable dead code removal.

Is it possible somehow?

I use Eclipse, by the way, if it's relevant ...

+4
source share
3 answers

Is it possible somehow?

I have not come across any method for this. It seems that there are no corresponding options.

But, to be clear, eliminating dead code could (potentially) be done by either one of both bytecode compilers or JIT. Therefore, you need to clearly indicate in which case you are concerned. (I think this is a bytecode compiler ...)

+1
source

The first thought that popped into my head was to write some crazy aspect and use compilation in time so that your dead code is no longer dead ... but then my head exploded.

0
source

I would advise you to think again and try to achieve your goal in some other way. What you are trying to do looks like a hack, and even if you succeed, you will never be sure that the mechanism for saving dead code still works.

0
source

Source: https://habr.com/ru/post/1314504/


All Articles