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.
--------------------------------------------
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.
- relates to
-
JDK-4296917 portability : VM assumes jlong is a scalar type
-
- Open
-