Details
-
Sub-task
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
1.0-JSR-5
-
None
-
None
-
WinXP, Java 1.5.0_06
Description
I've been having some fun getting the GroovyScriptEngine to load groovy scripts from the same directory as the compiled class files. I wrote a ResourceConnector to turn named resources into URLConnections with code to the effect of: "CLASS.getResource(name).openConnection()", but it failed with the following exception:
Exception in thread "main" BUG! exception in phase 'semantic analysis' in source unit 'resource_xml.groovy' null
It turns out that the script was being accessed correctly via my ResourceConnector, but when processing a bound variable inside the script ("${config.bg}") the ResourceConnector was again being used to try and load "config.groovy". As this file didn't exist, the ResourceConnector threw an NPE, which propagated up the stack where it was misinterpreted as an internal error. (The fix was to wrap the RuntimeException in a ResourceException before throwing it.)
I would like to suggest that documentation for the GroovyScriptEngine(ResourceConnector) constructor should mention how the ResourceConnector will be used, and that runtime exceptions from user-supplied objects should not be able to give the impression that an internal error occurred.