Hi Michael,
 
> What is the prefered way to test for the existance of a class before
> declaring it.
 
cm = this.namespace.getClassManager();
print(cm.classExists("MyClass"));
 
Re: Revising a class
 
Sorry, I haven't had a chance to play with BeanShell 2 much yet.  It imagine it would require some work with the classloaders, but I can't give you a specific pointer.
 
Cheers,
Dan
----- Original Message -----
From: Michael Pitoniak
To: beanshell-users@lists.sourceforge.net
Sent: Monday, March 22, 2004 10:00 PM
Subject: [Beanshell-users] Exception decalring class twice


Folks,

 If I run this script twice I get  the exception listed below. It appears that you can only declare a class once, as the second time you try to declare the same class you get an exception. What is the prefered way to test for the existance of a class before declaring it. What if the class changes between runs? Is there an easy way to unload the class prior to redecaring it?

Thanks,

mike


=====================================================


reloadClasses();


class TestReturn {
        boolean getBoolean() { return true; }
        byte getByte() { return (byte)1; }
        long getLong() { return 42l; }
        float getFloat() { return 1.0f; }
        double getDouble() { return 4.2d; }
        Double getD() { return new Double(4.2d); }
}


tr = new TestReturn();

parser.writeError(tr.getLong());


Exception:


Caused by: java.lang.LinkageError: duplicate class definition: TestReturn