www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript
electronics



c++ - DLL using JNI

↑ ↓ ← jimp <jimp02 email.com> writes:
I am using the C/C++ compiler version 8.49.

I have a DLL that can be called from either a C/C++ program or from a Java
program using the Java Native Interface (JNI). When called from a C++ program
it works OK. When called from a Java program, it works OK until the DLL needs
to terminate. Then I get a message box for a Java Application Error. It says
"The instruction at 0x1004c962 referenced memory at 0x82db0008. The memory
could not be read." The Java.exe program must be terminated using the task
manager.

I compile the DLL with other compilers and it works OK with Java. It is only
Digital Mars that has a problem. Following is a copy of the def file, which is
the only additional input to Digital Mars.

Why will the DLL not terminate with Digital Mars?


LIBRARY "AStylej.dll"
DESCRIPTION 'AStyle as a JNI DLL'
EXETYPE NT
SUBSYSTEM WINDOWS
CODE SHARED EXECUTE
DATA WRITE

EXPORTS
    _Java_ASInterface_AStyleMain 16      1
    Java_ASInterface_AStyleMain = _Java_ASInterface_AStyleMain 16   2
    _Java_ASInterface_GetVersion 8       3
    Java_ASInterface_GetVersion = _Java_ASInterface_GetVersion 8   4
Aug 06 2007
→ Walter Bright <newshound1 digitalmars.com> writes:
jimp wrote:
 Why will the DLL not terminate with Digital Mars?

I have no idea. I suggest compiling the DLL with debug on, and run it under the debugger.
Aug 06 2007
→ Walter Bright <newshound1 digitalmars.com> writes:
jimp wrote:
 Then I get a message box for a Java Application Error. It says
 "The instruction at 0x1004c962 referenced memory at 0x82db0008. The memory
 could not be read."

Being C/C++, this could very well be that your code suffers from an uninitialized pointer or a dangling pointer. It is not at all unusual for such code to appear to work with one compiler and fail with another, as the memory layouts are different.
Aug 06 2007