Exclude a particular method of a class from java compilation
I want to exclude a particular method of a class from java compilation.
For eg:
class Test {
public void printdouble(){}
public void printint(){}
}
Depending upon some properties, I want to exclude printdouble
method during compilation.
NOTE: I'm using ant script for java compilation
Thanks in Advan开发者_如何转开发ce Soman
You need to use a form of conditional compilation to achieve this.
Here's a tutorial on how to do it with Ant.
If you explain why you are trying to exclude the method, we can probably offer a better solution that does not involve preprocessing, code generation and other "hacky" approaches.
The only way to accomplish that in Java is some form of code generation or templating that generates the source code and then has Ant compile that.
If you describe what you want to accomplish you may find a more "Java" way to accomplish it.
精彩评论