Versions of the JDK that are compiled with a C compiler (such as GCC) that treat chars as unsigned by default cause Java programs to interpret the value of an element in a byte array incorrectly. For example, the following code snippet will take the
FAIL path:
byte[] bytearray = new byte[100];
bytearray[50] = (byte)222;
if (bytearray[50] == (byte)222)
// PASS
else
// FAIL
At first glance it appears that modifying:
typedef struct {
char body[1];
} ArrayOfByte;
typedef ArrayOfByte ClassArrayOfByte;
HandleTo(ArrayOfByte);
in src/share/java/include/oobj.h to be:
typedef struct {
signed char body[1];
} ArrayOfByte;
typedef ArrayOfByte ClassArrayOfByte;
HandleTo(ArrayOfByte);
by adding the "signed" keyword should fix this problem.
FAIL path:
byte[] bytearray = new byte[100];
bytearray[50] = (byte)222;
if (bytearray[50] == (byte)222)
// PASS
else
// FAIL
At first glance it appears that modifying:
typedef struct {
char body[1];
} ArrayOfByte;
typedef ArrayOfByte ClassArrayOfByte;
HandleTo(ArrayOfByte);
in src/share/java/include/oobj.h to be:
typedef struct {
signed char body[1];
} ArrayOfByte;
typedef ArrayOfByte ClassArrayOfByte;
HandleTo(ArrayOfByte);
by adding the "signed" keyword should fix this problem.