- JDK now fully support 64-bit with the new jdk version 1.4.1 with option -d64
- JDK has changed the definition of jinit from 1.1.8 than 1.2.2 onwards
JDK sizeof(jint)
32bit 64bit
------ ------- --------
1.1.8 long long
1.2.2 int32_t int32_t
1.3.1_02 int long
1.4.1_06 int int
- This wasn't noticable before jdk 1.4.1 as the 64 option wasn't exist, there was just 32-bit option
- When compiling using the default, the behaviour using jdk 1.4.1 is the same as 118, 1.2.2, 1.3.1
- When compiling using -d64 the problem occurs.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
To prove this problem, test the file provided below against jdk 1.1.8, 1.2.2, 1.3.1, and 1.4.1
files to be used
============
file: test.c
#include <jni.h>
int main (void)
{
int i =500000;
fprintf (stdout, "sizeof (jint): %d\n", sizeof (jint));
fflush (stdout);
printf("i = %l\n",i);
return 0;
}
------------------------------------------------
file: jdk.118 to set the environemt to jdk 118
-------------------
setenv JAVA_HOME /usr/java_1.1.8
setenv PATH $JAVA_HOME/bin/:${PATH}
-------------------------------------------------
file: jdk.140
---------------
setenv JAVA_HOME /usr/j2sdk1.4.0_01
setenv PATH $JAVA_HOME/bin/:${PATH}
-----------------------------------------------
file cc.sh
------------
/opt/SUNWspro6u1/bin/cc -I$JAVA_HOME/include -I$JAVA_HOME/include/solaris -xO3 -Xa -xstrconst -dalign -xF -mr -xildoff -errtags=yes -v -xarch=v9 -xchip=ultra3 -W2,-AKNR_S -Wd,-xsafe=unboundsym -Wc,-Qiselect-funcalign=32 -xcode=abs44 -Wc,-Qgsched-trace_late=1 -Wc,-Qgsched-T5 -xalias_level=weak -D_REENTRANT -DSS_64BIT_SERVER -DBIT64 -DMACHINE64 -DSLMXMX_ENABLE -DSLTS_ENABLE -D_SVID_GETTOD -D_REENTRANT -o test test.c
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expected jint has the same size in all jdk versions.
ACTUAL -
----------------------------
testing jdk 1.1.8
---------------------
$source jdk.118
sh -x cc.sh
./test
test result
---------------
sizeof (jint): 8
testing jdk140
-------------------
$source jdk.140
sh -x cc.sh
./test
test result
--------------
sizeof (jint): 4
REPRODUCIBILITY :
This bug can be reproduced always.
- JDK has changed the definition of jinit from 1.1.8 than 1.2.2 onwards
JDK sizeof(jint)
32bit 64bit
------ ------- --------
1.1.8 long long
1.2.2 int32_t int32_t
1.3.1_02 int long
1.4.1_06 int int
- This wasn't noticable before jdk 1.4.1 as the 64 option wasn't exist, there was just 32-bit option
- When compiling using the default, the behaviour using jdk 1.4.1 is the same as 118, 1.2.2, 1.3.1
- When compiling using -d64 the problem occurs.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
To prove this problem, test the file provided below against jdk 1.1.8, 1.2.2, 1.3.1, and 1.4.1
files to be used
============
file: test.c
#include <jni.h>
int main (void)
{
int i =500000;
fprintf (stdout, "sizeof (jint): %d\n", sizeof (jint));
fflush (stdout);
printf("i = %l\n",i);
return 0;
}
------------------------------------------------
file: jdk.118 to set the environemt to jdk 118
-------------------
setenv JAVA_HOME /usr/java_1.1.8
setenv PATH $JAVA_HOME/bin/:${PATH}
-------------------------------------------------
file: jdk.140
---------------
setenv JAVA_HOME /usr/j2sdk1.4.0_01
setenv PATH $JAVA_HOME/bin/:${PATH}
-----------------------------------------------
file cc.sh
------------
/opt/SUNWspro6u1/bin/cc -I$JAVA_HOME/include -I$JAVA_HOME/include/solaris -xO3 -Xa -xstrconst -dalign -xF -mr -xildoff -errtags=yes -v -xarch=v9 -xchip=ultra3 -W2,-AKNR_S -Wd,-xsafe=unboundsym -Wc,-Qiselect-funcalign=32 -xcode=abs44 -Wc,-Qgsched-trace_late=1 -Wc,-Qgsched-T5 -xalias_level=weak -D_REENTRANT -DSS_64BIT_SERVER -DBIT64 -DMACHINE64 -DSLMXMX_ENABLE -DSLTS_ENABLE -D_SVID_GETTOD -D_REENTRANT -o test test.c
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expected jint has the same size in all jdk versions.
ACTUAL -
----------------------------
testing jdk 1.1.8
---------------------
$source jdk.118
sh -x cc.sh
./test
test result
---------------
sizeof (jint): 8
testing jdk140
-------------------
$source jdk.140
sh -x cc.sh
./test
test result
--------------
sizeof (jint): 4
REPRODUCIBILITY :
This bug can be reproduced always.