by Piet van Oostrum <piet@[EMAIL PROTECTED]
>
Jul 1, 2006 at 02:07 PM
>>>>> jamesb457@[EMAIL PROTECTED]
(J) wrote:
>J> I have an IDL looking something like this
>J> module LMS
>J> {
>J> struct Alarm
>J> {
>J> string sensor;
>J> string zone;
>J> };
>J> interface LMSIF
>J> {
>J> void raise_alarm(in Alarm aReading);
>J> void send_alarm_to_rmc(in string alarm);
>J> string test_case();
>J> };
>J> };
>J> and a java file looking something like:
>J> class LMSServant extends _LMSIFImplBase
>J> {
>J> Alarm al;
>J> //functions here
>J> public LMSServ()
>J> {
>J> //this line causes the problem.
>J> al.sensor = "Sensor 1";
>J> }
>J> }
>J> The problem i'm having is when i try to modify or write to the Alarm
>J> struct i get a NullPointerException every time.
>J> Am i doing something wrong?
yes. You only declare the Alarm variable al, but you don't reserve any
memory for it. It initializes with null. In Java Corba structs are cl*****
and you have to create an instance with new. In contrast to C and C++
where
structs get memory automatically.
So Alarm al = new Alarm(); should solve it I think.
--
Piet van Oostrum <piet@[EMAIL PROTECTED]
>
URL: http://www.cs.uu.nl/~piet
[PGP 8DAE142BE17999C4]
Private email: piet@[EMAIL PROTECTED]