JDK-7053724 : Incorrect char conv. in UTF-16 and exception occurs in com.sun.tools.javac.parser.Scanner in jdk5u30
  • Type: Bug
  • Component: tools
  • Sub-Component: launcher
  • Affected Version: 5.0u30
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2011-06-11
  • Updated: 2013-09-12
  • Resolved: 2011-10-19
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.
Other
5.0u33 b09Fixed
Description
When a JavaSE licensee's customer runs a progam which uses UTF-16 encoding, 
NullPointerException occurs in JDK5u30.

===>
null:1: \11893 is invalid character.                               <=== (A)
A problme detected during parsing.                              <=== (A)
Details, please refer to the following stack trace           <=== (A)
java.lang.NullPointerException
        at com.sun.tools.javac.util.Log.printErrLine(Log.java:202)
        at com.sun.tools.javac.util.Log.printDiagnostic(Log.java:266)
        at com.sun.tools.javac.util.Log.error(Log.java:315)
        at com.sun.tools.javac.parser.Scanner.lexError(Scanner.java:434)
        at com.sun.tools.javac.parser.Scanner.lexError(Scanner.java:455)
        at com.sun.tools.javac.parser.Scanner.nextToken(Scanner.java:1343)
        at com.sun.tools.javac.parser.Parser.ident(Parser.java:334)
        at com.sun.tools.javac.parser.Parser.qualident(Parser.java:368)
        at com.sun.tools.javac.main.JavaCompiler.resolveIdent(JavaCompiler.java:306)  <=== (B)
        at com.sun.tools.apt.mirror.declaration.DeclarationMaker.nameToSymbol(DeclarationMaker.java:149)
        at com.sun.tools.apt.mirror.declaration.DeclarationMaker.getTypeDeclaration(DeclarationMaker.java:126)
        at com.sun.tools.apt.mirror.apt.AnnotationProcessorEnvironmentImpl.getTypeDeclaration(AnnotationProcessorEnvironmentImpl.java:85)
        at TestAPF$TestAnnotationProcessor.process(TestAPF.java:39)
        at com.sun.mirror.apt.AnnotationProcessors$CompositeAnnotationProcessor.process(AnnotationProcessors.java:60)
        at com.sun.tools.apt.comp.Apt.main(Apt.java:454)
        at com.sun.tools.apt.main.JavaCompiler.compile(JavaCompiler.java:448)
        at com.sun.tools.apt.main.Main.compile(Main.java:1075)
        at com.sun.tools.apt.main.Main.compile(Main.java:938)
        at com.sun.tools.apt.Main.processing(Main.java:95)
        at com.sun.tools.apt.Main.process(Main.java:85)
        at com.sun.tools.apt.Main.process(Main.java:67)
        at CompiletTest.main(CompiletTest.java:16)
<=====

NOTE:
  As to the lines of (A), messages are shown in Japanese. 
  The above messages are translated into Japanese by submitter.
  The original stack trace is attached as original-stack-trace.txt(can be seen in Japanese.).


CONFIGURATION:
 JDK: JDK5u30( 32bits)
 OS : WIndowsXP(SP3, **Japanese**, 32bits)
      (This problme does not occur in WinXP english edition.)


REPRODUCE:
1. Compile the attahced CompileTest.java and TestAPF.java
   ex.
    javac -classpath .;F:\export2\java\jdk1.5.0_30\lib\tools.jar CompileTest.java
2. Invoke Compile.class
  ex.
   java -classpath .;F:\export2\java\jdk1.5.0_30\lib\tools.jar CompileTest

You will see the above-listed NPE and exception messages.

NOTE:
  com.sun.tools.javac.parser.Scanner does not use UTF-16 encoding/decoding correctly.

  A little bit more details, String data passed to 
    AnnotationProcessorEnvironment.getTypeDeclaration(String name)
  is encoded by default encoding(MS932)  and converted byte array in com.sun.tools.javac.parser.Scanner.
 
  Then, this converted byte array is converted to char array by the encoding type which is specified to 
   com.sun.tools.apt.Main.process().
   The incorreect conversion seems to occurduring this operation of UTF-16.

   For more detail data used in the test program unternally, please see the data-log.txt(can be seen in
   Japanese.)

Comments
EVALUATION Request for deferral as this bug is been reported on 5u30. We will look into it as a potential candidate for 7u2 if the issue is still there on the 7 code base.
13-06-2011