Bug 452235 - java.util.Scanner.nextFloat() not working
java.util.Scanner.nextFloat() not working
Status: CLOSED WORKSFORME
Product: Fedora
Classification: Fedora
Component: java-1.6.0-openjdk (Show other bugs)
9
All Linux
low Severity medium
: ---
: ---
Assigned To: Thomas Fitzsimmons
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2008-06-20 09:40 EDT by Andrea Santilli
Modified: 2008-06-24 14:34 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2008-06-20 12:07:38 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
the test program sources (876 bytes, text/x-java)
2008-06-20 09:40 EDT, Andrea Santilli
no flags Details
text file i used to test the method (6 bytes, text/plain)
2008-06-20 09:41 EDT, Andrea Santilli
no flags Details

  None (edit)
Description Andrea Santilli 2008-06-20 09:40:31 EDT
Description of problem:
java.util.Scanner.nextFloat() raises java.util.InputMismatchException while
reading a floating point number.
Please notice that I could workaround this by using
Float.parseFloat(myScanner.next())
I'm attaching a simple test program and a test text file: try to run it with
both JDK and OpenJDK and you'll see the difference.

Version-Release number of selected component (if applicable):
1.6.0.0-0.15.b09.fc9

How reproducible:
Always

Steps to Reproduce:
1. Just create a new Scanner object with a string containing only a floating
point number
2. it will compile fine as exspected
3. but it will raise the InputMismatchException

Additional info:
I still didn't test the other methods of java.util.Scanner so I can't say
whether they will work or not.
Comment 1 Andrea Santilli 2008-06-20 09:40:31 EDT
Created attachment 309918 [details]
the test program sources
Comment 2 Andrea Santilli 2008-06-20 09:41:35 EDT
Created attachment 309919 [details]
text file i used to test the method
Comment 3 Lillian Angel 2008-06-20 12:07:38 EDT
java-1.6.0-openjdk-1.6.0.0-0.15.b09.fc9.i386

$ java Test test.txt 
0.123

$ /opt/jdk1.6.0_03/bin/java Test testtt 
0.123

$ java -version
java version "1.6.0"
OpenJDK  Runtime Environment (build 1.6.0-b09)
OpenJDK Server VM (build 1.6.0-b09, mixed mode)

Comment 4 Lillian Angel 2008-06-20 12:08:18 EDT
testtt and test.txt are identical to the text file you attached
Comment 5 Lubomir Rintel 2008-06-20 16:29:37 EDT
Lillian: I am wondering whether you tried this on PowerPC?

gbenson once pointed me to an issue very similar to this, that was an
explanation for a problem I had on ppc. It was occuring with an early version of
GNU Classpath IIRC.
Comment 6 Andrea Santilli 2008-06-21 06:11:26 EDT
I tried to reinstall all the packages but sorry, it still doesnt work for me.
this is the output i get by running the test program:

$ java Test test.txt
java.util.InputMismatchException
        at java.util.Scanner.throwFor(Scanner.java:857)
        at java.util.Scanner.next(Scanner.java:1478)
        at java.util.Scanner.nextFloat(Scanner.java:2336)
        at Test.main(Test.java:28)
Scanner.nextFloat() is screwed... let's try something else.
0.123

That's really weird because it looks like nextFloat() calls next() anyway.
Oh anyway I'm not on a PowerPC, just an Aspire 5630

Comment 7 Lillian Angel 2008-06-23 10:34:13 EDT
I tested this on an i386, I will test it on x86_64 as well.
Comment 8 Lillian Angel 2008-06-24 14:34:19 EDT
works on x86_64

$  java Test attachment.cgi
0.123
$ java -version
java version "1.6.0"
OpenJDK  Runtime Environment (build 1.6.0-b09)
OpenJDK 64-Bit Server VM (build 1.6.0-b09, mixed mode)

Note You need to log in before you can comment on or make changes to this bug.