rfgamaral
rfgamaral

Reputation: 16842

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 really want to disable dead code elimination.

Is it possible somehow?

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

Upvotes: 4

Views: 1570

Answers (3)

Illarion Kovalchuk
Illarion Kovalchuk

Reputation: 5894

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.

Upvotes: 0

bwawok
bwawok

Reputation: 15357

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.

Upvotes: 0

Stephen C
Stephen C

Reputation: 719279

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 ...)

Upvotes: 1

Related Questions