This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

run time value assignment to a Final and public variable.

 
Ravindra'sFanda
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My application requires that a String varibale which is declared as final , static should have value at runtime,
It definately can't be through ordinary assignment methods , probs some crack in Java can help in doing that .
Can anybody help me in doing that.

email : ravindra_gupta@satyam.com
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ravindra'sFanda:
My application requires that a String varibale which is declared as final , static should have value at runtime,
It definately can't be through ordinary assignment methods , probs some crack in Java can help in doing that .
Can anybody help me in doing that.

email : ravindra_gupta@satyam.com

How else are you going to provide a value to a variable except for normal assignment? There is no way to avoid assignment.
You might be able to get the initial value from an external source though, like a file or network stream. As long as you assign the variable one time before you start using it, it will work, and avoid having the actual value in the bytecode. However, you will still have the value in your file, or network packets, and either of those would be easier to hack than the java bytecode of your class file.
Rob
 
Sean MacLean
author
Ranch Hand
Posts: 621
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps a static initializer is what you want.


This will initialize the static String only once when the class is loaded for the first time.
Sean
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic