JDK-4845710 : File constructor does not properly translate unicode to platform encoding
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 1.4.0,1.4.2
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • OS: solaris_7,windows_2000
  • CPU: x86,sparc
  • Submitted: 2003-04-09
  • Updated: 2006-02-27
  • Resolved: 2006-02-27
Related Reports
Relates :  
Relates :  
Description
Name: jl125535			Date: 04/09/2003


FULL PRODUCT VERSION :
java version "1.4.2-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-beta-b19)
Java HotSpot(TM) Client VM (build 1.4.2-beta-b19, mixed mode)

Interestingly, everything is ok with:
java version "1.3.1_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_04-b02)
Java HotSpot(TM) Client VM (build 1.3.1_04-b02, mixed mode)

FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 Service Pack 2 [Version 5.00.2195] 
  with the German locale setting
java.util.Locale.getDefault() correctly yields "de_DE"

A DESCRIPTION OF THE PROBLEM :
Filenames with certain unicode characters are not correctly
translated to the platform. Problem characters include "u0084" (double
low-9 quotation mark) and "\u0093" (left double quotation mark)

java version "1.3.1_04"
Java(TM) 2 Runtime Environment, Standard Edition (build
1.3.1_04-b02)
Java HotSpot(TM) Client VM (build 1.3.1_04-b02, mixed mode)
works ok.

REGRESSION.  Last worked in version 1.3

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile Code
2. Run
3. Look for the generated file in Explorer

EXPECTED VERSUS ACTUAL BEHAVIOR :
Expected: A file with filename of >>����?Filename����?<<
Actual: A file with filename of >>��Filename��<<


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.io.FileOutputStream;
import java.io.File;

public class FileError {
    
    public FileError() {
    }
    
    public static void main(String[] args) {
        String filename = "\u0084Filename\u0093";
        File file = new File(filename);
        try {
            FileOutputStream out = new FileOutputStream(file);
            out.close();
        }
        catch (Exception ex) {
        }
    }
    
}

---------- END SOURCE ----------

Release Regression From : 1.3.1_04
The above release value was the last known release where this 
bug was known to work. Since then there has been a regression.

(Review ID: 163319) 
======================================================================
###@###.### 2003-04-10

Comments
EVALUATION This is not a bug. Support for Unicode filenames for NT Filesystem was added in 1.3.1_07. See the bug report for: 4185525 The report has tests that test for filenames with all possible unicodes. The example supplied with this bug report creates a filename that begins with \u0084" and ends with "\u0093". When the example is run with 1.3.1_04 (or 1.3.1_06 and previous releases) a file is created whose name shows up with extended ASCII characters substituted for the codes x84 and x93 -- this is the result before the support for filenames with Unicode was added into the JDK. However, with the fix made in 1.3.1_07, the example created filename contains the unicodes and shows up as "?filename?". Without Unicode Support o/p: ��Filename�� (1.3.1_06 and previous releases) With Unicode Support o/p: ?Filename? (1.3.1_07 and later releases)
27-02-2006

EVALUATION Windows 2000 uses effectively the same encoding for characters as the JDK uses for Strings, so there should not be any encoding issues. I suspect that at least in recent JDKs, this problem simply isn't there. (Or perhaps I misunderstand the bug report) I suggest closing this as Not Reproducible.
01-02-2006

EVALUATION Not for mantis. ###@###.### 2003-04-11
11-04-2003