Exclude a specific class method from java compilation

I want to exclude a specific class method from java compilation.

For instance,

class Test { public void printdouble(){} public void printint(){} } 

Depending on some properties, I want to exclude the printdouble method at compile time.

NOTE. I am using ant script to compile java

Thanks in Advance Soman

+4
source share
3 answers

To do this, you need to use the conditional compilation form.

Here's a tutorial on how to do this with Ant.

+3
source

If you explain why you are trying to exclude this method, we can offer a better solution that does not involve preprocessing, code generation, or other β€œhacker” approaches.

+2
source

The only way to achieve this in Java is with some form of code generation or templating that generates the source code and then Ant compiles it.

If you describe what you want to execute, you can find a more β€œJava” way to execute it.

+1
source

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


All Articles