classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Another Classpath / Kissme incompatibility


From: Casey Marshall
Subject: Re: Another Classpath / Kissme incompatibility
Date: Fri, 25 Apr 2003 15:37:56 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20030303

Stephen Crawley wrote:
Folks,

Recent changes to FileDescriptor.java / FileDescriptor.c in Classpath
have broken the Kissme VM bootstrap sequence.  I checked in some Kissme
changes a few minutes ago, but you will also need to apply the patches
below to your Classpath tree.

-- Steve


This doesn't fix it for me with JikesRVM. Namely GetStaticMethodID returns NULL (but GetMethodID(env, clazz, "<init>", "(J)V") doesn't, oddly), and ExceptionCheck is apparently unimplemented.

This patch seems to work for me, but I'm not sure if this is the way the initialization should be done (i.e. it assigns in, out, and err invalid FileDescriptors first, then the nativeInit() method fills in their correct nativeFd values).

I'm no JNI expert, so this could be wrong.

--
Casey Marshall || address@hidden
Index: java/io/FileDescriptor.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/io/FileDescriptor.java,v
retrieving revision 1.15
diff -u -r1.15 FileDescriptor.java
--- java/io/FileDescriptor.java 21 Apr 2003 19:44:09 -0000      1.15
+++ java/io/FileDescriptor.java 25 Apr 2003 22:01:26 -0000
@@ -49,6 +49,28 @@
  */
 public final class FileDescriptor
 {
+
+  /**
+   * A <code>FileDescriptor</code> representing the system standard input
+   * stream.  This will usually be accessed through the 
+   * <code>System.in</code>variable.
+   */
+  public static final FileDescriptor in = new FileDescriptor();
+
+  /**
+   * A <code>FileDescriptor</code> representing the system standard output
+   * stream.  This will usually be accessed through the 
+   * <code>System.out</code>variable.
+   */
+  public static final FileDescriptor out = new FileDescriptor();
+
+  /**
+   * A <code>FileDescriptor</code> representing the system standard error
+   * stream.  This will usually be accessed through the 
+   * <code>System.err</code>variable.
+   */
+  public static final FileDescriptor err = new FileDescriptor();
+
   static
     {
       if (Configuration.INIT_LOAD_LIBRARY)
@@ -71,27 +93,6 @@
   // EXCL is used only when making a temp file.
   static final int EXCL   = 8;
   static final int SYNC   = 16;
-
-  /**
-   * A <code>FileDescriptor</code> representing the system standard input
-   * stream.  This will usually be accessed through the 
-   * <code>System.in</code>variable.
-   */
-  public static final FileDescriptor in = null;
-
-  /**
-   * A <code>FileDescriptor</code> representing the system standard output
-   * stream.  This will usually be accessed through the 
-   * <code>System.out</code>variable.
-   */
-  public static final FileDescriptor out = null;
-
-  /**
-   * A <code>FileDescriptor</code> representing the system standard error
-   * stream.  This will usually be accessed through the 
-   * <code>System.err</code>variable.
-   */
-  public static final FileDescriptor err = null;
 
   /**
    * This is the actual native file descriptor value
Index: native/jni/java-io/FileDescriptor.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/java-io/FileDescriptor.c,v
retrieving revision 1.7
diff -u -r1.7 FileDescriptor.c
--- native/jni/java-io/FileDescriptor.c 21 Apr 2003 19:44:09 -0000      1.7
+++ native/jni/java-io/FileDescriptor.c 25 Apr 2003 22:01:27 -0000
@@ -107,12 +107,11 @@
 JNIEXPORT void JNICALL
 Java_java_io_FileDescriptor_nativeInit(JNIEnv *env, jclass clazz)
 {
-  jmethodID init_method;
-  jfieldID field;
+  jfieldID field, filedes_field;
   jobject filedes;
 
-  init_method = (*env)->GetStaticMethodID (env, clazz, "<init>", "J");
-  if (! init_method)
+  filedes_field = (*env)->GetFieldID(env, clazz, "nativeFd", "J");
+  if (! filedes_field)
     return;
 
 #define INIT_FIELD(FIELDNAME, FDVALUE)                                 \
@@ -120,11 +119,11 @@
                                    "Ljava/io/FileDescriptor;");        \
   if (! field)                                                         \
     return;                                                            \
-  filedes = (*env)->NewObject (env, clazz, init_method, (jlong) FDVALUE); \
+  filedes = (*env)->GetStaticObjectField (env, clazz, field);           \
   if (! filedes)                                                       \
     return;                                                            \
-  (*env)->SetStaticObjectField (env, clazz, field, filedes);           \
-  if ((*env)->ExceptionCheck (env))                                    \
+  (*env)->SetLongField (env, filedes, filedes_field, (jlong) FDVALUE);  \
+  if ((*env)->ExceptionOccurred (env))                                 \
     return;
 
   INIT_FIELD ("in", 0);

Attachment: pgpH8pWpQF0pO.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]