JDK-6597678 : JavaCompiler.getStandardFileManager always uses default charset not the one that user specifies
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2007-08-27
  • Updated: 2011-05-17
  • Resolved: 2011-05-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b138Fixed
Related Reports
Relates :  
Relates :  
Description
JavaCompiler.getStandardFileManager(...,Locale,...) always uses default locale and ignores the one that user specifies.


<JavacTool.java>
.
.
.
public JavacFileManager getStandardFileManager(
        DiagnosticListener<? super JavaFileObject> diagnosticListener,
        Locale locale,
        Charset charset) {
        Context context = new Context();
        if (diagnosticListener != null)
            context.put(DiagnosticListener.class, diagnosticListener);
        context.put(Log.outKey, new PrintWriter(System.err, true)); // FIXME
        return new JavacFileManager(context, true, charset);
}
...
.

</JavacTool.java>

In the above Standard implementaion, locale is ignored.

Comments
EVALUATION Not strictly true -- if a diag listener is provided the locale would be irrelevant, but if the default diag listener is used, then the given locale should be used. This means that the locale should go into the context and be picked up by Log/JavacMessages/etc.
16-03-2011

EVALUATION Locale does not come into play, but charset does. The code should use OutputStreamWriter directly to create writer with the appropriate charset, if charset is not null.
09-11-2010