DLL runtime problems

sjc@qx.net sjc@qx.net
Thu Aug 3 13:37:00 GMT 2000


I am trying to implement a Java JNI call into a DLL compiled by Cygwin's gcc.  I've gotten everything to compile correctly but running the example causes an application error and kills the JVM.  I've been doing some asking around, and have learned that there are differences between __stdcall and __cdecl methods for calling into DLLs.  The existence of the @ symbols and use of WINAPI in the Cygwin example indicate that __stdcall is being used.  Does anyone know how JNI is implemented on the Windows NT4 platform, either __stdcall or __cdecl, and whether or not gcc can create __cdecl DLLs if that's what the Windows NT4 JDK uses?  I'm not an experienced Windows programmer, so I maybe confusing the terminology.

Also, is there any more information someone could point me to concerning the meaning of the @12 in the example in case that number should be different for my example?

The files are so simple I've included them here:

HelloNative.h:
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class HelloNative */

#ifndef _Included_HelloNative
#define _Included_HelloNative

#ifdef __cplusplus
extern "C" {
#endif

/*
 * Class:     HelloNative
 * Method:    greeting
 * Signature: ()V
 */

JNIEXPORT void JNICALL Java_HelloNative_greeting
(JNIEnv *, jclass);

#ifdef __cplusplus
}
#endif
#endif

HelloNative.c:
#include "HelloNative.h"
#include <stdio.h>
#include <windows.h>

int WINAPI HelloNative_init
(HANDLE h, DWORD reason, void *foo)
{
  return 1;
}

JNIEXPORT void JNICALL Java_HelloNative_greeting
(JNIEnv* env, jclass cl)
{
    printf("Hello, Native World!\n");
}

main()
{
}

HelloNative.def:
EXPORTS
Java_HelloNative_greeting

HelloNative.java:
class HelloNative
{
    public native static void greeting();

    static
    {
        System.loadLibrary("HelloNative");
    }
}

HelloNativeTest.java:
class HelloNativeTest
{
    public static void main( String[] args )
    {
        HelloNative.greeting();
    }
}

Thanks for any help.

Stuck in DLL HELL,
Steve


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com



More information about the Cygwin mailing list