• Post Reply Bookmark Topic Watch Topic
  • New Topic

Compiler Specific Method Control  RSS feed

 
Joseph Husband
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am looking for info on only including a method into compilation based on which version of compilation is used. (i.e. Have a method that is in 1.4 but not in 1.3, and I need to have the same source compiled for both versions) I am not sure if the Compile Class using JIT is going to solve my problem. Anyone have any thoughts? Thank you in advance.
 
Joel McNary
Bartender
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch, Joseph!
The short answer to your question is: I don't think you can do what you want.
The long answer:
You can mimic C's conditional compiling by using

and adjusting DEBUG as necessary. However:
1). I don't think its possible to use this to remove an entire method declaration (it still has to be syntactically correct; you can't have ifs floating around outside of methods)
2). I don't think you can detect the Java version at compile time. (Though I can think of a couple creatinve ways around this)
3). You would still need to change the source code to compile for one version or the other.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!