[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Integrating Lua with Java
- From: Christian Vogler <cvogler@...>
- Date: Mon, 21 Oct 2002 15:29:35 -0400
On Mon, Oct 21, 2002 at 12:44:55PM -0200, Roberto Ierusalimschy wrote:
> > Argh. It just occurred to me that the reason why the GC tag method is
> > never called is probably that the associated object is not a userdata
> > object, but rather a Lua table with a non-default tag. Fixing that is
> > going to be a little tricky, because the code stores stuff in the
> > table for these kinds of objects. Any ideas or takers?
> The "usual trick" is to to store a userdata in a reserved table field,
> and to use the tag method of this userdata.
Thanks for your suggestion, but it won't work without major
contortions in this particular case. The problem is that the GC needs
to remove another object from a Java hash table, a reference to which
is stored in a different field of the Lua table. As I understand it,
there is no guarantee that this field will still be accessible from
the GC tag method.
I found the germs of a simpler solution. It turns out that JDK 1.3
provides hash tables with weak keys, which - in principle - fit the
bill for what LuaJava needs to do. There are some details that I still
need to work out, but I think it will all fall into place.
This comes at the cost of raising the minimum library requirements,
but I think that JDK 1.3.x is a reasonable compromise these days.