[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Classpath build process and VM-specific issues
From: |
Etienne Gagnon |
Subject: |
Re: Classpath build process and VM-specific issues |
Date: |
Mon, 05 Apr 2004 19:07:05 -0400 |
User-agent: |
Mozilla/5.0 (X11; U; Linux ppc; en-US; rv:1.6) Gecko/20040402 Debian/1.6-4 |
Andrew Haley wrote:
malloc() returns a char*, not a jbyte*.
So, can you tell me the difference between a jbyte and a "signed char"?
Sigh. No it isn't, and this code will break with gcc.
OK, maybe I am tired and I don't see it. GCC -Wall does not complain
about the attached example.
... Also, "when a pointer to an object is converted
to a pointer to a character type, the result points to the lowest
addressed byte of the object. Successive increments of the result, up
to the size of the object, yield pointers to the remaining bytes of
the object."
We agree on this. Now: what's different between "signed char" and "jbyte"?
Can they actually be distinct on some platform?
Etienne
--
Etienne M. Gagnon, Ph.D. http://www.info.uqam.ca/~egagnon/
SableVM: http://www.sablevm.org/
SableCC: http://www.sablecc.org/
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class JNITest */
#ifndef _Included_JNITest
#define _Included_JNITest
#ifdef __cplusplus
extern "C"
{
#endif
/*
* Class: JNITest
* Method: getPtr
* Signature: ()[B
*/
JNIEXPORT jbyteArray JNICALL Java_JNITest_getPtr (JNIEnv *, jclass);
/*
* Class: JNITest
* Method: testPtr
* Signature: ([B)V
*/
JNIEXPORT void JNICALL Java_JNITest_testPtr (JNIEnv *, jclass, jbyteArray);
#ifdef __cplusplus
}
#endif
#endif
public class JNITest
{
static
{
System.loadLibrary("test");
}
public static void main(String[] args)
{
byte[] nativePtr = getPtr();
testPtr(nativePtr);
}
private static native byte[] getPtr();
private static native void testPtr(byte[] nativPtr);
}
#include <jni.h>
#include <stdio.h>
#include <stdlib.h>
/*
* Class: JNITest
* Method: getPtr
* Signature: ()[B
*/
JNIEXPORT jbyteArray JNICALL
Java_JNITest_getPtr (JNIEnv * env, jclass class)
{
int *int_ptr = (int *) malloc (sizeof (int));;
*int_ptr = 0x47;
jbyteArray nativePtr = (*env)->NewByteArray (env, (jint) sizeof (int *));
if (nativePtr == NULL)
return NULL;
(*env)->SetByteArrayRegion (env, nativePtr, 0, (int) sizeof (int *),
(char *) &int_ptr);
return nativePtr;
}
/*
* Class: JNITest
* Method: testPtr
* Signature: ([B)V
*/
JNIEXPORT void JNICALL
Java_JNITest_testPtr (JNIEnv * env, jclass class, jbyteArray nativePtr)
{
int *int_ptr;
(*env)->GetByteArrayRegion (env, nativePtr, 0, (jint) sizeof (int *),
(jbyte *) & int_ptr);
printf ("value = %x\n", *int_ptr);
}
- Re: Classpath build process and VM-specific issues, (continued)
- Re: Classpath build process and VM-specific issues, Michael Koch, 2004/04/05
- Re: Classpath build process and VM-specific issues, Andrew Haley, 2004/04/05
- Re: Classpath build process and VM-specific issues, Michael Koch, 2004/04/05
- Re: Classpath build process and VM-specific issues, Andrew Haley, 2004/04/05
- Re: Classpath build process and VM-specific issues, Etienne Gagnon, 2004/04/05
- Re: Classpath build process and VM-specific issues, Andrew Haley, 2004/04/05
- Re: Classpath build process and VM-specific issues, Etienne Gagnon, 2004/04/05
- Re: Classpath build process and VM-specific issues, Andrew Haley, 2004/04/05
- Re: Classpath build process and VM-specific issues, Archie Cobbs, 2004/04/05
- Re: Classpath build process and VM-specific issues, Andrew Haley, 2004/04/05
- Re: Classpath build process and VM-specific issues,
Etienne Gagnon <=
- Re: Classpath build process and VM-specific issues, Etienne Gagnon, 2004/04/05
- RE: Classpath build process and VM-specific issues, David Holmes, 2004/04/05
- RE: Classpath build process and VM-specific issues, Andrew Haley, 2004/04/06
- Re: Classpath build process and VM-specific issues, Etienne Gagnon, 2004/04/05
- Re: Classpath build process and VM-specific issues, Andrew Haley, 2004/04/06
- Re: Classpath build process and VM-specific issues, Steven Augart, 2004/04/06
- Re: Classpath build process and VM-specific issues, Andrew Haley, 2004/04/06
- Re: Classpath build process and VM-specific issues, Etienne Gagnon, 2004/04/06
- Re: Classpath build process and VM-specific issues, David Lichteblau, 2004/04/06
- Re: Classpath build process and VM-specific issues, Andrew Haley, 2004/04/07