groovy

GroovyScriptEngine.loadScriptByName is the cause of Stack Overflow Error

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.1-beta-1
  • Fix Version/s: 1.1-beta-2
  • Component/s: groovy-jdk
  • Labels:
    None
  • Environment:
    WinXP. Groovy 1.1-BETA-1. JDK 1.5.0_06
  • Number of attachments :
    0

Description

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)
.......

Activity

Hide
Paul King added a comment -

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.

Show
Paul King added a comment - 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.
Hide
Aliaksandr Sebiashuk added a comment -

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

Show
Aliaksandr Sebiashuk added a comment - 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
Hide
Aliaksandr Sebiashuk added a comment -

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

Show
Aliaksandr Sebiashuk added a comment - 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
Hide
Aliaksandr Sebiashuk added a comment -

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()".

Show
Aliaksandr Sebiashuk added a comment - 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()".
Hide
Paul King added a comment -

No further feedback, assuming fixed

Show
Paul King added a comment - No further feedback, assuming fixed

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: