groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Erland Muller (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GROOVY-7168) I am unable to instantiate objects using the "new" keyword
Date Fri, 09 Jun 2017 22:17:18 GMT

    [ https://issues.apache.org/jira/browse/GROOVY-7168?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16045117#comment-16045117
] 

Erland Muller commented on GROOVY-7168:
---------------------------------------

The issue is not resolved. It affects groovysh 2.4.11 and 2.4.10 on GNU/Linux 3.2.0-4-686,
Debian 3.2 with both, java-7-openjdk-i386 or java-8-oracle. The bug is not present in groovysh
2.3.11.

To reproduce the problem open groovysh and enter the statements:
class A{}
new A()   // works
a= new A()   // fails with 
script14970460910271311459934.groovy: 1: unable to resolve class A 
 @ line 1, column 4.
   a= new A()
       ^
A a   // also fails:
cript149704620105463554.groovy: 1: unable to resolve class A 
 @ line 1, column 3.
   A a
     ^
Below is the output demonstrating the error with the debug option set:

Groovy Shell (2.4.11, JVM: 1.8.0_131)
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 A{}
DEBUG [org.codehaus.groovy.tools.shell.InteractiveShellRunner] Read line: class A{}
DEBUG [org.codehaus.groovy.tools.shell.RigidParser] Parsing: 
class A{}
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@f0a9da
DEBUG [org.codehaus.groovy.tools.shell.Interpreter] Evaluation result: true (class java.lang.Boolean)
===> true
groovy:000> new A()
DEBUG [org.codehaus.groovy.tools.shell.InteractiveShellRunner] Read line: new A()
DEBUG [org.codehaus.groovy.tools.shell.RigidParser] Parsing: 
new A()
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@1e731e
DEBUG [org.codehaus.groovy.tools.shell.Interpreter] Evaluation result: A@1c407fd (class A)
===> A@1c407fd
groovy:000> A a
DEBUG [org.codehaus.groovy.tools.shell.InteractiveShellRunner] Read line: A a
DEBUG [org.codehaus.groovy.tools.shell.RigidParser] Parsing: 
A a
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:
script149704352028763554.groovy: 1: unable to resolve class A 
 @ line 1, column 3.
   A a
     ^

1 error

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
script149704352028763554.groovy: 1: unable to resolve class A 
 @ line 1, column 3.
   A a
     ^

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.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:125)
	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.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:125)
	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.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.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:
script149704352028763554.groovy: 1: unable to resolve class A 
 @ line 1, column 3.
   A a
     ^

groovy:000> 



> I am unable to instantiate objects using the "new" keyword
> ----------------------------------------------------------
>
>                 Key: GROOVY-7168
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7168
>             Project: Groovy
>          Issue Type: Bug
>          Components: Groovysh
>    Affects Versions: 2.4.0-beta-3
>         Environment: Linux - Debian jessie/sid 64 bits
>            Reporter: Hector Satizabal
>             Fix For: 2.4.0-rc-1
>
>         Attachments: testA.groovy
>
>
> I am embedding Groovysh in a java application. After some tests, I realized that the
"new" keyword seems to not work in the last groovysh version. When I try to do:
> a = new A()
> I obtain: "unable to resolve class A"
> This is an example:
> groovy:000> class A {
> class A {
> groovy:001>   public A() {
> public A() {
> groovy:002>     name = "default"
> name = "default"
> groovy:003>     }
> }
> groovy:004>   String name;
> String name;
> groovy:005>   }
> }
> ===> true
> groovy:000> a = new A()
> a = new A()
> ERROR org.codehaus.groovy.control.MultipleCompilationErrorsException:
> startup failed:
> script14159599676571305654112.groovy: 1: unable to resolve class A 
>  @ line 1, column 5.
>    a = new A()
>        ^
> 1 error
> However, if I use the newInstance method it works:
> groovy:000> a = A.newInstance()
> a = A.newInstance()
> ===> A@2154cecb
> I tested the same code in the previous version (2.3.7) and it works



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message