Maintenance: Planio will be observing a scheduled maintenance window this Tuesday, November 5, 2024 from 03:00 UTC until 06:30 UTC to perform urgent network maintenance in our primary data center. Your Planio account will be unavailable during this maintenance window.
NullPointerException during compilation
Added by Anonymous over 17 years ago
Legacy ID: #4431380 Legacy Poster: Bertrand Mirat (bemi)
Hi, I am using Saxon 8.8, trying to compile generated XQueries, and I get a NullPointerException instead of the expected StaticError... Here's an XQuery for reproducing the problem : for $i at $pos in $result return 'hello' Here is what I get (this happens while trying to bind "result") : java.lang.NullPointerException at net.sf.saxon.query.StaticQueryContext.bindVariable(StaticQueryContext.java:1416) at net.sf.saxon.expr.ExpressionParser.parseBasicStep(ExpressionParser.java:1239) at net.sf.saxon.expr.ExpressionParser.parseStepExpression(ExpressionParser.java:1187) at net.sf.saxon.expr.ExpressionParser.parseRelativePath(ExpressionParser.java:1127) at net.sf.saxon.expr.ExpressionParser.parsePathExpression(ExpressionParser.java:1113) at net.sf.saxon.expr.ExpressionParser.parseUnaryExpression(ExpressionParser.java:992) at net.sf.saxon.expr.ExpressionParser.parseCastExpression(ExpressionParser.java:650) at net.sf.saxon.expr.ExpressionParser.parseCastableExpression(ExpressionParser.java:605) at net.sf.saxon.expr.ExpressionParser.parseTreatExpression(ExpressionParser.java:586) at net.sf.saxon.expr.ExpressionParser.parseInstanceOfExpression(ExpressionParser.java:568) at net.sf.saxon.expr.ExpressionParser.parseIntersectExpression(ExpressionParser.java:1025) at net.sf.saxon.expr.ExpressionParser.parseUnionExpression(ExpressionParser.java:1007) at net.sf.saxon.expr.ExpressionParser.parseMultiplicativeExpression(ExpressionParser.java:944) at net.sf.saxon.expr.ExpressionParser.parseAdditiveExpression(ExpressionParser.java:924) at net.sf.saxon.expr.ExpressionParser.parseRangeExpression(ExpressionParser.java:840) at net.sf.saxon.expr.ExpressionParser.parseComparisonExpression(ExpressionParser.java:790) at net.sf.saxon.expr.ExpressionParser.parseAndExpression(ExpressionParser.java:380) at net.sf.saxon.expr.ExpressionParser.parseOrExpression(ExpressionParser.java:362) at net.sf.saxon.expr.ExpressionParser.parseExprSingle(ExpressionParser.java:316) at net.sf.saxon.query.QueryParser.parseForClause(QueryParser.java:1730) at net.sf.saxon.query.QueryParser.parseForExpression(QueryParser.java:1497) at net.sf.saxon.expr.ExpressionParser.parseExprSingle(ExpressionParser.java:300) at net.sf.saxon.expr.ExpressionParser.parseExpression(ExpressionParser.java:280) at net.sf.saxon.query.QueryParser.parseQuery(QueryParser.java:250) at net.sf.saxon.query.QueryParser.makeXQueryExpression(QueryParser.java:101) at net.sf.saxon.query.StaticQueryContext.compileQuery(StaticQueryContext.java:510) Oooh... Bug?
Replies (6)
Please register to reply
RE: NullPointerException during compilation - Added by Anonymous over 17 years ago
Legacy ID: #4431400 Legacy Poster: Michael Kay (mhkay)
I can't tell what's going on here because the line numbers in the stack trace don't match the Saxon 8.8 source code. Have you made any local modifications? Please see if you can reproduce this using Saxon 8.9.0.4. Michael Kay http://www.saxonica.com/
RE: NullPointerException during compilation - Added by Anonymous over 17 years ago
Legacy ID: #4431424 Legacy Poster: Bertrand Mirat (bemi)
Yes, the code has been updated : I have reformatted the code (Ctrl-Shift-F has became quite automatic to me :]) following integration of a Saxon 8.9 patch... So, here's a little more details : the NullPointerException occurs in StaticQueryContext.bindVariable(), on line : // importedModuleNamespaces == null => exception! if (importedModuleNamespaces.contains(uri)) { .. This is due to method bindVariable() being called on a StaticQueryContext object that has been instanciated earlier by StaticQueryContext.copy() called in StaticQueryContext.compileQuery(..) : copy() does not set the importedModuleNamespaces property and lets its value to null. And as far as I can see in Saxon 8.9 code, the copy() method has not changed, so I guess the problem should be the same. I hope this helps.
RE: NullPointerException during compilation - Added by Anonymous over 17 years ago
Legacy ID: #4431439 Legacy Poster: Bertrand Mirat (bemi)
I may also add that inserting the line n.importedModuleNamespaces = importedModuleNamespaces; ..before the last line of StaticQueryContext.copy() seemed to fix the issue, but I am not sure whether this is an appropriate fix (side-effects?). Would you approve this?
RE: NullPointerException during compilation - Added by Anonymous over 17 years ago
Legacy ID: #4431487 Legacy Poster: Michael Kay (mhkay)
I'm sorry: I'm not going to debug problems that are (a) on an old Saxon release, and (b) on code that is different from the code as issued. If you can reproduce it on 8.9.0.4 as released, I'll be happy to look at it.
RE: NullPointerException during compilation - Added by Anonymous over 17 years ago
Legacy ID: #4431560 Legacy Poster: Bertrand Mirat (bemi)
Well, I can't reproduce this error on saxon 8.9, so I guess I'll stick to my fix until we can migrate to saxon 8.9. Thanks for the answer anyway.
RE: NullPointerException during compilation - Added by Anonymous over 17 years ago
Legacy ID: #4432668 Legacy Poster: Bertrand Mirat (bemi)
I'll have to add this : the problem described was all my fault! I tried to apply the fix for saxon 8.9 bug 1730717 into my copy of saxon8.8, and I may have missed a thing or two. For those interested, the end of StaticQueryContext.copy () now reads : // [...] n.importers = importers; n.resetFunctionLibraries(); n.importedModuleNamespaces = new HashSet(importedModuleNamespaces); return n; } Thanks again for your answer.
Please register to reply