• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with constants

 
Mike Rane
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am using ant to build a program. When I rebuild after having changed some constants in my program, the program still uses the old values of the constants. If I do a clean and rebuild the new values are used. How can I set things up so that I don't need to do a clean before I rebuild?
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is that if you have "final" constants, their value gets compiled into the classes that use them directly - the resulting class file does not have a reference to the class they came from. So if that final value changes in the source code, all classes that use it need to be recompiled in order to pick up the new value.
Either force a clean compile whenever you change a final constant, or don't make the constants final. A really good build tool could detect this situation automatically and recompile as necessary, but I'm not aware of one that does this.
 
Mike Rane
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic