Hi again,
I now inserted printf-statements to see the value of the parameters
before and after passing them:
In X11TextRenderer: numGlpyhs:10, usePositions:0,
subpixPos:0, rgbOrder:0, lcdc:140, glypx:100.500000,
glyphy:400.500000, Images: -1376605040, NULL
In X11TextRenderer_md: numGlpyhs:10, usePositions:0, subpixPos:0,
rgbOrder:0, lcdc:140, glypx:0.000000, glyphy:3.392578, Images: 0
Positions:1081673728
So somehow it looks like passing the jfloats causes troubles, after
commenting them out, everything works as expected:
In X11TextRenderer: numGlpyhs:10, usePositions:0, subpixPos:0,
rgbOrder:0, lcdc:140, glypx:100.500000, glyphy:400.50000, Images:
-1376605792
In _md: numGlpyhs:10, usePositions:0, subpixPos:0, rgbOrder:0,
lcdc:140, glypx:-0.000000, glyphy:-0.000000, Images: -1376605792,
Positions:0
Any idea why passing the jfloats fail?
Thank you in advance, lg Clemens
2008/6/3 Clemens Eisserer <[EMAIL PROTECTED]>:
Hi Dmitri,
Did you try to run it with -Xcheck:jni (preferably on a fastdebug
build)? What does it say?
Thanks for the hint, it cleans the array-handle is not valid.
I added printf-statements and Hotspot is of course right, the
"original" object handle was != NULL, but the one I passed is zero.
The strange thing is if I call a method in the same shared library
(fontmanager.so) the handle is passed correctly, but when calling into
libmawt.so the array-handle is NULL.
I pass the array-handles by value, is this ok?
For now I could work-arround that by simply calling
GetPrimitiveArrayCritical in the first method, however thats somehow
strange and I would like to understand where my mistake is to learn of
my faults ;)
Thanks a lot for your patience, Clemens
One thing that also puzzles me is how the compiler knows about
AWTXRDrawGlyphList?
There's no header-file which specifies it, does the compiler guess?
This is the how the code looks like:
1.) In libmawt.so the method which is called and crashes:
void AWTXRDrawGlyphList
(JNIEnv *env, jobject self,
jlong dstData, jint numGlyphs, jboolean usePositions,
jboolean subPixPos, jboolean rgbOrder, jint lcdContrast,
jfloat glyphListOrigX, jfloat glyphListOrigY,
jlongArray imgArray, jfloatArray posArray)
{
images = (jlong *) (*env)->GetPrimitiveArrayCritical(env, imgArray, NULL);
}
2.)The method called from JNI in libfontmanager.so and a test-dummy method:
JNIEXPORT void JNICALL Java_sun_font_X11TextRenderer_doDrawGlyphList
//Method called from JNI
(JNIEnv *env, jobject xtr,
jlong dstData, jint totalGlyphs, jboolean usePositions,
jboolean subPixPos, jboolean rgbOrder, jint lcdContrast,
jfloat glyphListOrigX, jfloat glyphListOrigY,
jlongArray images, jfloatArray positions)
{
TESTDrawGlyphList(env, xtr, dstData, totalGlyphs, usePositions,
//Does not crash
subPixPos, rgbOrder, lcdContrast, glyphListOrigX,
glyphListOrigY, images, positions);
AWTXRDrawGlyphList(env, xtr, dstData, totalGlyphs, usePositions,
//Does crash, because images == NULL
subPixPos, rgbOrder, lcdContrast, glyphListOrigX,
glyphListOrigY, images, positions);
}
JNIEXPORT void TESTDrawGlyphList //DummyTestMethod
(JNIEnv *env, jobject self,
jlong dstData, jint numGlyphs, jboolean usePositions,
jboolean subPixPos, jboolean rgbOrder, jint lcdContrast,
jfloat glyphListOrigX, jfloat glyphListOrigY,
jlongArray imgArray, jfloatArray posArray)
{
jlong *images;
images = (jlong *) (*env)->GetPrimitiveArrayCritical(env, imgArray, NULL);
}
These are the outputs when I run the code with Xcheck:jni:
Pointer: -1388390664 <- Value of imgArray-handle before passed to the
2nd method in libmawt.so
Pointer: 0 <- Passed value
FATAL ERROR in native method: Non-array passed to JNI array operations
and this is without XCheck:jni:
V [libjvm.so+0x24252b]
C [libmawt.so+0x1fc81] AWTXRDrawGlyphList+0xa1
C [libfontmanager.so+0xb393]
Java_sun_font_X11TextRenderer_doDrawGlyphList+0x113
j sun.font.X11TextRenderer.doDrawGlyphList(JIZZZIFF[J[F)V+0
So the first call succeed (which basically does exectly the same, its
just in another shared library), but the second time the parameter is
not passed :-/