Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4904617

JVM_Read needs better documentation

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • tbd
    • 5.0
    • hotspot
    • None
    • generic
    • generic

      The hotspot and j2se workspaces both contain a copy of jvm.h.
      (These two files have been diverging. That should probably be fixed.)

      In both of these files, JVM_Read() is documented like this:

      /*
       * Read data from a file decriptor into a char array.
       *
       * fd the file descriptor to read from.
       * buf the buffer where to put the read data.
       * nbytes the number of bytes to read.
       *
       * This function returns -1 on error, and 0 on success.
       */
      JNIEXPORT jint JNICALL
      JVM_Read(jint fd, char *buf, jint nbytes);


      This documentation needs fixing in the following ways:

      - This function actually appears to return:
        the number of bytes read, or JVM_IO_ERR, or JVM_IO_INTR

      - A maintainer of j2se native code needs guidance regarding the following:

        - When should one use JVM_Read() instead of native read()?

        - How should a caller deal with interrupted system calls?
          Apparently the right thing to do is to use something like this
          (completely untested):


      jint JVM_RestartingRead(jint fd, char *buf, jint nbytes)
      {
          jint n;
          do { n = JVM_Read(fd, buf, nbytes); }
          while (n == JVM_IO_ERR && errno == EINTR);
          return n;
      }

        Perhaps the above function should be made part of the JVM interface?

        - How should a caller deal with JVM_IO_INTR?
          This is extremely tricky, especially given the confusion
          with EINTR.

      - "decriptor" typo.
      ###@###.### 2003-08-11

            Unassigned Unassigned
            martin Martin Buchholz
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: