[groovy-user] NPE for correct code in Groovy web console - 1.8 issue?

19 views
Skip to first unread message

Evgeny Goldin

unread,
Oct 12, 2010, 6:49:43 PM10/12/10
to us...@groovy.codehaus.org
http://groovyconsole.appspot.com/script/275001:

class LockableList
{
@Delegate private List list = []
}
 
assert new LockableList() instanceof List

causes:

java.lang.NullPointerException
	at com.sun.beans.TypeResolver.resolve(TypeResolver.java:321)
	at com.sun.beans.TypeResolver.resolve(TypeResolver.java:303)
	at com.sun.beans.TypeResolver.resolve(TypeResolver.java:351)
	at com.sun.beans.TypeResolver.resolve(TypeResolver.java:172)
	at com.sun.beans.TypeResolver.resolveInClass(TypeResolver.java:93)
	at Script1.run(Script1.groovy:6)

If I comment out an assert then I get:

java.lang.NullPointerException
	at com.sun.beans.TypeResolver.resolve(TypeResolver.java:321)
	at com.sun.beans.TypeResolver.resolve(TypeResolver.java:303)
	at com.sun.beans.TypeResolver.resolve(TypeResolver.java:351)
	at com.sun.beans.TypeResolver.resolve(TypeResolver.java:172)
	at com.sun.beans.TypeResolver.resolveInClass(TypeResolver.java:93)
	at LockableList.$getStaticMetaClass(Script1.groovy)
	at LockableList.(Script1.groovy:3)

Can it be Groovy 1.8 beta issue? It works fine in GroovyConsole v1.7.5.
Best regards,
Evgeny
http://evgeny-goldin.com/


View this message in context: NPE for correct code in Groovy web console - 1.8 issue?
Sent from the groovy - user mailing list archive at Nabble.com.

roshan...@gmail.com

unread,
Oct 12, 2010, 10:38:34 PM10/12/10
to us...@groovy.codehaus.org
This is something specific to OpenJDK and not groovy 1.7 or 1.8 - if you run the same @Delegate code on groovy web console version that has 1.7.x, you will get the same error.

I have fixed this issue already in 1.8-beta-3 and 1.7.6.

Web console is on 1.8-beta-2 and I requested its upgrade to 1.8-beta-3, but so far it has not been done.

So waiting for it.

---------------------------------------------------
Sent from BlackBerry


From: Evgeny Goldin <evg...@gmail.com>
Date: Tue, 12 Oct 2010 15:49:43 -0700 (PDT)
Subject: [groovy-user] NPE for correct code in Groovy web console - 1.8 issue?

Evgeny Goldin

unread,
Oct 13, 2010, 3:40:07 AM10/13/10
to us...@groovy.codehaus.org
I see. Thank you for the update!
--

Guillaume Laforge

unread,
Oct 15, 2010, 9:04:10 AM10/15/10
to us...@groovy.codehaus.org
Roshan,

I've updated the Groovy Web Console with Groovy 1.8-beta-3-SNAPSHOT.
The @Delegate issue disapeared :-)

Guillaume

On Wed, Oct 13, 2010 at 04:38, <roshan...@gmail.com> wrote:

--
Guillaume Laforge
Groovy Project Manager
Head of Groovy Development at SpringSource
http://www.springsource.com/g2one

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


Guillaume Laforge

unread,
Oct 15, 2010, 9:09:19 AM10/15/10
to us...@groovy.codehaus.org
So if you want to test the script on the console:

http://groovyconsole.appspot.com/edit/275001

And if you want to use 1.7.5, where it's failing:
http://175.latest.groovyconsole.appspot.com/edit/275001

You'll notice that we now have a version of the console with Groovy
1.8-beta-3 snapshot, and one with Groovy 1.7.5 :-)

Guillaume

Tim Yates

unread,
Oct 15, 2010, 9:09:31 AM10/15/10
to us...@groovy.codehaus.org
Cool :-)

Looks like parsing may have changed though...

The basic interpreter on the webconsole now needs line 83 changing from:

    if( get(0).type == type1 && get(1).type == type2 ) token += 2 else false

to

    if( get(0).type == type1 && get(1).type == type2 ) { token += 2 } else false

Otherwise, you get:
Script1.groovy: 83: unexpected token: else @ line 83, column 67.
   1).type == type2 ) token += 2 else false
Tim

Guillaume Laforge

unread,
Oct 15, 2010, 9:15:08 AM10/15/10
to us...@groovy.codehaus.org
Interesting...
Could you file a JIRA issue please?

Roshan Dawrani

unread,
Oct 15, 2010, 9:16:09 AM10/15/10
to us...@groovy.codehaus.org
Generics related fix done for OpenJDK (6 / 7) has nothing to with groovy grammar.

If you are noticing any grammar related side-effect, it may be due to some other fix made in that area and someone may trace it down for you, if it matters much. Or you can report it separately.
--
rgds,
Roshan
http://roshandawrani.wordpress.com/
http://twitter.com/roshandawrani


Guillaume Laforge

unread,
Oct 15, 2010, 9:18:47 AM10/15/10
to us...@groovy.codehaus.org
This is perhaps due to the GEP-3 changes.
To be confirmed.

Tim Yates

unread,
Oct 15, 2010, 9:57:02 AM10/15/10
to us...@groovy.codehaus.org
Done :-)

http://jira.codehaus.org/browse/GROOVY-4480

It's only a minor thing, but could be indicative of a change that wasn't meant to occur?

Tim

Guillaume Laforge

unread,
Oct 15, 2010, 10:06:50 AM10/15/10
to us...@groovy.codehaus.org
On Fri, Oct 15, 2010 at 15:57, Tim Yates <tim....@gmail.com> wrote:
> Done :-)
>
> http://jira.codehaus.org/browse/GROOVY-4480

Thanks.

> It's only a minor thing, but could be indicative of a change that wasn't
> meant to occur?

I think so too :-)

Evgeny Goldin

unread,
Oct 16, 2010, 4:59:51 AM10/16/10
to us...@groovy.codehaus.org

Here's another code that works with 1.7.5 and fails in Groovy web console
(can't post it now, the console seems malfunctioning as it doesn't show
recent posts and doesn't accept a new ones)


Number.metaClass.m = { amount -> ( delegate.multiply( amount )) }
Number.metaClass.d = { amount -> ( delegate.div( amount )) }

assert 15 == 3.m( 5 )
assert 5.3333333333 == 16.d( 3 )

The exception is

groovy.lang.MissingMethodException: No signature of method:
java.lang.Integer.times() is applicable for argument types:
(java.lang.Integer) values: [3]
Possible solutions: times(groovy.lang.Closure), power(java.lang.Integer),
is(java.lang.Object), minus(java.lang.Number), minus(java.lang.Character),
abs()
at Script1$_run_closure1.doCall(Script1.groovy:1)
at Script1$_run_closure1.doCall(Script1.groovy:1)
at Script1.run(Script1.groovy:5)


-----


Best regards,
Evgeny
http://evgeny-goldin.com/

--
View this message in context: http://groovy.329449.n5.nabble.com/NPE-for-correct-code-in-Groovy-web-console-1-8-issue-tp3209754p3214925.html


Sent from the groovy - user mailing list archive at Nabble.com.

---------------------------------------------------------------------

Roshan Dawrani

unread,
Oct 16, 2010, 5:35:00 AM10/16/10
to us...@groovy.codehaus.org
Seems to be working fine. Can't get the error you reported - http://groovyconsole.appspot.com/script/285001

Even your 2 scripts seem to be published fine there on the web console and both work. Or, am I imagining things? :-)

Evgeny Goldin

unread,
Oct 16, 2010, 8:02:48 AM10/16/10
to us...@groovy.codehaus.org
Hmm, it works now indeed. 
Probably, there was some temporal issue with web console.
--
Reply all
Reply to author
Forward
0 new messages