]
Issue was automatically transitioned when kuzukami.sh created pull request #40 in GitHub
----------------------------------------------------------------------------------------
Status: Pull Request Sent (was: Open)
Encoding of source[?] code cannot be easily configured.
-------------------------------------------------------
Key: ROASTER-75
URL:
https://issues.jboss.org/browse/ROASTER-75
Project: Roaster
Issue Type: Enhancement
Components: API, JDT
Affects Versions: 2.14.0.Final, 2.15.0.Final
Environment: Java 8 64bit, Eclipse Mars, Windows 8.1 Pro 64bit
Reporter: Shoji Kuzukami
Priority: Minor
Fix For: 2.x Future
The parser encoding for souce code can only be configured by the 'file.encoding'
system parameter, as we can see in JavaParserImpl, "String encoding =
System.getProperty("file.encoding", "ISO8859_1");".
Even though the Roaster API can receive a 'String' source as "public static
JavaType<?> parse(final String data)" in the 'Roaster.java', the
'String' of source can only contain "ISO8859_1" charsets if we don't
change the "file.encoding".
The parser SPI in 'JavaParser.java' is defined as "JavaUnit parseUnit(final
InputStream data);" instead of "JavaUnit parseUnit(Reader source);". I
think it is adequate considering that the Roaster API will accept some binary sources
(such as bytecode) in near future.
I recommend that the SPI "JavaUnit parseUnit(final InputStream data);" is
expanded into "JavaUnit parseUnit(final InputStream data, Charset encodingIfText
);" and some encoding refactors are done in the 'Roaster.java' without any
change of semantics in the Roaster APIs except for the 'String' souce APIs as
"public static JavaType<?> parse(final String data)".
The 'Charset' argument is used only if the 'data' of InputStream must be
interpreted as 'String' ( as a case of source code ).
If this idea is accepted by this project design, I'll refactor the code and do a
pull-requeust.