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

portability : A Java long is not necessarily a scalar type in C

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.2.0
    • 1.2.0
    • hotspot
    • 1.2beta2
    • sparc
    • solaris_2.5.1
    • Not verified

      A Java long is not necessarily a scalar type in C
      --------------------------------------------
      Not all C compilers support native 64-bit integers.
      They may have to use a structure:
      e.g.
      int64_t x;
      This means that casting a Java long to a pointer for
      example inside some C code may not succeed.
      E.g.
      >From src/win32/javavm/runtime/jvmdi_md.c:
            case SUSPENDED: {
              struct javaframe *currFrame;
              ExecEnv* thread_ee = (ExecEnv *)unhand(h)->eetop;
              if ((thread_ee != 0) &&
                  ((currFrame = thread_ee->current_frame) != 0) &&
                  (currFrame->lastpc != 0) &&
      >From /src/share/jvm/runtime/debug.c
      static void
      threadDumpInfoLocked(TID tid, bool_t verbose)
      {
          int priority;
          jio_fprintf(stderr, " %s",
                      Object2CString((JHandle *) THREAD(tid)->name));
          if (verbose == TRUE) {
              ExecEnv *ee = (ExecEnv *)THREAD(tid)->eetop;
              sys_thread_t *t = ee ? EE2SysThread(ee) : 0;


      But eetop is declared a Java long, so is an int64_t, which can be a structure,
      so
      can not be cast to a pointer.

      Perhaps accessing a pointer in this fashion should be isolated in a macro.
      I am not sure when happens on an AS/400 which uses 16 byte pointers.

      The code should at least use ll2ptr and ptr2ll macros.

            apalanissunw Anand Palaniswamy (Inactive)
            miflemi Mick Fleming
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: