[gme-users] Constructing a GME model using Java

Carolina carolnotrabalho at uol.com.br
Fri Sep 22 11:12:56 CDT 2006


Hi Kitty,

Sorry for my late reply. In fact is possible to debug Java interpreters. You 
only need to add a few lines in JavaCompRunner.dll source, recompile it and 
then use Eclipse debugger.

The proceedings are:

1- Change the JavaCompRunner.dll source (it´s the RawComponent.cpp source 
file inside the
JavaCompRunner project) so the JVM could be initialized in debug mode. For
this, you need to pass an -Xrun option to the JVM (that´s based on a
bug reported in http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4335526,
which tells us "An -Xrun option with a ':' needs to be stored in a temporary
buffer before being passed to JNI_CreateJavaVM."). Based on this, here is 
the
final code snippet (located around line 87 of the RawComponent.cpp source
file):

(...)

// find java vm or create it if not found
jsize machineNum;
jsize buflen = 6;
JavaVMInitArgs args;
JavaVMOption options[6];

char buf2[300];

args.version = JNI_VERSION_1_2;
args.nOptions = 6;
sprintf(buf, "-Djava.class.path=%s", classPath);

sprintf(buf2,
"-Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=n");
options[0].optionString = buf;
options[1].optionString = "-verbose:jni";
options[2].optionString = "-Xdebug";
options[3].optionString = buf2;
options[4].optionString = "-Djava.compiler=NONE";
options[5].optionString = "-Xnoagent";

args.options = options;

(...)

2- After changing the source code, generate a new JavaCompRunner.dll and
replaced the original one for the new one.
To start the debug, it´s necessary to block the execution of the interpreter
and for that we used a javax.swing.JOptionPane. So, during the execution of
the interpreter, when a JOptionPane pops-up, go to Eclipse, right-click the
interpreter java file and select Debug as > Debug. In the debug window,
create a new "Remote Java Application" with the following properties:

Connection Type: Standard (Socket Attach)
Host: 127.0.0.1
Port: 8000

Click on the debug button and then click on the OK button from the
JOptionPane. That way, the execution should stop in the first breakpoint
inserted in the interpreter´s java code ;)

That is the way we debug GME java interpreters here where I work.

Regards,

Carolina S. Araujo
Autbank Projetos e Consultoria
São Paulo - Brasil

----- Original Message ----- 
From: "Krishnakumar B" <kitty at dre.vanderbilt.edu>
To: "A list for GME users to share thoughts and discuss bugs and fixes." 
<gme-users at list.isis.vanderbilt.edu>
Sent: Wednesday, September 06, 2006 4:51 PM
Subject: Re: [gme-users] Constructing a GME model using Java


> Hi John,
>
> On Wed, 06 Sep 2006 02:20:45 PM -0500, John K Black wrote:
>> Hi,
>>
>> I've been trying to construct a GME model using Java.  I've written some
>> working code using the mga.dtd as a starting point for some Java
>> bindings, but it looks like I really should be using the official Java
>> interface to GME.
>
> The Java Bindings to GME are not complete, i.e., some functions are not 
> yet
> implemented.  I have also heard that is might get fixed in the near 
> future.
> But the big issue with Java and GME is that debugging is really painful.
> You have to resort to dumping messages on GME's console, and cannot use 
> any
> debugger to step in.
>
> We have also discussed implementing a C# binding to GME which will be more
> amenable to debugging as well the advantages of a high-level programming
> language and the rich .NET libraries.  But it is not high priority right
> now.
>
>> I tried creating a project from scratch with the low-level Java BON API,
>> but haven't had any success.  Are there any examples or docs around that
>> show how to do this?
>
> You can actually use the mga.dtd and create an XME file.  In fact, I
> converted mga.dtd to mga.xsd, and used the latest JAXB 2.0, to create
> XME files that can be imported into GME.  Please see:
>
> https://svn.dre.vanderbilt.edu/viewvc/cosmic/trunk/CoSMIC/PIM/WSML/interpreters/WSDLImporter/
>
> for an example.  You can also find usage of UDM's Java interface at:
>
> https://svn.dre.vanderbilt.edu/viewvc/cosmic/trunk/CoSMIC/PIM/WSML/interpreters/WSDLExporter/
>
> Problem with UDM is that it is not integrated into GME, and hence requires
> conversion of your GME model to UDM's XML model before you can use it with
> Java UDM.
>
> HTH.
>
> -kitty.
>
> -- 
> Krishnakumar B <kitty at dre dot vanderbilt dot edu>
> Institute for Software Integrated Systems, Dept. of EECS, Vanderbilt 
> University
> _______________________________________________
> gme-users mailing list
> gme-users at list.isis.vanderbilt.edu
> http://list.isis.vanderbilt.edu/mailman/listinfo/gme-users
> 



More information about the gme-users mailing list