|
RE: External function binding bug (early binding): msg#00159text.xml.saxon.help
I think this is too marginal a case to justify fixing. I don't often say that, but one has to draw the line somewhere. The circumvention is to write a wrapper Java class that handles the situation, and call that instead. Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: saxon-help-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@xxxxxxxxxxxxxxxx > [mailto:saxon-help-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@xxxxxxxxxxxxxxxx] > On Behalf Of > Wolfgang Hoschek > Sent: 22 June 2005 20:59 > To: saxon-help-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@xxxxxxxxxxxxxxxx > Subject: [saxon] External function binding bug (early binding) > > Hi Mike, > > There is another small bug in the way saxon-8.4 searches and binds > Java extension functions. > It's triggered if there's a public method in an external function > class that uses argument types in its signature that are not on the > class path, even if that method is not used in any way by the query. > In the spirit of late dynamic binding, I think Saxon should not fail > here. Rather, it should catch and ignore the relevant exceptions on > function binding if the function is never used. > > The case arises if one has a class with various utility extension > functions, some of which are typically rarely used, but have > dependencies on various third-party libs. If those rare > functions are > not used, a user should not need to download and include those third- > party libs. > > Here's an example to reproduce (assuming you have lucene.jar from > http://lucene.apache.org/java/docs/index.html on the classpath at > compile time, but not at runtime): > > package nux.xom.tests; > > import org.apache.lucene.analysis.Analyzer; > > public class ExternalFunctionTest { > public static String foo(String bar) { return bar; } > public static void unused(String baz, Analyzer anal) {} // this > method is never used at runtime > } > > > package nux.xom.tests; > > public class ExternalFunctionTestWorkAround { > public static String foo(String bar) { return > ExternalFunctionTest.foo(bar); } > } > > > This works fine: > =========================================== > declare namespace util = > "java:nux.xom.tests.ExternalFunctionTestWorkAround"; > util:foo("x") > > > [hoschek /Users/hoschek/unix/devel/nux] fire-xquery ext-workaround.xq > <atomic-value xsi:type="xs:string" xmlns="http://dsd.lbl.gov/nux" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">x</atomic-value> > > > This triggers the bug: > =========================================== > declare namespace util = "java:nux.xom.tests.ExternalFunctionTest"; > util:foo("x") > > > [hoschek /Users/hoschek/unix/devel/nux] fire-xquery ext.xq > Exception in thread "main" java.lang.NoClassDefFoundError: > org/apache/ > lucene/analysis/Analyzer > at java.lang.Class.getDeclaredMethods0(Native Method) > at java.lang.Class.privateGetDeclaredMethods(Class.java:1655) > at java.lang.Class.privateGetPublicMethods(Class.java:1778) > at java.lang.Class.getMethods(Class.java:832) > at net.sf.saxon.functions.JavaExtensionLibrary.bind > (JavaExtensionLibrary.java:307) > at net.sf.saxon.functions.FunctionLibraryList.bind > (FunctionLibraryList.java:71) > at net.sf.saxon.expr.ExpressionParser.parseFunctionCall > (ExpressionParser.java:1732) > at net.sf.saxon.expr.ExpressionParser.parseBasicStep > (ExpressionParser.java:1234) > at net.sf.saxon.expr.ExpressionParser.parseStepExpression > (ExpressionParser.java:1149) > at net.sf.saxon.expr.ExpressionParser.parseRelativePath > (ExpressionParser.java:1089) > at net.sf.saxon.expr.ExpressionParser.parsePathExpression > (ExpressionParser.java:1075) > at net.sf.saxon.expr.ExpressionParser.parseUnaryExpression > (ExpressionParser.java:954) > at net.sf.saxon.expr.ExpressionParser.parseCastExpression > (ExpressionParser.java:625) > at > net.sf.saxon.expr.ExpressionParser.parseCastableExpression > (ExpressionParser.java:600) > at net.sf.saxon.expr.ExpressionParser.parseTreatExpression > (ExpressionParser.java:581) > at > net.sf.saxon.expr.ExpressionParser.parseInstanceOfExpression > (ExpressionParser.java:563) > at > net.sf.saxon.expr.ExpressionParser.parseIntersectExpression > (ExpressionParser.java:987) > at net.sf.saxon.expr.ExpressionParser.parseUnionExpression > (ExpressionParser.java:969) > at > net.sf.saxon.expr.ExpressionParser.parseMultiplicativeExpression > (ExpressionParser.java:906) > at > net.sf.saxon.expr.ExpressionParser.parseAdditiveExpression > (ExpressionParser.java:886) > at net.sf.saxon.expr.ExpressionParser.parseRangeExpression > (ExpressionParser.java:798) > at > net.sf.saxon.expr.ExpressionParser.parseComparisonExpression > (ExpressionParser.java:748) > at net.sf.saxon.expr.ExpressionParser.parseAndExpression > (ExpressionParser.java:370) > at net.sf.saxon.expr.ExpressionParser.parseOrExpression > (ExpressionParser.java:352) > at net.sf.saxon.expr.ExpressionParser.parseExprSingle > (ExpressionParser.java:306) > at net.sf.saxon.expr.ExpressionParser.parseExpression > (ExpressionParser.java:269) > at net.sf.saxon.query.QueryParser.parseQuery > (QueryParser.java:144) > at net.sf.saxon.query.QueryParser.makeXQueryExpression > (QueryParser.java:71) > at net.sf.saxon.query.StaticQueryContext.compileQuery > (StaticQueryContext.java:254) > at nux.xom.xquery.XQuery.<init>(XQuery.java:413) > at nux.xom.pool.XQueryFactory.createXQuery > (XQueryFactory.java:139) > at nux.xom.pool.XQueryFactory.createXQuery > (XQueryFactory.java:165) > at nux.xom.pool.XQueryFactory.createXQuery > (XQueryFactory.java:114) > at nux.xom.tests.XQueryCommand.main(XQueryCommand.java:132) > [hoschek /Users/hoschek/unix/devel/nux] > > > > ------------------------------------------------------- > SF.Net email is sponsored by: Discover Easy Linux Migration Strategies > from IBM. Find simple to follow Roadmaps, straightforward articles, > informative Webcasts and more! Get everything you need to get up to > speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click > _______________________________________________ > saxon-help mailing list > saxon-help-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@xxxxxxxxxxxxxxxx > https://lists.sourceforge.net/lists/listinfo/saxon-help > ------------------------------------------------------- SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | External function binding bug (early binding): 00159, Wolfgang Hoschek |
|---|---|
| Next by Date: | Re: External function binding bug (early binding): 00159, Wolfgang Hoschek |
| Previous by Thread: | External function binding bug (early binding)i: 00159, Wolfgang Hoschek |
| Next by Thread: | Re: External function binding bug (early binding): 00159, Wolfgang Hoschek |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |