Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7053724

Incorrect char conv. in UTF-16 and exception occurs in com.sun.tools.javac.parser.Scanner in jdk5u30

    Details

    • Subcomponent:
    • Resolved In Build:
      b09
    • CPU:
      x86
    • OS:
      windows_xp

      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.)

        Attachments

          Activity

            People

            • Assignee:
              robm Robert Mckenna
              Reporter:
              tbaba Tadayuki Baba (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: