Issue Details (XML | Word | Printable)

Key: GROOVY-519
Type: Bug Bug
Status: Closed Closed
Resolution: Won't Fix
Priority: Major Major
Assignee: Guillaume Laforge
Reporter: Konstantin Sobolev
Votes: 1
Watchers: 1
Operations

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

BSF integration doesn't remember defined classes

Created: 04/Jun/04 06:34 PM   Updated: 02/Nov/07 05:56 AM
Component/s: None
Affects Version/s: 1.0-beta-6
Fix Version/s: None

Time Tracking:
Not Specified

Environment: Gentoo Linux, Sun JDK 1.4.2-04, one of beta-6 snapshots
Issue Links:
dependent
 


 Description  « Hide
Bug can be best illustrated by sample BSFConsole session (it uses BSFEngine.eval(..) call):

groovy% class test1{void foo(){println("test1: foo")}}; new test1().foo()

test1: foo

groovy% class test2{void foo(){println("test2: foo")}};
groovy% new test2().foo()

General error during class generation: No such class: test2 in constructor call for class: groovy_console. At [1:1] groovy_console
at org.codehaus.groovy.control.ProcessingUnit.fail(ProcessingUnit.java:466)
at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:939)
at org.codehaus.groovy.control.CompilationUnit.classgen(CompilationUnit.java:586)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:480)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:228)
at groovy.lang.GroovyShell.parseClass(GroovyShell.java:351)
at groovy.lang.GroovyShell.parse(GroovyShell.java:362)
at groovy.lang.GroovyShell.parse(GroovyShell.java:344)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:327)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:282)
at org.codehaus.groovy.bsf.GroovyEngine.eval(GroovyEngine.java:147)
at org.kos.bsfconsoleplugin.BSFInterpreter.eval(BSFInterpreter.java:153)
at org.kos.bsfconsoleplugin.BSFInterpreter$1.run(BSFInterpreter.java:118)
at java.lang.Thread.run(Thread.java:534)

So it allows to use defined classes inside single eval() call, but forgets them in consequent calls.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Konstantin Sobolev added a comment - 09/Jun/04 07:57 AM
Another issue which may have the same roots:

groovy% Class.forName("org.kos.bsfconsoleplugin.BSFConsoleConfig").newInstance()
org.kos.bsfconsoleplugin.BSFConsoleConfig@5762f7ce
groovy% org.kos.bsfconsoleplugin.BSFConsoleConfig cfg = new org.kos.bsfconsoleplugin.BSFConsoleConfig()
org.kos.bsfconsoleplugin.BSFConsoleConfig@5762f7ce
groovy% import org.kos.bsfconsoleplugin.BSFConsoleConfig; new BSFConsoleConfig()
org.kos.bsfconsoleplugin.BSFConsoleConfig@5762f7ce
groovy% import org.kos.bsfconsoleplugin.BSFConsoleConfig
groovy% new BSFConsoleConfig()
General error during class generation: No such class: BSFConsoleConfig in constructor call for class: groovy_console. At [1:1] groovy_console

So 'import' statement works only in the scope of single 'eval' call


Guillaume Laforge added a comment - 02/Nov/07 05:56 AM
With Java 6's own scripting APIs, it becomes less important to continue enhancing the BSF support.