Bug 40630 - java.util.Scanner fails when used for charset generation by the OpenJDK build
Summary: java.util.Scanner fails when used for charset generation by the OpenJDK build
Status: RESOLVED FIXED
Alias: None
Product: classpath
Classification: Unclassified
Component: classpath (show other bugs)
Version: 0.98
: P3 normal
Target Milestone: 0.99
Assignee: Andrew John Hughes
URL:
Keywords:
Depends on:
Blocks: 39410
  Show dependency treegraph
 
Reported: 2009-07-03 10:44 UTC by Andrew John Hughes
Modified: 2010-10-12 17:33 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2009-07-07 09:22:49


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew John Hughes 2009-07-03 10:44:32 UTC
/mnt/builder/icedtea/bootstrap/jdk1.6.0/bin/java -XX:-PrintVMOptions -XX:+UnlockDiagnosticVMOptions -XX:-LogVMOutput -Xmx896m -Xms128m -XX:PermSize=32m -XX:MaxPermSize=160m -jar /mnt/builder/icedtea/openjdk-ecj/build/linux-amd64/btjars/charsetmapping.jar ../../tools/CharsetMapping /mnt/builder/icedtea/generated/sun/nio/cs/ext dbcs
IBM1381,x-IBM1381,Cp1381,true,sun.nio.cs.ext
Exception in thread "main" java.lang.NullPointerException
   at java.util.regex.Matcher.toMatchResult(libgcj.so.10)
   at java.util.Scanner.myCoreNext(libgcj.so.10)
   at java.util.Scanner.myPrepareForNext(libgcj.so.10)
   at java.util.Scanner.myNextLine(libgcj.so.10)
   at java.util.Scanner.hasNextLine(libgcj.so.10)
   at build.tools.charsetmapping.GenerateDBCS.genClass(GenerateDBCS.java:248)
   at build.tools.charsetmapping.GenerateDBCS.genDBCS(GenerateDBCS.java:66)
   at build.tools.charsetmapping.Main.main(Main.java:41)
Comment 1 Andrew John Hughes 2009-07-07 09:22:49 UTC
Tracked this down to a failure in java.util.Scanner.  The NPE in MatchResult is masking the real problem (the NPE itself is easily solved by only cloning match if it is non-null).
The method hasNextLine returns false if it receives a null return value, but myCoreNext never returns null. Instead, it keeps hitting the end of the input and returning an empty string.
Comment 2 Andrew John Hughes 2009-07-07 11:00:19 UTC
CVSROOT:        /sources/classpath
Module name:    classpath
Changes by:     Andrew John Hughes <gnu_andrew> 09/07/07 10:27:19

Modified files:
       .              : ChangeLog
       java/util      : Scanner.java
       java/util/regex: Matcher.java

Log message:
       Correctly spot EOF in java.util.Scanner#hasNextLine().

       2009-07-07  Andrew John Hughes  <ahughes@redhat.com>

               PR classpath/40630
               * java/util/Scanner.java:
               (myCoreNext(boolean, Pattern)): Set tmp2 to
               null if the string is empty (i.e. we are at
               the end of the file).
               * java/util/regex/Matcher.java:
               (toMatchResult()): Check that match is non-null
               before attempting to clone it.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpath&r1=1.9769&r2=1.9770
http://cvs.savannah.gnu.org/viewcvs/classpath/java/util/Scanner.java?cvsroot=classpath&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/classpath/java/util/regex/Matcher.java?cvsroot=classpath&r1=1.24&r2=1.25
Comment 3 Andrew John Hughes 2010-10-12 17:33:06 UTC
Merged to gcj in libgcj-snapshot-20100921.