Skip to main content
GameDev.net gamedev.net
🔒 Locked

[java] how to create a working dll?

Started by fazekaim Oct 6, 2005 at 2:37 AM 4 replies 1.3k views
Original Post
fazekaim
fazekaim
Hello, i would like to create a dll to an existing C code. i created the jni C and H code, i compiled it, i created a test code:

static{
  System.loadLibrary("helpsm");
  HelpSMServices.updateMtx2();
  HelpSMServices.updateMtx2();
}


this works fine... when i want to make this calls from the jogl display method i got this: # # An unexpected error has been detected by HotSpot Virtual Machine: # # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d73c55d, pid=1560, tid=3080 # # Java VM: Java HotSpot(TM) Client VM (1.5.0_05-b05 mixed mode, sharing) # Problematic frame: # V [jvm.dll+0x8c55d] # # An error report file with more information is saved as hs_err_pid1560.log # # If you would like to submit a bug report, please visit: # http://java.sun.com/webapps/bugreport/crash.jsp # What can i do? (i'm using visual studio 6 for the dll creation) Thanks...
CaptainJester
CaptainJester
That doesn't look right at all. YOu would need to show more code to be sure.
"None of us learn in a vacuum; we all stand on the shoulders of giants such as Wirth and Knuth and thousands of others. Lend your shoulders to building the future!" - Michael Abrash[JavaGaming.org][The Java Tutorial][Slick][LWJGL][
fazekaim
fazekaim
My Java class:

 static {public class LispSMServices {        System.loadLibrary("lispsm");        /*LispSMServices.updateEyeMtx2();        LispSMServices.updateEyeMtx2();        LispSMServices.updateEyeMtx2();        //double[] res = LispSMServices.getEyeView();        System.out.println( "!!!!!!!!!"+eyeView.length+" "+eyeView[0]+" "+eyeView[1]+" "+eyeView[2] );*/    }    public static native void       perspectiveDeg( double vFovy, double ratio, double vNearDis, double vFarDis );    public static native double[]   getEyeView();    public static native double[]   getProjection();    public static native double[]   getProjEyeView();    public static native double[]   getInvEyeProjView();    public static native double[]   getLightView();    public static native double[]   getLightProjection();    public static native double[]   getLightProjView();    public static native void       updateEyeMtx();    public static native void       updateLightMtx();    public static native void       setSceneSize( double minX, double minY, double minZ, double maxX, double maxY, double maxZ );    public static native void       setEyePos( double xPos, double yPos, double zPos );    public static native void       setViewDir( double xDir, double yDir, double zDir );    public static native void       setLightDir( double xDir, double yDir, double zDir );}


.h generated by javah:
/* DO NOT EDIT THIS FILE - it is machine generated */#include <jni.h>/* Header for class witer_engine_math_lispSM_LispSMServices */#ifndef _Included_witer_engine_math_lispSM_LispSMServices#define _Included_witer_engine_math_lispSM_LispSMServices#ifdef __cplusplusextern "C" {#endif/* * Class:     witer_engine_math_lispSM_LispSMServices * Method:    perspectiveDeg * Signature: (DDDD)V */JNIEXPORT void JNICALL Java_witer_engine_math_lispSM_LispSMServices_perspectiveDeg  (JNIEnv *, jclass, jdouble, jdouble, jdouble, jdouble);/* * Class:     witer_engine_math_lispSM_LispSMServices * Method:    getEyeView * Signature: ()[D */JNIEXPORT jdoubleArray JNICALL Java_witer_engine_math_lispSM_LispSMServices_getEyeView  (JNIEnv *, jclass);/* * Class:     witer_engine_math_lispSM_LispSMServices * Method:    getProjection * Signature: ()[D */JNIEXPORT jdoubleArray JNICALL Java_witer_engine_math_lispSM_LispSMServices_getProjection  (JNIEnv *, jclass);/* * Class:     witer_engine_math_lispSM_LispSMServices * Method:    getProjEyeView * Signature: ()[D */JNIEXPORT jdoubleArray JNICALL Java_witer_engine_math_lispSM_LispSMServices_getProjEyeView  (JNIEnv *, jclass);/* * Class:     witer_engine_math_lispSM_LispSMServices * Method:    getInvEyeProjView * Signature: ()[D */JNIEXPORT jdoubleArray JNICALL Java_witer_engine_math_lispSM_LispSMServices_getInvEyeProjView  (JNIEnv *, jclass);/* * Class:     witer_engine_math_lispSM_LispSMServices * Method:    getLightView * Signature: ()[D */JNIEXPORT jdoubleArray JNICALL Java_witer_engine_math_lispSM_LispSMServices_getLightView  (JNIEnv *, jclass);/* * Class:     witer_engine_math_lispSM_LispSMServices * Method:    getLightProjection * Signature: ()[D */JNIEXPORT jdoubleArray JNICALL Java_witer_engine_math_lispSM_LispSMServices_getLightProjection  (JNIEnv *, jclass);/* * Class:     witer_engine_math_lispSM_LispSMServices * Method:    getLightProjView * Signature: ()[D */JNIEXPORT jdoubleArray JNICALL Java_witer_engine_math_lispSM_LispSMServices_getLightProjView  (JNIEnv *, jclass);/* * Class:     witer_engine_math_lispSM_LispSMServices * Method:    updateEyeMtx * Signature: ()V */JNIEXPORT void JNICALL Java_witer_engine_math_lispSM_LispSMServices_updateEyeMtx  (JNIEnv *, jclass);/* * Class:     witer_engine_math_lispSM_LispSMServices * Method:    updateLightMtx * Signature: ()V */JNIEXPORT void JNICALL Java_witer_engine_math_lispSM_LispSMServices_updateLightMtx  (JNIEnv *, jclass);/* * Class:     witer_engine_math_lispSM_LispSMServices * Method:    setSceneSize * Signature: (DDDDDD)V */JNIEXPORT void JNICALL Java_witer_engine_math_lispSM_LispSMServices_setSceneSize  (JNIEnv *, jclass, jdouble, jdouble, jdouble, jdouble, jdouble, jdouble);/* * Class:     witer_engine_math_lispSM_LispSMServices * Method:    setEyePos * Signature: (DDD)V */JNIEXPORT void JNICALL Java_witer_engine_math_lispSM_LispSMServices_setEyePos  (JNIEnv *, jclass, jdouble, jdouble, jdouble);/* * Class:     witer_engine_math_lispSM_LispSMServices * Method:    setViewDir * Signature: (DDD)V */JNIEXPORT void JNICALL Java_witer_engine_math_lispSM_LispSMServices_setViewDir  (JNIEnv *, jclass, jdouble, jdouble, jdouble);/* * Class:     witer_engine_math_lispSM_LispSMServices * Method:    setLightDir * Signature: (DDD)V */JNIEXPORT void JNICALL Java_witer_engine_math_lispSM_LispSMServices_setLightDir  (JNIEnv *, jclass, jdouble, jdouble, jdouble);#ifdef __cplusplus}#endif#endif



and an implementation:
#include "witer_engine_math_lispSM_LispSMServices.h"#include "lispSM\LispSM.h"/* Header for class witer_engine_math_lispSM_LispSMServices */jdoubleArray result;/* * Class:     witer_engine_math_lispSM_LispSMServices * Method:    perspectiveDeg * Signature: (DDDD)V */JNIEXPORT void JNICALL Java_witer_engine_math_lispSM_LispSMServices_perspectiveDeg(JNIEnv *env, jclass cls, jdouble vFovy, jdouble ratio, jdouble vNearDis, jdouble vFarDis){	perspectiveDeg( eyeProjection, vFovy, ratio, vNearDis, vFarDis );}/* * Class:     witer_engine_math_lispSM_LispSMServices * Method:    getEyeView * Signature: ()[D */JNIEXPORT jdoubleArray JNICALL Java_witer_engine_math_lispSM_LispSMServices_getEyeView(JNIEnv *env, jclass cls){		if( result == 0) result = (*env)->NewDoubleArray( env, 16 );	(*env)->SetDoubleArrayRegion( env, result, 0, 16, eyeView);		return result;}/* * Class:     witer_engine_math_lispSM_LispSMServices * Method:    getProjection * Signature: ()[D */JNIEXPORT jdoubleArray JNICALL Java_witer_engine_math_lispSM_LispSMServices_getProjection(JNIEnv *env, jclass cls ){	if( result == 0) result = (*env)->NewDoubleArray( env, 16 );	(*env)->SetDoubleArrayRegion( env, result, 0, 16, eyeProjection);		return result;}/* * Class:     witer_engine_math_lispSM_LispSMServices * Method:    getProjEyeView * Signature: ()[D */JNIEXPORT jdoubleArray JNICALL Java_witer_engine_math_lispSM_LispSMServices_getProjEyeView(JNIEnv *env, jclass cls ){	if( result == 0) result = (*env)->NewDoubleArray( env, 16 );	(*env)->SetDoubleArrayRegion( env, result, 0, 16, eyeProjView);		return result;}/* * Class:     witer_engine_math_lispSM_LispSMServices * Method:    getInvEyeProjView * Signature: ()[D */JNIEXPORT jdoubleArray JNICALL Java_witer_engine_math_lispSM_LispSMServices_getInvEyeProjView(JNIEnv *env, jclass cls ){	if( result == 0) result = (*env)->NewDoubleArray( env, 16 );	(*env)->SetDoubleArrayRegion( env, result, 0, 16, invEyeProjView);		return result;}/* * Class:     witer_engine_math_lispSM_LispSMServices * Method:    getLightView * Signature: ()[D */JNIEXPORT jdoubleArray JNICALL Java_witer_engine_math_lispSM_LispSMServices_getLightView(JNIEnv *env, jclass cls ){	if( result == 0) result = (*env)->NewDoubleArray( env, 16 );	(*env)->SetDoubleArrayRegion( env, result, 0, 16, lightView );		return result;}/* * Class:     witer_engine_math_lispSM_LispSMServices * Method:    getLightProjection * Signature: ()[D */JNIEXPORT jdoubleArray JNICALL Java_witer_engine_math_lispSM_LispSMServices_getLightProjection(JNIEnv *env, jclass cls ){	if( result == 0) result = (*env)->NewDoubleArray( env, 16 );	(*env)->SetDoubleArrayRegion( env, result, 0, 16, lightProjection);		return result;}/* * Class:     witer_engine_math_lispSM_LispSMServices * Method:    getLightProjView * Signature: ()[D */JNIEXPORT jdoubleArray JNICALL Java_witer_engine_math_lispSM_LispSMServices_getLightProjView(JNIEnv *env, jclass cls ){	if( result == 0) result = (*env)->NewDoubleArray( env, 16 );	(*env)->SetDoubleArrayRegion( env, result, 0, 16, lightProjection );		return result;}/* * Class:     witer_engine_math_lispSM_LispSMServices * Method:    updateEyeMtx * Signature: ()V */JNIEXPORT void JNICALL Java_witer_engine_math_lispSM_LispSMServices_updateEyeMtx(JNIEnv *env, jclass cls ){	updateEyeMtx();}/* * Class:     witer_engine_math_lispSM_LispSMServices * Method:    updateLightMtx * Signature: ()V */JNIEXPORT void JNICALL Java_witer_engine_math_lispSM_LispSMServices_updateLightMtx(JNIEnv *env, jclass cls ){	updateLightMtx();}/* * Class:     witer_engine_math_lispSM_LispSMServices * Method:    setSceneSize * Signature: (DDDDDD)V */JNIEXPORT void JNICALL Java_witer_engine_math_lispSM_LispSMServices_setSceneSize(JNIEnv *env, jclass cls, jdouble minX, jdouble minY, jdouble minZ, jdouble maxX, jdouble maxY, jdouble maxZ ){	sceneAABox.min[0] = minX; sceneAABox.min[1] = minY; sceneAABox.min[2] = minZ;	sceneAABox.min[0] = maxX; sceneAABox.min[1] = maxY; sceneAABox.min[2] = maxZ;}/* * Class:     witer_engine_math_lispSM_LispSMServices * Method:    setEyePos * Signature: (DDD)V */JNIEXPORT void JNICALL Java_witer_engine_math_lispSM_LispSMServices_setEyePos(JNIEnv *env, jclass cls, jdouble xPos, jdouble yPos, jdouble zPos){	eyePos[0] = xPos; eyePos[1] = yPos; eyePos[2] = zPos; }/* * Class:     witer_engine_math_lispSM_LispSMServices * Method:    setViewDir * Signature: (DDD)V */JNIEXPORT void JNICALL Java_witer_engine_math_lispSM_LispSMServices_setViewDir(JNIEnv *env, jclass cls, jdouble eyeX, jdouble eyeY, jdouble eyeZ){	viewDir[0] = eyeX; viewDir[1] = eyeY; viewDir[2] = eyeZ;}/* * Class:     witer_engine_math_lispSM_LispSMServices * Method:    setLightDir * Signature: (DDD)V */JNIEXPORT void JNICALL Java_witer_engine_math_lispSM_LispSMServices_setLightDir(JNIEnv *env, jclass cls, jdouble lightX, jdouble lightY, jdouble lightZ){	lightDir[0] = lightX; lightDir[1] = lightY; lightDir[2] = lightZ;}


i hope, somebody could help me...
Raghar
Raghar
And now there would be a simple easy debug thourgh the native application.

Try to // possible offending method.
Optus
Optus
Well, I don't think anyone can help you, the method you say crashes doesn't exist in the code you posted.
Son of Cain
Son of Cain
Hey, I also have that recent JVM, and I got the SAME error doing something extremely different (I can't remember exactly what it was, but I was programming for swing).

So, it seems there's nothing wrong with our code, but with the JVM itself.

[Edit: Now I see, we weren't doing "something extremely different" if you had the error while calling the JOGL display... which increases the chance of this being a bug, since I was doing swing work]

Son Of Cain
a.k.a javabeats at yahoo.ca

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.