Hi,

I extract the objects before sending them over to the
Java constructor. I push the objects into an array,
for example, in @arg and pass to the java constructor.
But I have observed that I need to enclose @arg in
square brackets as [EMAIL PROTECTED] and pass it to a java
method/constructor, otherwise I get errors.
I am not sure why I need to do this only for java
objects. For an Array of String, I don't have to
enclose it in square brackets.
For now, the code works but I have to treat an array
of java objects as a special case, and enclose it in a
square bracket.

Thanks,
Sharmishtha
--- Patrick LeBoutillier
<[EMAIL PROTECTED]> wrote:

> Hi,
> 
> You are trying to send n array of Perl objects of
> type JavaArray over
> to Java and it doesn't know what to do with that.
> What exactly is a
> JavaArray?
> 
> 
> Patrick
> 
> 
> On 8/9/07, sharmishtha upadhyay
> <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > I am developing Perl wrappers for Java Code using
> > Inline-Java. I need to pass an array of Java
> objects
> > and an array of string to the constructor. The
> > constructor is defined as:
> >
> > public MyClassConstructor(JavaArray[] javaArray,
> > String[] strArray);
> >
> > Corresponding to the above constructor, I have
> > developed a wrapper as:
> >
> > sub new{
> >   my $class = shift;
> >   my $java_array = shift;
> >   my $str_array = shift;
> >
> >   my $obj = MyClassConstructor->new(???,???);
> >   return bless {
> >         obj => $obj,
> >     }, $class;
> > }
> >
> > Now my question is, how do I pass the arrays to
> the
> > constructor. If I use:
> >
>
MyClassConstructor->new([EMAIL PROTECTED],[EMAIL PROTECTED]),
> > I get the error:
> > A Java array can only contain scalars, Java
> objects or
> > array reference...
> > I have used all combinations, and nothing seems to
> > work.
> > BTW, the client code is calling the wrappers as
> shown
> > below:
> >
> > my @java_arr;
> > my $java_comp = new JavaArray;
> > push @java_arr, $java_comp;
> >
> > my @str_arr;
> > push @str_arr,"mystring";
> >
> > my $obj = perlClass->new([EMAIL PROTECTED],[EMAIL PROTECTED]);
> >
> > I am not sure what I am missing in the above code.
> > Any help would be appreciated.
> >
> > Thanks,
> > Sharmishtha
> >
> >
> >
> >
> >
>
____________________________________________________________________________________
> > Building a website is a piece of cake. Yahoo!
> Small Business gives you all the tools to get
> online.
> > http://smallbusiness.yahoo.com/webhosting
> >
> 
> 
> -- 
> =====================
> Patrick LeBoutillier
> Laval, Québec, Canada
> 



       
____________________________________________________________________________________
Pinpoint customers who are looking for what you sell. 
http://searchmarketing.yahoo.com/

Reply via email to