Rony G. Flatscher wrote:

Hi there,

running a macro which gets dispatched as a macro via the OOo 2.4.1 Java bridge (the Java scripting framework of OOo) will be aborted, if the Java support (Apache BSF, cf. <http://jakarta.apache.org/bsf>) creates dynamically an event adapter. Running the same program via URE succeeds!

The Apache BSF employs its own class loader (extending java.lang.ClassLoader) for caching the dynamically created event adapter classes (done in org.apache.bsf.util.event.generator.AdapterClassLoader). Unfortunately, when dispatched by OOo 2.4.1 as a macro invoking ClassLoader.defineClass() causes an (uncatchable!) abend. (Running the same code via URE works as expected.)

What causes this surprising behaviour, and even more important, how can one come by it! (Support for dynamic languages is dependent on being able to create Java classes on the fly from time to time.)

The likely cause is some code that is loaded by a parent classloader trying to find the class in the generator's classloader.

The usual solution is to use the thread context classloader.

http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html#setContextClassLoader(java.lang.ClassLoader)

http://www.mail-archive.com/[email protected]/msg06747.html

You should be very careful to do any changing of the contextClassLoader in a try-finally block so that you don't expose the OOo code that calls your to a strange classloader.

---rony

P.S.: Ad Beta 3.0, Dev300m21: currently I am not able to add the scripting package (same package can be added to 2.4). Were there any changes to the OOo scripting framework for OOo 3.0 which one needs to take into account? If so, where would that be documented?

I've successfully run GroovyForOpenOffice and IFCX Wings on OOo 3.0 Beta m20 without changes from those needed for OOo 2.3 (which did break extensions that access the Scripting Framework Java API).

I recently posted to an old thread of yours on that issue:

http://www.mail-archive.com/[EMAIL PROTECTED]/msg00794.html

The only significant problem I'm having with OOo 3.0 is on PPC OS X where anything with Swing hangs the whole application.

Jim


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to