Issue Details (XML | Word | Printable)

Key: GROOVY-1912
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Paul King
Reporter: Aliaksandr Sebiashuk
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
groovy

GroovyScriptEngine.loadScriptByName is the cause of Stack Overflow Error

Created: 22/May/07 12:31 PM   Updated: 26/Sep/07 08:25 PM
Component/s: groovy-jdk
Affects Version/s: 1.1-beta-1
Fix Version/s: 1.1-beta-2

Time Tracking:
Not Specified

Environment: WinXP. Groovy 1.1-BETA-1. JDK 1.5.0_06


 Description  « Hide
ClassLoader cl = getClass().getClassLoader();
def engine = new GroovyScriptEngine(["file://."]*.toURL() as URL[], cl);
engine.loadScriptByName("TestGroovy2").newInstance();

Exception in thread "main" java.lang.StackOverflowError
at groovy.util.GroovyScriptEngine.loadScriptByName(GroovyScriptEngine.java:283)
at groovy.util.GroovyScriptEngine.loadScriptByName(GroovyScriptEngine.java:283)
at groovy.util.GroovyScriptEngine.loadScriptByName(GroovyScriptEngine.java:283)
.......



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Paul King added a comment - 16/Jun/07 05:52 PM
Should be fixed in head, but I made the method deprecated as it calls a deprecated method. I am not sure what the recomended alternative would be.

Aliaksandr Sebiashuk added a comment - 17/Jun/07 04:17 PM
I think you put comments to wrong function. look at this:

loadScriptByName

public Class loadScriptByName(String scriptName)
throws ResourceException,
ScriptException

Get the class of the scriptName in question, so that you can instantiate Groovy objects with caching and reloading. Note: This class is deprecated because we should not use a different parentClassLoader

Parameters:
scriptName -
Returns:
the loaded scriptName as a compiled class
Throws:
ResourceException
ScriptException

loadScriptByName

public Class loadScriptByName(String scriptName,
ClassLoader parentClassLoader)
throws ResourceException,
ScriptException

Deprecated.

Get the class of the scriptName in question, so that you can instantiate Groovy objects with caching and reloading.

Parameters:
scriptName -
Returns:
the loaded scriptName as a compiled class
Throws:
ResourceException
ScriptException



Aliaksandr Sebiashuk added a comment - 17/Jun/07 04:21 PM
I think you put comments to wrong function. look at this:

http://groovy.codehaus.org/api/groovy/util/GroovyScriptEngine.html#loadScriptByName(java.lang.String,%20java.lang.ClassLoader)

you put "Note: This class is deprecated because we should not use a different parentClassLoader" to
loadScriptByName(String scriptName)

instead of
loadScriptByName(String scriptName,
ClassLoader parentClassLoader)

anyway why


Aliaksandr Sebiashuk added a comment - 17/Jun/07 04:28 PM
sorry for multiposting, I use Ctrl+Enter in IM to start new line, but if FF it post message.

so, anyway why it can be a problem to use different parent classloaders?

I review all posts and found that: in my case I pass classLoader to GSE constructor not in "loadScriptByName()".


Paul King added a comment - 26/Sep/07 08:25 PM
No further feedback, assuming fixed