Hi!
 
In our application we have some methods on the client side that take a java.lang.Class object as a parameter. ULC 6.1 doesn't contain a coder for java.lang.Class, but since that's not really difficult we developed our own one:
public class ClassCoder implements IStreamCoder
{
    public String getPeerClassName()
    {
        return Class.class.getName();
    }
 
    public void writeObject(IObjectOutputStream out, Object data) throws IOException
    {
        out.writeUTF(((Class) data).getName());
    }
 
    public Object readObject(IObjectInputStream in) throws IOException
    {
        String className = in.readUTF();
        Class result;
        try
        {
            result = Class.forName(className);
        }
        catch (ClassNotFoundException e)
        {
            throw new IOException("Die Klasse <" + className + "> konnte nicht gefunden und deshalb beim Einlesen nicht wieder hergestellt werden.");
        }
        return result;
    }
}
and registered it on both the client and server side coder registries:
        registry.registerCoder(Class.class, new ClassCoder());
The great problem here is that the coder is never used. In our first test where the classes used as parameters where classes like java.lang.String it seemed to work, but when we began using our own classes, it stopped working.
When we now take a class "de.pds.CustomClass" ULC complains "No coder found for de.pds.CustomClass" and our ClassCoder isn't ever used. Why is ULC searching for a coder for de.pds.CustomClass. We aren't transfering objects of this class, only the class object itself.
 
Cheers,
  Peter & Robert

Reply via email to