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

int with only highest order bit set not converted to boolean correctly

    XMLWordPrintable

Details

    Description

      The following test fails:

      in libTestBool.c:

          int get_bool() {
              return 0x80000000;
          }

      In TestBool.java:

          Addressable ma = findNativeOrThrow("get_bool");
          FunctionDescriptor fd = FunctionDescriptor.of(C_BOOL);

          MethodHandle GET_BOOL = LINKER.downcallHandle(ma, fd);
          boolean result = (boolean) GET_BOOL.invokeExact();
          assertTrue(result);

      It seems that, even though the value of the int is non-zero, it is not converted to a boolean correctly (according to C rules).

      Attachments

        Activity

          People

            jvernee Jorn Vernee
            jvernee Jorn Vernee
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: