groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Øyvind Stegard (JIRA) <j...@apache.org>
Subject [jira] [Created] (GROOVY-8278) Groovysh: unable to resolve previously declared classes
Date Mon, 07 Aug 2017 05:40:00 GMT
Øyvind Stegard created GROOVY-8278:
--------------------------------------

             Summary: Groovysh: unable to resolve previously declared classes
                 Key: GROOVY-8278
                 URL: https://issues.apache.org/jira/browse/GROOVY-8278
             Project: Groovy
          Issue Type: Bug
          Components: Groovysh
    Affects Versions: 2.4.11
         Environment: Linux x86-64,
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
            Reporter: Øyvind Stegard


Classes declared in a Groovysh session cannot be used properly later on.

This fails:
{code:java}
class C { }
instance = new C()
{code}

However, this works:
{code:java}
class C { }
new C()
{code}


Groovysh session showing the issue:
{noformat}
groovysh -d
DEBUG [org.codehaus.groovy.tools.shell.BufferManager] Created new buffer with index: 0
DEBUG [org.codehaus.groovy.tools.shell.BufferManager] Buffers reset
DEBUG [org.codehaus.groovy.tools.shell.Parser] Using parser flavor: rigid
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: ?
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: :help
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: :quit
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: :exit
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: import
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: :display
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: :clear
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: :show
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: :inspect
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: :purge
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: :edit
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: .
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: :load
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: :save
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: :record
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: :history
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: :alias
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: :set
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: :register
DEBUG [org.codehaus.groovy.tools.shell.CommandRegistry] Registered command: :doc
DEBUG [org.codehaus.groovy.tools.shell.InteractiveShellRunner] Using history file: /home/oyvind/.groovy/groovysh.history
DEBUG [org.codehaus.groovy.tools.shell.Groovysh] Terminal (jline.UnixTerminal@d737b89)
DEBUG [org.codehaus.groovy.tools.shell.Groovysh]     Supported:  true
DEBUG [org.codehaus.groovy.tools.shell.Groovysh]     ECHO:       (enabled: false)
DEBUG [org.codehaus.groovy.tools.shell.Groovysh]     H x W:      64 x 115
DEBUG [org.codehaus.groovy.tools.shell.Groovysh]     ANSI:       true
Groovy Shell (2.4.12, JVM: 1.8.0_144)
Type ':help' or ':h' for help.
------------------------------------------------------------------------------------------------------------------
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[1] for command:
:help
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[2] for command:
?
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[3] for command:
:exit
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[4] for command:
:quit
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[5] for command:
import
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[6] for command:
:display
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[7] for command:
:clear
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[8] for command:
:show
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[9] for command:
:inspect
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[10] for command:
:purge
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[11] for command:
:edit
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[12] for command:
:load
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[13] for command:
.
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[14] for command:
:save
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[15] for command:
:record
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[16] for command:
:history
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[17] for command:
:alias
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[18] for command:
:set
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[19] for command:
:register
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Added completer[20] for command:
:doc
DEBUG [org.codehaus.groovy.tools.shell.CommandsMultiCompleter] Refreshing the completer list
DEBUG [org.codehaus.groovy.tools.shell.InteractiveShellRunner] Running
groovy:000> class C { }
DEBUG [org.codehaus.groovy.tools.shell.InteractiveShellRunner] Read line: class C { }
DEBUG [org.codehaus.groovy.tools.shell.RigidParser] Parsing: 
class C { }
DEBUG [org.codehaus.groovy.tools.shell.RigidParser] Parse complete
DEBUG [org.codehaus.groovy.tools.shell.Groovysh] Evaluating buffer...
DEBUG [org.codehaus.groovy.tools.shell.Interpreter] Compiled script: groovysh_evaluate@4b213651
DEBUG [org.codehaus.groovy.tools.shell.Interpreter] Evaluation result: true (class java.lang.Boolean)
===> true
groovy:000> C
DEBUG [org.codehaus.groovy.tools.shell.InteractiveShellRunner] Read line: C
DEBUG [org.codehaus.groovy.tools.shell.RigidParser] Parsing: 
C
DEBUG [org.codehaus.groovy.tools.shell.RigidParser] Parse complete
DEBUG [org.codehaus.groovy.tools.shell.Groovysh] Evaluating buffer...
DEBUG [org.codehaus.groovy.tools.shell.Interpreter] Compiled script: groovysh_evaluate@5d066c7d
DEBUG [org.codehaus.groovy.tools.shell.Interpreter] Evaluation result: class C (class java.lang.Class)
===> class C
groovy:000> instance = new C()
DEBUG [org.codehaus.groovy.tools.shell.InteractiveShellRunner] Read line: instance = new C()
DEBUG [org.codehaus.groovy.tools.shell.RigidParser] Parsing: 
instance = new C()
DEBUG [org.codehaus.groovy.tools.shell.RigidParser] Parse complete
DEBUG [org.codehaus.groovy.tools.shell.Groovysh] Evaluating buffer...
DEBUG [org.codehaus.groovy.tools.shell.InteractiveShellRunner] Work failed: org.codehaus.groovy.control.MultipleCompilationErrorsException:
startup failed:
script15020841055791703884630.groovy: 1: unable to resolve class C 
 @ line 1, column 12.
   instance = new C()
              ^

1 error

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
script15020841055791703884630.groovy: 1: unable to resolve class C 
 @ line 1, column 12.
   instance = new C()
              ^

1 error

	at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310)
	at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:958)
	at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:605)
	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:554)
	at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:254)
	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:211)
	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:221)
	at groovy.lang.GroovyClassLoader$parseClass.call(Unknown Source)
	at org.codehaus.groovy.tools.shell.util.ScriptVariableAnalyzer.getBoundVars(ScriptVariableAnalyzer.groovy:110)
	at org.codehaus.groovy.tools.shell.util.ScriptVariableAnalyzer$getBoundVars.call(Unknown
Source)
	at org.codehaus.groovy.tools.shell.Groovysh.evaluateWithStoredBoundVars(Groovysh.groovy:235)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210)
	at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
	at org.codehaus.groovy.tools.shell.Groovysh.execute(Groovysh.groovy:194)
	at org.codehaus.groovy.tools.shell.Shell.leftShift(Shell.groovy:122)
	at org.codehaus.groovy.tools.shell.Shell$leftShift$0.call(Unknown Source)
	at org.codehaus.groovy.tools.shell.ShellRunner.work(ShellRunner.groovy:95)
	at org.codehaus.groovy.tools.shell.InteractiveShellRunner.super$2$work(InteractiveShellRunner.groovy)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:132)
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuper0(ScriptBytecodeAdapter.java:152)
	at org.codehaus.groovy.tools.shell.InteractiveShellRunner.work(InteractiveShellRunner.groovy:124)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210)
	at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:158)
	at org.codehaus.groovy.tools.shell.ShellRunner.run(ShellRunner.groovy:59)
	at org.codehaus.groovy.tools.shell.InteractiveShellRunner.super$2$run(InteractiveShellRunner.groovy)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:132)
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuper0(ScriptBytecodeAdapter.java:152)
	at org.codehaus.groovy.tools.shell.InteractiveShellRunner.run(InteractiveShellRunner.groovy:83)
	at java_lang_Runnable$run.call(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
	at org.codehaus.groovy.tools.shell.Groovysh.run(Groovysh.groovy:596)
	at org.codehaus.groovy.tools.shell.Groovysh$run$0.callCurrent(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
	at org.codehaus.groovy.tools.shell.Groovysh.run(Groovysh.groovy:561)
	at org.codehaus.groovy.tools.shell.Groovysh$run.call(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
	at org.codehaus.groovy.tools.shell.Main.startGroovysh(Main.groovy:186)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210)
	at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:71)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
	at org.codehaus.groovy.tools.shell.Main.main(Main.groovy:152)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:109)
	at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:131)
ERROR org.codehaus.groovy.control.MultipleCompilationErrorsException:
script15020841055791703884630.groovy: 1: unable to resolve class C 
 @ line 1, column 12.
   instance = new C()
              ^

groovy:000> new C()
DEBUG [org.codehaus.groovy.tools.shell.InteractiveShellRunner] Read line: new C()
DEBUG [org.codehaus.groovy.tools.shell.RigidParser] Parsing: 
new C()
DEBUG [org.codehaus.groovy.tools.shell.RigidParser] Parse complete
DEBUG [org.codehaus.groovy.tools.shell.Groovysh] Evaluating buffer...
DEBUG [org.codehaus.groovy.tools.shell.Interpreter] Compiled script: groovysh_evaluate@64a40280
DEBUG [org.codehaus.groovy.tools.shell.Interpreter] Evaluation result: C@42b02722 (class C)
===> C@42b02722
{noformat}




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message