[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: ClassCastException



I get the same ClassCastException in DocumentImpl_Proxy.java in
getDocumentElement while running the XML Query samples(XML.Load,
XML.Convert, XML.Remove are working fine) on Solaris and Win 95. I was not
able to figure out what ResultConverter.substituteOzoneCompatibles is
actually trying to do. Can some body explain what actually is happening
here.

Thanks,

-Sarva




-----Original Message-----
From: Falko Braeutigam [mailto:falko@smb-tec.com]
Sent: Monday, August 28, 2000 7:35 AM
To: Lars Steiger; ozone-users@ozone-db.org
Subject: Re: ClassCastException


On Mon, 28 Aug 2000, Lars Steiger wrote:
> hi
> 
> does anyone knows something about the following behaviour:
> 
> example:
> 
> public class CommissionImpl
>     extends OzoneObject
>     implements Commission
> {
>     private Number _number = null;
> 
>     ...
> 
>     public Number getNumber() {
>         String name = _number.getName();
> 
>         ...
> 
>         return _number;
>     }
> }
> 
> public class NumberImpl
>     extends OzoneObject
>     implements Number
> {
>     String _name = null;
> 
>     ...
> 
>     public String getName() {
>         return _name;
>    }
> }

I tried to test this by changing org.ozoneDB.test.simpleAutoImpl to:

public class AutoImpl extends OzoneObject implements Auto {
   
   Auto		link;
   ...

   public Auto doSomthing (Auto auto) throws Exception {
      String linkName = link.name();
      System.out.println ("doSomething(): linkName=" + linkName);
      return link;
      }
   ...
}

doSomthing() now does the same as CommisionImpl.getNumber(). Right?

But calling doSomething() in my test case returns exactly the expected
results
- no exceptions.

> as you see commission and number are ozone objects. if i call the method
> getNumber(), i get an ClassCastException inside the CommissionImpl_Proxy
> while
> trying to return the number (method getNumber()). At that time the
> result (inside CommissionImpl_Proxy) contains the string value which was
> returned by the getName() method and not the number value which should
> be returned by the getNumber() method.
The result field is a _local_ variable of all proxy methods. OPP produces
the
following code for the doSomething() method of the proxy:
    
public org.ozoneDB.test.simple.Auto doSomthing (org.ozoneDB.test.simple.Auto
             arg0) throws java.lang.Exception {       

      try {
         Object target = link.fetch (this, Lock.LEVEL_READ);
         if (target != null) {
            arg0 =
(org.ozoneDB.test.simple.Auto)ResultConverter.substituteOzoneCompatibles
(arg0);
            return
(org.ozoneDB.test.simple.Auto)ResultConverter.substituteOzoneCompatibles
(((org.ozoneDB.test.simple.AutoImpl)target).doSomthing(arg0));
            }
         else {
            Object[] args = {arg0};
            Object result = link.invoke (this, 4, args, Lock.LEVEL_READ);
            return (org.ozoneDB.test.simple.Auto)result;
            }
         }
      catch (java.lang.Exception e) {
         e.fillInStackTrace();
         throw e;
         }
      }

So, subsequent calls fo the same or different methods of the proxy cannot
affect each other.

Are you on windows? If yes, can you test on Linux?


Falko
-- 
______________________________________________________________________
Falko Braeutigam                              mailto:falko@smb-tec.com
SMB GmbH                                        http://www.smb-tec.com