Quantcast
Viewing all articles
Browse latest Browse all 80

Problem encountered when trying to pass objects using JPL by Stephen Burns

Firstly I would like to apologise for the length of this posting but if you can help please read on...

I am attempting to build a Java wrapper to an existing Perl API. The API performs updates over a network connection to a second server, which therefore requires a connection to be established, utilised and finally torn down (in a similar fashion to a database connection).

To avoid the overhead of creating and destroying the connection for each update, I am attempting to create the Perl object, pass this back into the Java which in turn pass the object to various other Perl procedures to perform the updates and finally tear down the connection.

I attempt the following using JPL:

class JPLSXIExample
{

perl void deleteSXIConnection (Object obj1) {{
use SXI;
my $SXIConn = $obj1;
print "deleteSXIConnection: SXIConn: $SXIConn\n";
bless $SXIConn, SXI;
print "deleteSXIConnection: SXIConnAfterBless: $SXIConn\n";
$SXIConn->delete();
}}

perl Object getSXIConnection () {{
use SXI;
my $SXIConn;
$SXIConn = new SXI{<<parameters>>} if !defined($SXIConn);
print "getSXIConnection: SXIConn: $SXIConn\n";
return bless $SXIConn, SXI;
}}


void test()
{
/* Get a connection */
System.out.println("Attempting to get an object of type SXI");
Object mySXI = getSXIConnection();
System.out.println("Successfully retrieved Object");

/* delete the connection */
System.out.println("Attempting Delete the conncetion to the SXI Server");
deleteSXIConnection(mySXI);
System.out.println("Successfully passed the object and used it");
}

public static void main(String[] argv) {
JPLSXIExample demo = new JPLSXIExample();
demo.test();
}
}

The output from running the above is shown below.

java JPLSXIExample
Attempting to get an object of type SXI
getSXIConnection: SXIConn: SXI=HASH(0xf3e60)
Successfully retrieved Object
Attempting Delete the conncetion to the SXI Server
deleteSXIConnection: SXIConn1: java::lang::Object=SCALAR(0xf3e60)
deleteSXIConnection: SXIConnAfterBless: SXI=SCALAR(0xf3e60)
Exception in thread "main" java.lang.RuntimeException: (in cleanup) Not a HASH reference at /usr/local/lib/perl5/site_perl/5.8.4/SXI.pm line 2936.

at JPLSXIExample.deleteSXIConnection(Native Method)
at JPLSXIExample.test(JPLSXIExample.java:57)
at JPLSXIExample.main(JPLSXIExample.java:63)
make: *** [test] Error 1

As can be seen the act of passing the object from one Perl procedure to another via Java seems to cause the object to be forced to a SCALER as opposed to a HASH!!

I would appreciate if anyone can shed any light on this, even to discredit it.

Many thanks in advance.

Stephen Burns

Stephen Burns
Senior Systems Designer
Real Time Engineering Ltd.


The information contained in this e-mail may contain confidential or privileged material and is intended only for the person or entity to which it is addressed. If you are not the intended recipient, the use, disclosure, copying or distribution of this information is prohibited and may be unlawful. If you have received it in error, please notify us immediately by telephone (+44 (0)141 427 4142). Please also destroy and delete the message from your computer. The opinions contained within this e-mail are not necessarily the opinions of Real Time Engineering Limited.

Viewing all articles
Browse latest Browse all 80

Trending Articles