[Bug 158] New: JNI jlong weirdness on ARM
[email protected] Mon, 7 Nov 2005 11:27:15 -0500
| Newsgroups | gmane.comp.java.vm.sablevm.bugs |
|---|---|
| Message-ID | <[email protected]> |
http://sablevm.org/bugs/show_bug.cgi?id=158
Summary: JNI jlong weirdness on ARM
Product: SableVM
Version: unspecified
Platform: Other
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: default
AssignedTo: [email protected]
ReportedBy: [email protected]
QAContact: [email protected]
jlong types exhibit a weird behaviour when "transferred" to Java code from a JNI
library in ARM, although they are correctly interpreted on the native C code. I
can't reproduce the bug on an x86 box.
This is SableVM 1.12 running on an ARM920TID (S32410) processor.
Example code follows:
HelloWorld.java:
class HelloWorld {
public native long displayHelloWorld();
static {
System.loadLibrary("hello");
}
public static void main(String[] args) {
long foo = new HelloWorld().bar();
System.out.println("Java: " + foo);
}
}
HelloWorld.h:
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class HelloWorld */
#ifndef _Included_HelloWorld
#define _Included_HelloWorld
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: HelloWorld
* Method: displayHelloWorld
* Signature: ()J
*/
JNIEXPORT jlong JNICALL Java_HelloWorld_bar
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif
HelloWorldImpl.c:
#include <jni.h>
#include "HelloWorld.h"
#include <stdio.h>
JNIEXPORT long long JNICALL
Java_HelloWorld_bar(JNIEnv *env, jobject obj)
{
jlong result = 0;
printf("native: %lld\n", result);
return result;
}
This code displays:
$ java -Djava.library.path=. HelloWorld
native: 0
Java: 356447925829632
The difference between C value and Java value is 0x1443000000000 (I don't know
if it's relevant)
I can't find the exact portion of code that interprets a native value into a
Java value so I could substract this value to every jlong returned by a JNI call.
This only affects jlong values. jint, jbyteArray et al work as expected.
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
You are the QA contact for the bug, or are watching the QA contact.