Favicon

[groovy-dev] Can't run a file with - in it

Is this supposed to happen?

➔ target/install/bin/groovy recursive-blah.groovy
Caught: java.lang.ClassFormatError: Illegal class name "recursive-blah" 
in class file recursive-blah

- Charlie

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

    http://xircles.codehaus.org/manage_email

Guillaume Laforge | 14 Aug 21:08
Gravatar

Re: [groovy-dev] Can't run a file with - in it

Yes, the script name has to be a valid Java class name.
We don't do any string mangling to make valid Java class names from
script file names.
It's arbitrary though :-)

On Thu, Aug 14, 2008 at 9:05 PM, Charles Oliver Nutter
<charles.nutter <at> sun.com> wrote:
> Is this supposed to happen?
>
> ➔ target/install/bin/groovy recursive-blah.groovy
> Caught: java.lang.ClassFormatError: Illegal class name "recursive-blah" in
> class file recursive-blah

--

-- 
Guillaume Laforge
Groovy Project Manager
G2One, Inc. Vice-President Technology
http://www.g2one.com
Favicon

Re: [groovy-dev] Can't run a file with - in it

Ok, why not mangle? Seems like a language intended for scripting 
shouldn't have arbitrary naming restrictions for the name of the script.

Guillaume Laforge wrote:
> Yes, the script name has to be a valid Java class name.
> We don't do any string mangling to make valid Java class names from
> script file names.
> It's arbitrary though :-)
> 
> On Thu, Aug 14, 2008 at 9:05 PM, Charles Oliver Nutter
> <charles.nutter@...> wrote:
>> Is this supposed to happen?
>>
>> ➔ target/install/bin/groovy recursive-blah.groovy
>> Caught: java.lang.ClassFormatError: Illegal class name "recursive-blah" in
>> class file recursive-blah
> 
> 
> 

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

    http://xircles.codehaus.org/manage_email

Jochen Theodorou | 15 Aug 00:41
Gravatar

Re: [groovy-dev] Can't run a file with - in it

Charles Oliver Nutter schrieb:
> Ok, why not mangle? Seems like a language intended for scripting 
> shouldn't have arbitrary naming restrictions for the name of the script.

simple, we never came up with rules ;) For most users it doesn't seem to 
be of interest.

bye blackdrag

--

-- 
Jochen "blackdrag" Theodorou
The Groovy Project Tech Lead (http://groovy.codehaus.org)
http://blackdragsview.blogspot.com/
http://www.g2one.com/

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

    http://xircles.codehaus.org/manage_email

Luke Daley | 15 Aug 01:53

Re: [groovy-dev] Can't run a file with - in it


On 15/08/2008, at 8:41 AM, Jochen Theodorou wrote:

>> Ok, why not mangle? Seems like a language intended for scripting  
>> shouldn't have arbitrary naming restrictions for the name of the  
>> script.
>
> simple, we never came up with rules ;) For most users it doesn't  
> seem to be of interest.

I went looking for a Jira ticket to vote on but couldn't find one.  
Anyone know if there is one?

--

LD.

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

    http://xircles.codehaus.org/manage_email

Danno Ferrin | 15 Aug 05:49
Favicon
Gravatar

Re: [groovy-dev] Can't run a file with - in it

Sounds like it doesn't exist yet.  Perhaps you could post one and some possible mappings?  My main concern is whatever it is that it should have a one to one mapping in almost all cases.

On Thu, Aug 14, 2008 at 5:53 PM, Luke Daley <ld-Hc2V4H83aCrQT0dZR+AlfA@public.gmane.org> wrote:

On 15/08/2008, at 8:41 AM, Jochen Theodorou wrote:

Ok, why not mangle? Seems like a language intended for scripting shouldn't have arbitrary naming restrictions for the name of the script.

simple, we never came up with rules ;) For most users it doesn't seem to be of interest.

I went looking for a Jira ticket to vote on but couldn't find one. Anyone know if there is one?

--

LD.



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

  http://xircles.codehaus.org/manage_email





--
------------------------------------------------------
I'm Danno Ferrin, and I approved this message.
Luke Daley | 15 Aug 05:52

Re: [groovy-dev] Can't run a file with - in it


On 15/08/2008, at 1:49 PM, Danno Ferrin wrote:

> Sounds like it doesn't exist yet.  Perhaps you could post one and  
> some possible mappings?  My main concern is whatever it is that it  
> should have a one to one mapping in almost all cases.

Is '_' legal? If so, why not map anything that is illegal to '_'?

--

LD.

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

    http://xircles.codehaus.org/manage_email

Russel Winder | 15 Aug 07:47

Re: [groovy-dev] Can't run a file with - in it

On Fri, 2008-08-15 at 13:52 +1000, Luke Daley wrote:
> On 15/08/2008, at 1:49 PM, Danno Ferrin wrote:
> 
> > Sounds like it doesn't exist yet.  Perhaps you could post one and  
> > some possible mappings?  My main concern is whatever it is that it  
> > should have a one to one mapping in almost all cases.
> 
> Is '_' legal? If so, why not map anything that is illegal to '_'?

Step back a minute.

You cannot use - in the file name of a Java source file because the file
name must be the same as the class name and the class name cannot
contain - because of the rules of Java naming.

By analogy there is a good rule to follow:  You cannot use - in the file
name of a Groovy source file that contains a class because the file name
must be the same as the class name and the class name cannot contain -
because of the rules of Java naming.

Continuing:  Is it wise to have two different file naming rules for the
case where a file contains a class, and the case where the file contains
a script.  For me this is the important case.  Is total consistency of
naming more important allowing - in a file name in some cases?

--

-- 
Russel.
====================================================
Dr Russel Winder                 Partner

Concertant LLP                   t: +44 20 7585 2200, +44 20 7193 9203
41 Buckmaster Road,              f: +44 8700 516 084
London SW11 1EN, UK.             m: +44 7770 465 077
Luke Daley | 15 Aug 07:55

Re: [groovy-dev] Can't run a file with - in it


On 15/08/2008, at 3:47 PM, Russel Winder wrote:

>>> Sounds like it doesn't exist yet.  Perhaps you could post one and
>>> some possible mappings?  My main concern is whatever it is that it
>>> should have a one to one mapping in almost all cases.
>>
>> Is '_' legal? If so, why not map anything that is illegal to '_'?
>
> Step back a minute.
>
> You cannot use - in the file name of a Java source file because the  
> file
> name must be the same as the class name and the class name cannot
> contain - because of the rules of Java naming.
>
> By analogy there is a good rule to follow:  You cannot use - in the  
> file
> name of a Groovy source file that contains a class because the file  
> name
> must be the same as the class name and the class name cannot contain -
> because of the rules of Java naming.
>
> Continuing:  Is it wise to have two different file naming rules for  
> the
> case where a file contains a class, and the case where the file  
> contains
> a script.  For me this is the important case.  Is total consistency of
> naming more important allowing - in a file name in some cases?

In my opinion, the fact that a script creates a class of the same  
name is an implementation detail and for the majority of usage  
doesn't come into play. I see it as more likely that users will want  
'illegal' characters in their script filenames, than want to use the  
classname of the script.

--

LD.

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

    http://xircles.codehaus.org/manage_email

Russel Winder | 15 Aug 10:43

Re: [groovy-dev] Can't run a file with - in it

On Fri, 2008-08-15 at 15:55 +1000, Luke Daley wrote:

> In my opinion, the fact that a script creates a class of the same  
> name is an implementation detail and for the majority of usage  
> doesn't come into play. I see it as more likely that users will want  
> 'illegal' characters in their script filenames, than want to use the  
> classname of the script.

That certainly works for me, but it must be an explicit thing that the
file name rules for scripts and the file name rules for classes are
different.  The boundary point is:  when is the file name used to create
a class name compared to when is the file name simply checked for
consistency with the class name.

Mapping '-' to '_' works for me.

--

-- 
Russel.
====================================================
Dr Russel Winder                 Partner

Concertant LLP                   t: +44 20 7585 2200, +44 20 7193 9203
41 Buckmaster Road,              f: +44 8700 516 084
London SW11 1EN, UK.             m: +44 7770 465 077
Jochen Theodorou | 15 Aug 12:06
Gravatar

Re: [groovy-dev] Can't run a file with - in it

Russel Winder schrieb:
> On Fri, 2008-08-15 at 15:55 +1000, Luke Daley wrote:
> 
>> In my opinion, the fact that a script creates a class of the same  
>> name is an implementation detail and for the majority of usage  
>> doesn't come into play. I see it as more likely that users will want  
>> 'illegal' characters in their script filenames, than want to use the  
>> classname of the script.
> 
> That certainly works for me, but it must be an explicit thing that the
> file name rules for scripts and the file name rules for classes are
> different.  The boundary point is:  when is the file name used to create
> a class name compared to when is the file name simply checked for
> consistency with the class name.
> 
> Mapping '-' to '_' works for me.

for me the concern is reverse mapping. If the script depends on another 
script and that script has a name that is illegal for Java, then what do 
we do? The first script needs to lookup he second script by classname. 
But for one classname with "_" in it, there exists a variety of possible 
file names. It would be better if we had a 1:1 mapping or something near 
that.

bye blackdrag

--

-- 
Jochen "blackdrag" Theodorou
The Groovy Project Tech Lead (http://groovy.codehaus.org)
http://blackdragsview.blogspot.com/
http://www.g2one.com/

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

    http://xircles.codehaus.org/manage_email

Martin C. Martin | 15 Aug 14:08

Re: [groovy-dev] Can't run a file with - in it

Also, two different scripts with two different file names could map to 
the same class name, so that e.g Ricky+Cory+Trever.groovy and 
Ricky-Cory-Trevor.groovy would have a collision.

Best,
Martin

Jochen Theodorou wrote:
> Russel Winder schrieb:
>> On Fri, 2008-08-15 at 15:55 +1000, Luke Daley wrote:
>>
>>> In my opinion, the fact that a script creates a class of the same  
>>> name is an implementation detail and for the majority of usage  
>>> doesn't come into play. I see it as more likely that users will want  
>>> 'illegal' characters in their script filenames, than want to use the  
>>> classname of the script.
>>
>> That certainly works for me, but it must be an explicit thing that the
>> file name rules for scripts and the file name rules for classes are
>> different.  The boundary point is:  when is the file name used to create
>> a class name compared to when is the file name simply checked for
>> consistency with the class name.
>>
>> Mapping '-' to '_' works for me.
> 
> for me the concern is reverse mapping. If the script depends on another 
> script and that script has a name that is illegal for Java, then what do 
> we do? The first script needs to lookup he second script by classname. 
> But for one classname with "_" in it, there exists a variety of possible 
> file names. It would be better if we had a 1:1 mapping or something near 
> that.
> 
> bye blackdrag
> 

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

    http://xircles.codehaus.org/manage_email

Russel Winder | 15 Aug 18:11

Re: [groovy-dev] Can't run a file with - in it

On Fri, 2008-08-15 at 08:08 -0400, Martin C. Martin wrote:
> Also, two different scripts with two different file names could map to 
> the same class name, so that e.g Ricky+Cory+Trever.groovy and 
> Ricky-Cory-Trevor.groovy would have a collision.

So you would have to use a mangling algorithm for illegal characters.
For example use two underscores followed by the Unicode codepoint value
as a number followed by two underscores.

--

-- 
Russel.
====================================================
Dr Russel Winder                 Partner

Concertant LLP                   t: +44 20 7585 2200, +44 20 7193 9203
41 Buckmaster Road,              f: +44 8700 516 084
London SW11 1EN, UK.             m: +44 7770 465 077
Favicon

Re: [groovy-dev] Can't run a file with - in it

Luke Daley wrote:
> 
> On 15/08/2008, at 1:49 PM, Danno Ferrin wrote:
> 
>> Sounds like it doesn't exist yet.  Perhaps you could post one and some 
>> possible mappings?  My main concern is whatever it is that it should 
>> have a one to one mapping in almost all cases.
> 
> Is '_' legal? If so, why not map anything that is illegal to '_'?

A few others mentioned that it needs to be reversible. So, have a look 
at this blog post by John Rose:

http://blogs.sun.com/jrose/entry/symbolic_freedom_in_the_vm

JRuby is using a similar round-trippable technique. Perhaps we should 
work on a single piece of code we can both use?

Also, I don't see that the actual class name of a script is important 
beyond being readable. Do people actually write bare scripts with 
methods in them and expect to be able to instantiate and execute those 
scripts by name from Java? Does that even work? It seems like if you 
want to present something to Java you would expose a class, and be 
subject to class naming as normal.

- Charlie

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

    http://xircles.codehaus.org/manage_email

Luke Daley | 16 Aug 08:42

Re: [groovy-dev] Can't run a file with - in it


On 16/08/2008, at 4:29 AM, Charles Oliver Nutter wrote:

> A few others mentioned that it needs to be reversible. So, have a  
> look at this blog post by John Rose:
>
> http://blogs.sun.com/jrose/entry/symbolic_freedom_in_the_vm
>
> JRuby is using a similar round-trippable technique. Perhaps we  
> should work on a single piece of code we can both use?
>
> Also, I don't see that the actual class name of a script is  
> important beyond being readable. Do people actually write bare  
> scripts with methods in them and expect to be able to instantiate  
> and execute those scripts by name from Java? Does that even work?  
> It seems like if you want to present something to Java you would  
> expose a class, and be subject to class naming as normal.

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

Are you able to point me towards the code you use for this in JRuby?

--

LD.

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

    http://xircles.codehaus.org/manage_email

Jochen Theodorou | 16 Aug 14:14
Gravatar

Re: [groovy-dev] Can't run a file with - in it

Charles Oliver Nutter schrieb:
> Luke Daley wrote:
>>
>> On 15/08/2008, at 1:49 PM, Danno Ferrin wrote:
>>
>>> Sounds like it doesn't exist yet.  Perhaps you could post one and 
>>> some possible mappings?  My main concern is whatever it is that it 
>>> should have a one to one mapping in almost all cases.
>>
>> Is '_' legal? If so, why not map anything that is illegal to '_'?
> 
> A few others mentioned that it needs to be reversible. So, have a look 
> at this blog post by John Rose:
> 
> http://blogs.sun.com/jrose/entry/symbolic_freedom_in_the_vm
> 
> JRuby is using a similar round-trippable technique. Perhaps we should 
> work on a single piece of code we can both use?
> 
> Also, I don't see that the actual class name of a script is important 
> beyond being readable. Do people actually write bare scripts with 
> methods in them and expect to be able to instantiate and execute those 
> scripts by name from Java? Does that even work? It seems like if you 
> want to present something to Java you would expose a class, and be 
> subject to class naming as normal.

a script can be compiled like any other groovy program through groovyc 
and it produces a class file. In fact any script is a class. Methods in 
a script are real methods, so of course they can be called from the 
outside. You can give a script also a different base class.

I mean the class name doesn't have to be readable.. if they want to 
precompile the class and call it directly on the commandline or refer to 
it in a java class, then they can use a normal java class name.

bye blackdrag

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

    http://xircles.codehaus.org/manage_email

Favicon

Re: [groovy-dev] Can't run a file with - in it

Jochen Theodorou wrote:
> a script can be compiled like any other groovy program through groovyc 
> and it produces a class file. In fact any script is a class. Methods in 
> a script are real methods, so of course they can be called from the 
> outside. You can give a script also a different base class.
> 
> I mean the class name doesn't have to be readable.. if they want to 
> precompile the class and call it directly on the commandline or refer to 
> it in a java class, then they can use a normal java class name.

Well, this is an area where we could probably organize some 
compatibility, as far as what we present from bare scripts to the Java 
side of things. I'd only planned for JRuby's "Java-visible" compiler to 
support normal class definitions, but if there's a good use case for 
script methods being available as well I could certainly do that too.

- Charlie

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

    http://xircles.codehaus.org/manage_email


Gmane