[fpc-devel] Updated FPC JVM snapshot
Jonas Maebe
jonas.maebe at elis.ugent.be
Mon Nov 7 15:42:33 CET 2011
On 07 Nov 2011, at 09:21, Michael.VanCanneyt at Wisa.be wrote:
> I have been looking at the JVM backend, and noticed that file I/O is
> not
> working. I'm asking what is needed to get write(ln) or read(ln)
> working.
One thing I forgot to mention: threadvars. They are already supported
and work (should work) at the same as on other platforms, but it is
not possible to automatically run code whenever a thread is started.
The way this is solved in Java is actually quite good, I think:
threadvars are descendants of the java.lang.ThreadLocal class, and
whenever you call the get() method of such an instance for the first
time in a particular thread, its initialValue() method is called to
determine the initial value of the threadvar in the current thread.
This means that threadvars are only initialized when necessary, and
you can easily add the required initialization code separately for
every threadvar as needed.
The problem is that we don't have a Pascal language-level construct
that maps to this mechanism (on other FPC targets, the initialization
of system unit threadvars for I/O etc happens via some RTL-internal
routines that we call whenever a new thread is registered with the
RTL), and I'm not yet sure how to solve that.
Jonas
More information about the fpc-devel
mailing list