comp.lang.ada
 help / color / mirror / Atom feed
* 'image fails in Ada callback from Java
@ 1997-12-29  0:00 Shayne Flint
  0 siblings, 0 replies; only message in thread
From: Shayne Flint @ 1997-12-29  0:00 UTC (permalink / raw)



I have a fustrating problem when using Ada with Java. I am using
Gnat 3.10p and JDK 1.1.5 on Windows NT4sp3. The problem also applies to
Gnat 3.09 and JDK 1.1.4.

I am using the Java Native Interface (JNI) from Ada via a set of
bindings I have built. I am able to do most things including the use of
Ada
to handle Java events.

My problem is that an Ada callback procedure, setup to handle a Java
event, aborts the program when it uses the 'image attribute. If the
callback
is called from Ada or another Java method things work as expected. It is
only when the callback is called by Java in response to an event that
things
go wrong.

I have built the following three tests to help diagnose the problem.

CASE ONE: "C", "Java" and "Java Events"
---------------------------------------
This test is an all "C" and "Java" implementation (no Ada at all). The C
main calls JNI to create a window and button, and to setup the Java side
so that a C function is called when the button is clicked. This test
works OK.

"C Side"                    "Java side (class MyListener)"
========                    ==============================
C1. create window via JNI
C2. create button via JNI
C3. register C function 'callback' as Java native method in Java class
    MyListener (extends ActionListener).
C4. create instance of Java class MyListener
C5. add MyListener instance to button

                            J1. user Clicks Button
                            J2. actionPerformed in MyListener called
                            J3. actionPerformed calls NativeMethod
                                (ie. C function 'callback')


CASE TWO: "Ada" and "Java" (no java events)
-------------------------------------------
The second test uses an Ada main which calls Java to test its ability
to callback to Ada without anything to do with Java events. This test
works as expected. ie. The use of 'image within the Ada callback routine
works properly.

"Ada Side"                  "Java side (class TestClass)"
==========                  ==============================
A1. register Ada procedure 'callback' as Java native method in Java
    class TestClass
A2. create instance of Java class TestClass
A3. call java Native method in TestClass

                            J1. NativeMethod implemented by Ada
procedure
                                displays parameters using 'image


CASE THREE: "Ada", "Java" and "Java Events"
-------------------------------------------
The third case is an Ada and Java implementation of the first test
described above (the C code was replaced by Ada). In this case things
work as expected until the Ada callback procedure attempts to use
'image.
When this happens, the program aborts with the error message shown
below.

"Ada Side"                  "Java side (class MyListener)"
==========                  ==============================
C1. create window via JNI
C2. create button via JNI
C3. register Ada procedure 'callback' as Java native method in
    Java class MyListener (extends ActionListener)
C4. create instance of Java class MyListener
C5. add MyListener instance to button

                            J1. user Clicks Button
                            J2. actionPerformed in MyListener called
                            J3. actionPerformed calls NativeMethod
                                (ie. Ada procedure 'callback')
                                This Ada procedure fails when it
                                attempts to use 'image.

The error is as follows (displayed in a pop up window with OK and CANCEL
buttons)

    The instruction at "0x0040cd30" referenced memory at "0x00000018".
    The memory could not be "read"

Does anyone have any idea what is going on here? Maybe some input on how
'image is implemented by Gnat would be a good start.

thanks.

------------------------------------------------------------------
-- Shayne Flint, MIEAust, CPEng        shayne@ainslie-software.com 
-- Ainslie Software Pty Limited    http://www.ainslie-software.com
--
--      ShapeDB, a database and form drawing add-on for Visio
------------------------------------------------------------------




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1997-12-29  0:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-12-29  0:00 'image fails in Ada callback from Java Shayne Flint

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox