File.exists() does not work on mac for non-English characters on Java 7 on Mac

Paul Taylor paul_t100 at fastmail.fm
Wed Jan 23 00:50:17 PST 2013


On 22/01/2013 21:41, Steve Hannah wrote:
> I just wanted to post my experiences with this bug.  I was having
> trouble on OS X in both 1.7.0u11 and 1.7.0u12 with Japanese file names
> (File.exists() erroneously returning false).
>
> Scott's fix for LC_CTYPE was the only thing that worked for me.
> (tried file.encoding=UTF8, and sun.jnu.encoding=UTF8 to no avail).
>
> As I am deploying to the Mac App store I needed to set this
> environment variable using the Info.plist file, and the current
> appbundler ant task didn't have an option to set arbitrary keys/values
> in the Info.plist, so I modified the appbundler source (I was actually
> working off of the infinitekind fork of appbundler at
> https://bitbucket.org/infinitekind/appbundler) to automatically set
> the LSEnvironment key.
>
> The diff for this change is:
>
> diff -r 563fcd766efe appbundler/src/com/oracle/appbundler/AppBundlerTask.java
> --- a/appbundler/src/com/oracle/appbundler/AppBundlerTask.java	Wed Sep
> 19 17:54:08 2012 +0100
> +++ b/appbundler/src/com/oracle/appbundler/AppBundlerTask.java	Tue Jan
> 22 13:31:11 2013 -0800
> @@ -577,7 +577,16 @@
>
>               xout.writeEndElement();
>               xout.writeCharacters("\n");
> -
> +
> +            // Write Environment
> +            writeKey(xout, "LSEnvironment");
> +            xout.writeStartElement(DICT_TAG);
> +            xout.writeCharacters("\n");
> +            writeKey(xout, "LC_CTYPE");
> +            writeString(xout, "UTF-8");
> +            xout.writeEndElement();
> +            xout.writeCharacters("\n");
> +
>               // Write options
>               writeKey(xout, "JVMOptions");
>
>
> I'm not working off the trunk, so I don't know if this problem has
> actually been resolved... but this workaround works for me.
>
> Just thought I'd share in case it helps someone else along the line.
>
> -Steve
>
Thanks all the fixes in that fork are great, but cant we get these 
incorporated into trunk - I know its been asked before but nothing seems 
to have been added to appbundler for some time

Paul


More information about the macosx-port-dev mailing list