

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
25 messages in org.codehaus.groovy.userRe: [groovy-user] File encoding problem| From | Sent On | Attachments |
|---|---|---|
| Michael Baehr | Mar 23, 2007 7:25 am | |
| Guillaume Laforge | Mar 23, 2007 9:31 am | |
| Michael Baehr | Mar 23, 2007 9:57 am | |
| Guillaume Laforge | Mar 23, 2007 10:07 am | |
| Michael Baehr | Mar 23, 2007 10:16 am | |
| Guillaume Laforge | Mar 23, 2007 10:20 am | |
| Michael Baehr | Mar 23, 2007 10:24 am | |
| Guillaume Laforge | Mar 23, 2007 12:19 pm | |
| Michael Baehr | Mar 23, 2007 12:36 pm | .groovy |
| Russel Winder | Mar 23, 2007 12:41 pm | |
| Guillaume Laforge | Mar 23, 2007 12:47 pm | |
| Michael Baehr | Mar 23, 2007 12:52 pm | |
| Russel Winder | Mar 23, 2007 12:53 pm | |
| Michael Baehr | Mar 23, 2007 12:54 pm | |
| Russel Winder | Mar 23, 2007 12:58 pm | |
| Michael Baehr | Mar 23, 2007 1:01 pm | |
| Russel Winder | Mar 23, 2007 1:04 pm | |
| Michael Baehr | Mar 23, 2007 1:05 pm | |
| Russel Winder | Mar 23, 2007 1:06 pm | |
| Michael Baehr | Mar 23, 2007 1:24 pm | |
| Russel Winder | Mar 23, 2007 1:31 pm | |
| Michael Baehr | Mar 23, 2007 1:40 pm | |
| Gavin Grover | Mar 23, 2007 4:51 pm | |
| Barzilai Spinak | Mar 23, 2007 6:39 pm | |
| Jochen Theodorou | Mar 25, 2007 9:59 am |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | Re: [groovy-user] File encoding problem | Actions... |
|---|---|---|
| From: | Jochen Theodorou (blac...@gmx.org) | |
| Date: | Mar 25, 2007 9:59:26 am | |
| List: | org.codehaus.groovy.user | |
Barzilai Spinak schrieb: [...]
D:\temp>ren utf8.groovy utf8.groovy.OLD D:\temp>groovy utf8 Caught: java.io.FileNotFoundException: utf8 (D:\temp\utf8)
See? *EVEN THOUGH* it has a completely valid .class file, it tries to look for the source .groovy file and it fails after not finding it.
I think recompilation is off by default, so it should use the .class file. But the above is clearly an error, because the .grovoy file is the fall back for a non existing .class file, which means groovy can't find the .class file as well here. You are sure it was there?
[...]
2) Second tests, execute the "groovy" command specifying the encoding. D:\temp>ren utf8.groovy utf8.groovy.otra
D:\temp>groovy -c utf8 utf8 Caught: BUG! exception in phase 'parsing' in source unit 'utf8.groovy' charsetName
D:\temp>groovy --encoding utf8 utf8 Caught: BUG! exception in phase 'parsing' in source unit 'utf8.groovy' charsetName
(And other attempts to specify an encoding)
The problem here: a) If it didn't try to parse/compile anything (since it's already compiled and up to date!), this problem would not happen.
I agree partially... even if it recompiles, there should be no problem with the charset name.... would be nice of you to post a bigger trace for this (run groovy with -d)
b) The --encoding or -c options are *ignored* or not passed down to "groovyc" (maybe groovyStarter doesn't know what to do with it?).
I don't think it is the fault of groovyc or groovyStarter.
As Michael discovered, it can be "fixed" by setting JAVA_OPTS=-Dfile.encoding=UTF-8 since that will change the default encoding for the compiler AND the Java Virtual Machine.
I think we should more ask how file.encoding does take effect. It effects the default encoding used by the java api for reader and inputstreams. And of course the groovy compilers uses this api. But should it really affect the compiler? Normally the compiler should use the encoding given to him, but since file.encoding takes effect it means that there are places where the compiler does not use an explicit encoding, therefor the configuration we gave in with the --encoding option is naturally ignored.
I see a suspicous line in GroovyClassLoader:
su = unit.addSource(codeSource.getName(), codeSource.getInputStream());
getInputStream is implemented as:
public InputStream getInputStream() { try { if (file!=null) return new FileInputStream(file); } catch (FileNotFoundException fnfe) {} return inputStream; }
so if file is not null, we will create a new FileInputStream *using the default encoding*. A big bug!
This does of course not explain the problem with not calling a .class file, but it exaplains the prolem with the encoing.
bye blackdrag
-- Jochen "blackdrag" Theodorou Groovy Tech Lead (http://groovy.codehaus.org) http://blackdragsview.blogspot.com/








.groovy