Hi,
I'm unfortunately forced to contend with the following admittedly strange issue...
I need to somehow save a reference to an object as a string, and later access the object from this string-ified reference. Perhaps an example would be best:
I've also tried
String s = Integer.toHexString(this.hashCode());
So obviously this is wrong, and I get cast exception errors.
I suspect (but don't know for sure) that the
Object.toString() method preserves information that can be used to reaccess an instantiated object, such as the name and hash info... so:
1) what exactly is the nature of the "Object.hashCode()" data? Does it have anything to do with the address of the object in memory?
2) Is this possible? I think it should be in principle - to be able to cast such a string to an object if all appropriate info (address and type) are available...
3) What about reference counting? If I save the string containing this info (hashCode and type), will the reference count on the object I've "string-ified" be maintained? I.e., will the object not "destruct", if nobody else has a reference to it?
Thanks - I know this is a bit esoteric but unfortunately it's something I've got to contend with (XML is involved, and some other things as well)...
Thanks - help *truly* appreciated!!!
![Smile :) :)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
dora
I'm unfortunately forced to contend with the following admittedly strange issue...
I need to somehow save a reference to an object as a string, and later access the object from this string-ified reference. Perhaps an example would be best:
Code:
String s = this.toString(); //"this" is of type "Class"
...
( (Class)s ).ClassMethod();
I've also tried
String s = Integer.toHexString(this.hashCode());
So obviously this is wrong, and I get cast exception errors.
I suspect (but don't know for sure) that the
Object.toString() method preserves information that can be used to reaccess an instantiated object, such as the name and hash info... so:
1) what exactly is the nature of the "Object.hashCode()" data? Does it have anything to do with the address of the object in memory?
2) Is this possible? I think it should be in principle - to be able to cast such a string to an object if all appropriate info (address and type) are available...
3) What about reference counting? If I save the string containing this info (hashCode and type), will the reference count on the object I've "string-ified" be maintained? I.e., will the object not "destruct", if nobody else has a reference to it?
Thanks - I know this is a bit esoteric but unfortunately it's something I've got to contend with (XML is involved, and some other things as well)...
Thanks - help *truly* appreciated!!!
dora