[prev in list] [next in list] [prev in thread] [next in thread] 

List:       groovy-user
Subject:    Re: [groovy-user] class name from static method
From:       Roshan Dawrani <roshandawrani () codehaus ! org>
Date:       2009-10-31 18:41:54
Message-ID: 522638960910311129t63c224e9yc9452cd0cfb3b20a () mail ! gmail ! com
[Download RAW message or body]

This issue should be found fixed in current 1.6.6 and 1.7-rc-1 snapshots
now.

-- Roshan

On Sat, Oct 31, 2009 at 11:06 PM, Roshan Dawrani <roshandawrani@codehaus.org
> wrote:

> I created GROOVY-3863 for it.
>
>
> On Sat, Oct 31, 2009 at 11:02 PM, Robert Fischer <
> robert.fischer@smokejumperit.com> wrote:
>
>> Sounds like a JIRA to me.
>>
>> ~~ Robert Fischer, Smokejumper IT Consulting.
>> Enfranchised Mind Blog http://EnfranchisedMind.com/blog
>>
>> Grails Expert Retainer Services
>> http://smokejumperit.com/grails-retainer/
>>
>>
>>
>> roshandawrani@gmail.com wrote:
>>
>>> I just noticed that you are invoking this.name from main(), so that bit
>>> was different and I had tried it a non-main() method. So issue you have
>>> pointed out may be in both 1.6 and 1.7.
>>> It should behave same, though.
>>> I will give it a try later and see what makes main() different.
>>>
>>>
>>> ------Original Message------
>>> From: Peter Niederwieser
>>> To: user@groovy.codehaus.org
>>> ReplyTo: user@groovy.codehaus.org
>>> Subject: Re: [groovy-user] class name from static method
>>> Sent: Oct 31, 2009 7:36 PM
>>>
>>>
>>> Doesn't work for me (Groovy 1.6.6-SNAPSHOT). The following:
>>>
>>> class Foo {
>>>  static main(args) {
>>>    println this.name
>>>  }
>>> }
>>>
>>> results in:
>>>
>>> java.lang.ClassCastException: java.lang.Class cannot be cast to
>>> groovy.lang.GroovyObject
>>>
>>> However, "println this.getName()" does work.
>>>
>>> Cheers,
>>> Peter
>>>
>>>
>>> Roshan Dawrani-2 wrote:
>>>
>>>> Yes, there is.
>>>>
>>>> ==================
>>>> class Foo {
>>>>  static m() {
>>>>    println this.name
>>>>  }
>>>> }
>>>>
>>>> Foo.m()
>>>> ==================
>>>>
>>>> This works because in static context, groovy maps calls on "this" to
>>>> calls
>>>> on the class.
>>>>
>>>> -- Roshan
>>>>
>>>> On Sat, Oct 31, 2009 at 2:28 AM, Francesco Pasqualini
>>>> <frapas@gmail.com>wrote:
>>>>
>>>>  Hi all,
>>>>> is there a way to get the class name from inside a static method ?
>>>>>
>>>>> thanks
>>>>> --
>>>>> Francesco
>>>>>
>>>>>
>>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>   http://xircles.codehaus.org/manage_email
>>
>>
>>
>

[Attachment #3 (text/html)]

This issue should be found fixed in current 1.6.6 and 1.7-rc-1 snapshots \
now.<br><br>-- Roshan<br><br><div class="gmail_quote">On Sat, Oct 31, 2009 at 11:06 \
PM, Roshan Dawrani <span dir="ltr">&lt;<a \
href="mailto:roshandawrani@codehaus.org">roshandawrani@codehaus.org</a>&gt;</span> \
wrote:<br> <blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, \
204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I created GROOVY-3863 for \
it.<div><div></div><div class="h5"><br><br><div class="gmail_quote"> On Sat, Oct 31, \
2009 at 11:02 PM, Robert Fischer <span dir="ltr">&lt;<a \
href="mailto:robert.fischer@smokejumperit.com" \
target="_blank">robert.fischer@smokejumperit.com</a>&gt;</span> wrote:<br> \
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); \
margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Sounds like a JIRA to me.<br> <br>
~~ Robert Fischer, Smokejumper IT Consulting.<br>
Enfranchised Mind Blog <a href="http://EnfranchisedMind.com/blog" \
target="_blank">http://EnfranchisedMind.com/blog</a><br> <br>
Grails Expert Retainer Services<br>
<a href="http://smokejumperit.com/grails-retainer/" \
target="_blank">http://smokejumperit.com/grails-retainer/</a><div><div></div><div><br>
 <br>
<br>
<a href="mailto:roshandawrani@gmail.com" target="_blank">roshandawrani@gmail.com</a> \
wrote:<br> <blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, \
204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> I just noticed that you \
are invoking <a href="http://this.name" target="_blank">this.name</a> from main(), so \
that bit was different and I had tried it a non-main() method. So issue you have \
pointed out may be in both 1.6 and 1.7. <br>


It should behave same, though. <br>
I will give it a try later and see what makes main() different.<br>
<br>
<br>
------Original Message------<br>
From: Peter Niederwieser<br>
To: <a href="mailto:user@groovy.codehaus.org" \
                target="_blank">user@groovy.codehaus.org</a><br>
ReplyTo: <a href="mailto:user@groovy.codehaus.org" \
                target="_blank">user@groovy.codehaus.org</a><br>
Subject: Re: [groovy-user] class name from static method<br>
Sent: Oct 31, 2009 7:36 PM<br>
<br>
<br>
Doesn&#39;t work for me (Groovy 1.6.6-SNAPSHOT). The following:<br>
<br>
class Foo {<br>
  static main(args) {<br>
    println <a href="http://this.name" target="_blank">this.name</a><br>
  }<br>
}<br>
<br>
results in:<br>
<br>
java.lang.ClassCastException: java.lang.Class cannot be cast to<br>
groovy.lang.GroovyObject<br>
<br>
However, &quot;println this.getName()&quot; does work.<br>
<br>
Cheers,<br>
Peter<br>
<br>
<br>
Roshan Dawrani-2 wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); \
margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> Yes, there is.<br>
<br>
==================<br>
class Foo {<br>
  static m() {<br>
    println <a href="http://this.name" target="_blank">this.name</a><br>
  }<br>
}<br>
<br>
Foo.m()<br>
==================<br>
<br>
This works because in static context, groovy maps calls on &quot;this&quot; to \
calls<br> on the class.<br>
<br>
-- Roshan<br>
<br>
On Sat, Oct 31, 2009 at 2:28 AM, Francesco Pasqualini<br>
&lt;<a href="mailto:frapas@gmail.com" \
target="_blank">frapas@gmail.com</a>&gt;wrote:<br> <br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); \
margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> Hi all,<br>
is there a way to get the class name from inside a static method ?<br>
<br>
thanks<br>
--<br>
Francesco<br>
<br>
</blockquote>
<br>
</blockquote>
<br>
</blockquote>
<br></div></div><div><div></div><div>
---------------------------------------------------------------------<br>
To unsubscribe from this list, please visit:<br>
<br>
   <a href="http://xircles.codehaus.org/manage_email" \
target="_blank">http://xircles.codehaus.org/manage_email</a><br> <br>
<br>
</div></div></blockquote></div><br>
</div></div></blockquote></div><br>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic