beehive-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carlin Rogers (JIRA)" <>
Subject [jira] Resolved: (BEEHIVE-1033) NetUI APT does not create UTF-8 encoded output in the generated XML documents for other multibyte encoded source files.
Date Wed, 28 Dec 2005 07:31:02 GMT
     [ ]
Carlin Rogers resolved BEEHIVE-1033:

    Resolution: Fixed
     Assign To: Julie Zhuo  (was: Carlin Rogers)

Fixed with revision 359429. 


This fix explicitly sets the charset name to "UTF-8" for the PrintWriter we get with a call
to com.sun.mirror.apt.Filer.createTextFile(), to match the "UTF-8" encoding for the XML declaration
attribute in out generated files.

> NetUI APT does not create UTF-8 encoded output in the generated XML documents for other
multibyte encoded source files.
> -----------------------------------------------------------------------------------------------------------------------
>          Key: BEEHIVE-1033
>          URL:
>      Project: Beehive
>         Type: Bug
>   Components: NetUI
>     Versions: V1, 1.1
>     Reporter: Carlin Rogers
>     Assignee: Julie Zhuo
>      Fix For: 1.1
>  Attachments:
> The struts module config files and validator rules generated by NetUI APT are XML files
with the encoding attribute of the declaration set to "UTF-8" (<?xml version="1.0" encoding="UTF-8"?>).
However, if a different multibyte encoding is used in the source files, NetUI APT does not
create UTF-8 encoded output in the generated XML documents. Instead, the encoding of the input
source file is used for the output, even though we set the declaration attrbute as UTF-8.
Then, when this XML file is parsed there will be errors such as SAXParseException about an
incorrect byte sequence for UTF-8.
> The problem occurs with the difference in the file encoding of the input Java file and
the charset used by our APT processor to write out the struts config file. We just delegate
to APT to create the file and have it use the encoding of the source file. We get a PrintWriter
for the generated XML output by calling com.sun.mirror.apt.Filer.createTextFile() with null
as the charset name. The null charset name tells APT to use the charset used to encode source
files when we wite the file. 
> For example, on a Japanese Windows box the JVM file.encoding property may be SJIS. When
a source file is edited and multybite characters are used for the names of actions, the encoding
is SJIS. The beehive ant task for compiling a Controller file with annotations will use the
JVM file.encoding of the system (SJIS) and correctly compile the source file. However, during
the annotation processing, when we get the PrintWriter to output the generated XML, it will
also use SJIS, regardless of the fact that we write a declaration that says the output file
encoding is UTF-8.
> Note, you can set the encoding of the APT process with an option. So, one possible workaround
is to write your file using the UTF-8 encoding (or use the native2ascii converter
in the JDK). Then explicitly set the encoding to UTF-8 for the APT processor (and javac) in
our ant macrodef for "build-pageflows". To try this out, please follow these steps...
> - Before building your sample app, edit the beehive-tools.xml file in your Beehive distribution.
It's in the ant subdirectory of your beehive home.
>     apache-beehive-svn-snapshot/ant/beehive-tools.xml
> - Add the encoding option to the call to the <apt> task in the <macrodef name="build-pageflows">.
The line to add should be encoding="UTF-8". In the macrodef, the <apt> task should look
like this...
>            <apt srcdir="@{srcdir}"
>                 destdir="@{destdir}"
>                 gendir="@{tempdir}"
>                 classpathref=""
>                 sourcepathref="@{sourcepathref}"
>                 srcExtensions="*.jpf,*.jpfs,*.app,*.jsfb,*.java"
>                 encoding="UTF-8"
>                 processorOptions="web.content.root=@{webcontentdir}"
>                 debug="true"/>
> - Now try to build your modified sample app.
> The output for the struts config file will be in UTF-8

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:

View raw message