This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [cp-patches] [RFA/JDWP] ReferenceKey


On Fri, 2005-06-17 at 14:47 -0500, Archie Cobbs wrote:
> Coupla questions. Disclaimer: I haven't really been paying attention,
> so ignore me if these are stupid irrelevant..

Nothing is irrelevant: I'm a Java newbie.

> - Could java.util.WeakHashMap be used instead of writing your own?
>    See java.lang.VMString.intern() for an example.

Yeah, that's a good question. Originally, I wrote this thing using a
Hashtable and SoftReferences, and the tables contained different
mappings of various things.

Now, however, the id manager has two tables for object types. One which
maps this ReferenceKey to its corresponding ObjectId (which contains a
SoftReference to the original object). The other is a table which maps
from a numerical ID to the ObjectId.

So, in fact, it does look like I could use a WeakHashMap to do this. I
presume their should be no problem in the value of the WeakHashMap
containing an object with a WeakReference to the Object, right? [Sorry,
all this strong, soft, weak, phantom, unreachable stuff is a little new
to me.]

> - Do you mean to use hashCode()/equals() or System.identityHashCode()/==?

WeakHashMap discussion aside, I needed to be able to compare two keys
for identity in two ways: one to match the Object and one to match
actual keys.

I think I just implemented some sort of hacky WeakHashMap!

I'll take a look changing to WeakHashMap to see what it does.

Thanks for the note!
Keith


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]