According to the JLS, it is possible to "mangle" package names containing non-ASCII characters in case host filesystem doesn't support Unicode. For instance, package é
becomes @00e9
, and papierMâché
becomes papierM@00e2ch@00e9
when projected to the file system.
The question is: is it ever possible to achieve just the same for Java source files (whose names must confirm to the corresponding names of Java classes)?
The background of the problem is I need to have an accented e with acute in my public class name ('é'
, '\u00e9'
). Yes I know I shouldn't, and Unicode in file names is a malpractice, but still I need it.
However, either Mac OS X or the underlying HFS+ filesystem disallows this very character in file names, replacing it with 'e' immediately followed by COMBINING ACUTE ACCENT
("e\u0301"
). This behaviour is totally different from NTFS or ext3/ext4, where two files named "\u00e9"
and "e\u0301"
can co-exist in the same directory (test repository is here).
The above HFS+ behaviour results in 2 problems:
- I'm unable to compile my classes with
javac
because class name and file name are not the same (though I am able to compile them with either Maven or ecj). - I can't have my classes managed with Git, as it always reports that the file has been renamed:
.
$ git status .
# On branch master
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# "src/main/java/com/intersystems/persistence/Cache\314\201ExtremeConnectionParameters.java"
# "src/main/java/com/intersystems/persistence/Cache\314\201ExtremePersister.java"
# "src/main/java/com/intersystems/persistence/Cache\314\201JdbcConnectionParameters.java"
# "src/main/java/com/intersystems/persistence/Cache\314\201JdbcPersister.java"
# "src/main/java/com/intersystems/persistence/ui/Cache\314\201JdbcConnectionParametersPanel.java"
nothing added to commit but untracked files present (use "git add" to track)