Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2007

Tip: Looking for answers? Try searching our database.

How to send null parameter in Java-IDL?

Thread view: 
billdavidcn@gmail.com - 03 Jul 2007 06:10 GMT
1.I need to transfer a complex type with an array variable member in a
Java-IDL based program. But if the array is empty, the program will
report a java.lang.NullPointerException.
Is there any solution to it except block the request in client side?

The following is my idl:

#ifndef __SAMPLE_IDL__
#define __SAMPLE_IDL__

typedef sequence <octet> ByteArray;

struct ComplexType {
    ByteArray data;
    string info;
};

interface Sample {
 void doSomething(in ComplexType value);
};

#endif  // __SAMPLE_IDL__

And the following is a snippet from the client program:

ComplexType value = new ComplexType();
// leave data field to be NULL
value.info = "Hello, World!";
xxx.doSomething(value);

If I provide an empty data field for ComplexType, it will fail to
serialize the parameter value.
And the following is part of the autogenerated class ByteArrayHelper:

 public static void write (org.omg.CORBA.portable.OutputStream
ostream, byte[] value)
 {
   ostream.write_long (value.length);
   ostream.write_octet_array (value, 0, value.length);
 }

It always throws java.lang.NullPointerException at the line:
ostream.write_long (value.length);

2.If I have another method:
void echoString(in string info);

If the client call this method with a null parameter, ORB will
complain too. But sometimes, it's reasonable requirement. Is it any
solution to this? Redefine a method:
void echoString();
or block such kind of request by client?

There must be a better solution. But what is it?
Yakov Gerlovin - 04 Jul 2007 21:07 GMT
1. CORBA does not allow sending 'null'
In your case, you should create an array of zero size:

ComplexType value = new ComplexType();
// fill data field with zero-length array, instead of leaving it equal
to NULL
value.data = new byte[0];
value.info = "Hello, World!";

xxx.doSomething(value);

2. http://groups.google.com/group/comp.lang.java.corba/browse_thread/thread/c90d317
a8f847ae0?hl=en



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.