Patch: java/lang/Thread.h and CNI

Bryce McKinlay bryce@albatross.co.nz
Thu Sep 7 05:04:00 GMT 2000


java/lang/Thread.h contains some friend declarations that break CNI code
that tries to #include it:

  friend int _Jv_CondWait (_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *mu,
jlong millis, jint nanos);
  friend int _Jv_CondNotify (_Jv_ConditionVariable_t *cv, _Jv_Mutex_t
*mu);
  friend void _Jv_ThreadInterrupt (_Jv_Thread_t *data);

$ c++ -c `gtk-config --cflags` gnu/awt/peer/gtk/natGtkMainThread.cc -o
build/gnu/awt/peer/gtk/natGtkMainThread.o -Ibuild
/usr/local/gcc/include/java/lang/Thread.h:83: `_Jv_ConditionVariable_t'
was not declared in this scope
/usr/local/gcc/include/java/lang/Thread.h:83: `cv' was not declared in
this scope
/usr/local/gcc/include/java/lang/Thread.h:83: `_Jv_Mutex_t' was not
declared in this scope
/usr/local/gcc/include/java/lang/Thread.h:83: `mu' was not declared in
this scope
/usr/local/gcc/include/java/lang/Thread.h:83: parse error before `,'
/usr/local/gcc/include/java/lang/Thread.h:84: `_Jv_ConditionVariable_t'
was not declared in this scope
/usr/local/gcc/include/java/lang/Thread.h:84: `cv' was not declared in
this scope
/usr/local/gcc/include/java/lang/Thread.h:84: `_Jv_Mutext' was not
declared in this scope
/usr/local/gcc/include/java/lang/Thread.h:84: `mu' was not declared in
this scope
/usr/local/gcc/include/java/lang/Thread.h:84: invalid data member
initiailization
/usr/local/gcc/include/java/lang/Thread.h:84: use `=' to initialize
static data members
[...]

This solution takes advantage of the property of CNI where
package-private fields are actually mapped to public fields in C++. This
way the native threads implementation can access the interrupt_flag
without polluting the Java API. This is a bit of a hack, but the only
solution I can come up with right now: interrupt_flag must be accessible
from both the native thread implementation and the java.lang.Thread
code, and putting it inside Thread itself is the only convenient way to
do it.

I'm checking this in.

regards

  [ bryce ]



More information about the Java-patches mailing list