*
The moose likes Java in General and the fly likes run time value assignment to a Final and public variable. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "run time value assignment to a Final and public variable." Watch "run time value assignment to a Final and public variable." New topic
Author

run time value assignment to a Final and public variable.

Ravindra'sFanda
Greenhorn

Joined: Feb 06, 2002
Posts: 1
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

Joined: Jan 07, 2002
Posts: 2205
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


Rob
SCJP 1.4
Sean MacLean
author
Ranch Hand

Joined: Nov 07, 2000
Posts: 621
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: run time value assignment to a Final and public variable.