The problem of Compile hitting classes that aren't Serializable is one that I've found it very difficult to crack. I did quite a bit of work to get this right in the Saxon 8.4 release; the only way I know how to do it is to compile lots of stylesheets and make sure that they work. I've looked around for tools that inspect the code to check that all reachable classes are Serializable - one would think it's a simple enough problem - but can't find anything. In fact, even in 8.4 the FastStringBuffer class is not serializable, so you'll probably hit the same issue. (The other problem is working out why the compiled stylesheet contains a reference to the offending class. Sometimes the problem isn't that the class should be serializable, but that the reference should be transient.)
 
I did find one problem in testing this for 8.4 which might affect you, namely that stylesheets containing calls on saxon:evaluate() can't be compiled. This is because saxon:evaluate() needs too much of the original source stylesheet to be kept around at run-time.
 
If you'd like to send me this stylesheet I'll take a look at it to see if the problem is soluble. It might just be a question of declaring FastStringBuffer to implement java.io.Serializable but it's probably a bit deeper than that.
 
Longer term, I probably need to rethink the way compilation works, to use a more robust approach than Java serialization. There's a real need for some kind of separate compilation to allow modules to be compiled and linked separately.
 
Michael Kay
http://www.saxonica.com/


From: saxon-help-admin@lists.sourceforge.net [mailto:saxon-help-admin@lists.sourceforge.net] On Behalf Of Cary Millsap
Sent: 12 April 2005 22:27
To: Saxon Help List
Subject: [saxon] can Transform, can't Compile

I have a transform that works fine if I use “call java net.sf.saxon.Transform”, but it emits errors when I use “call java net.sf.saxon.Compile”. What should my next step be?

 

Here’s my session…

 

 

16:02:31.34 $ p5st 2020

 

16:03:34.14 $ call java net.sf.saxon.Transform -o "2020.html" -t "2020.xml" "C:\Documents and Settings\Cary Millsap\My Documents\Software\dev\P5\Profile-xhtml\p5.xsl" "SOFTWARE-HOME=C:\Documents and Settings\Cary Millsap\My Documents\Software\dev"

Saxon 8.3 from Saxonica

Java version 1.5.0_02

Stylesheet compilation time: 3335 milliseconds

Processing file:/C:/Documents%20and%20Settings/Cary%20Millsap/My%20Documents/Software/dev/P5/Test-Data/2020.xml

Building tree for file:/C:/Documents%20and%20Settings/Cary%20Millsap/My%20Documents/Software/dev/P5/Test-Data/2020.xml using class net.sf.saxon.tinytree.TinyBuilder

Tree built in 130 milliseconds

Tree size: 3910 nodes, 14905 characters, 7901 attributes

Building tree for file:///C:/Documents%20and%20Settings/Cary%20Millsap/My%20Documents/Software/dev/P5/config/Profile-XHTML.xml using class net.sf.saxon.tinytree.TinyBuilder

Tree built in 0 milliseconds

Tree size: 112 nodes, 225 characters, 32 attributes

Building tree for file:///C:/Documents%20and%20Settings/Cary%20Millsap/My%20Documents/Software/dev/P5/config/cdefs.xml using class net.sf.saxon.tinytree.TinyBuilder

Tree built in 10 milliseconds

Tree size: 44 nodes, 57 characters, 22 attributes

Execution time: 1522 milliseconds

16:03:41.16 $

16:03:57.95 $

16:03:59.45 $ ..\Profile-XHTML\xsl2sxx

 

16:04:13.33 $ set XSL=C:\Documents and Settings\Cary Millsap\My Documents\Software\dev\P5\Profile-XHTML\p5.xsl

 

16:04:13.33 $ set SXX=C:\Documents and Settings\Cary Millsap\My Documents\Software\dev\P5\bin\Profile-XHTML.sxx

 

16:04:13.33 $ call java net.sf.saxon.Compile -t "C:\Documents and Settings\Cary Millsap\My Documents\Software\dev\P5\Profile-XHTML\p5.xsl" "C:\Documents and Settings\Cary Millsap\My Documents\Software\dev\P5\bin\Profile-XHTML.sxx"

Saxon 8.3 from Saxonica

Java version 1.5.0_02

Stylesheet compilation time: 6249 milliseconds

Serializing compiled stylesheet

java.io.NotSerializableException: net.sf.saxon.om.FastStringBuffer

        at java.io.ObjectOutputStream.writeObject0(Unknown Source)

        at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)

        at java.io.ObjectOutputStream.writeSerialData(Unknown Source)

        at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)

        at java.io.ObjectOutputStream.writeObject0(Unknown Source)

        at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)

        at java.io.ObjectOutputStream.writeSerialData(Unknown Source)

        at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)

        at java.io.ObjectOutputStream.writeObject0(Unknown Source)

        at java.io.ObjectOutputStream.writeObject(Unknown Source)

        at java.util.HashMap.writeObject(Unknown Source)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

        at java.lang.reflect.Method.invoke(Unknown Source)

        at java.io.ObjectStreamClass.invokeWriteObject(Unknown Source)

        at java.io.ObjectOutputStream.writeSerialData(Unknown Source)

        at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)

        at java.io.ObjectOutputStream.writeObject0(Unknown Source)

        at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)

        at java.io.ObjectOutputStream.writeSerialData(Unknown Source)

        at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)

        at java.io.ObjectOutputStream.writeObject0(Unknown Source)

        at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)

        at java.io.ObjectOutputStream.writeSerialData(Unknown Source)

        at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)

        at java.io.ObjectOutputStream.writeObject0(Unknown Source)

        at java.io.ObjectOutputStream.writeObject(Unknown Source)

        at net.sf.saxon.Compile.doMain(Compile.java:148)

        at net.sf.saxon.Compile.main(Compile.java:44)

 

16:04:29.23 $

 

Cary Millsap
Hotsos Enterprises, Ltd.
http://www.hotsos.com
Nullius in verba

Visit www.hotsos.com for curriculum and schedule details...