Bug 69271 - decimal integer literals should not consist of FULL WIDTH Unicode digits
Summary: decimal integer literals should not consist of FULL WIDTH Unicode digits
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 minor (vote)
Target Milestone: 3.0.1   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-07-05 01:06 EDT by OZAWA Sakuro CLA
Modified: 2004-09-06 10:28 EDT (History)
0 users

See Also:


Attachments
An example of integer literal which JLS does not allow (297 bytes, text/plain)
2004-07-05 10:14 EDT, OZAWA Sakuro CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description OZAWA Sakuro CLA 2004-07-05 01:06:34 EDT
In JLS decimal integer literals consist of only 0, 1, 2,... and 9.
But JDT compiler also allows FULL WIDTH digits(U+FF10...U+FF19).
Comment 1 Philipe Mulet CLA 2004-07-05 09:16:26 EDT
Please provide a testcase.
Comment 2 OZAWA Sakuro CLA 2004-07-05 10:14:33 EDT
Created attachment 12962 [details]
An example of integer literal which JLS does not allow

This code, which Eclipse 3.0(Build 200406251208) compiles without complaining
anything, should not be compiled, because decimal literals(10) are written in
full width digits(U+FF10..U+FF19) while JLS(Java Language Specification)
specifies decimal integer literals only consists of 0..9.
[http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#48282]


Full width digits appear in JIS(Japanese Industrial Standards) X 0208 and
adopted into Unicode for compatibility use only.
Character.isDigit returns true for these digits.
Comment 3 Olivier Thomann CLA 2004-07-05 17:18:39 EDT
We use Character.isDigit(...) to find out if we have a digit.
I will double-check the specs.
Comment 4 Olivier Thomann CLA 2004-07-06 11:22:12 EDT
We should replace all calls to Character.isDigit with the following code:
private boolean isDigit(char c) throws InvalidInputException {
	if (Character.isDigit(c)) {
		switch(c) {
			case '0' :
			case '1' :
			case '2' :
			case '3' :
			case '4' :
			case '5' :
			case '6' :
			case '7' :
			case '8' :
			case '9' :
				return true;
		}
		throw new InvalidInputException(Scanner.INVALID_DIGIT);
	} else {
		return false;
	}
}
Comment 5 Olivier Thomann CLA 2004-07-06 21:10:05 EDT
Fixed and released in HEAD.
Comment 6 Olivier Thomann CLA 2004-07-06 21:11:11 EDT
Regression test added.
Comment 7 Philipe Mulet CLA 2004-07-07 16:06:03 EDT
Should address in 3.0.1 stream as well. 
Comment 8 Olivier Thomann CLA 2004-07-07 18:20:51 EDT
The fix is ready to be released in the 3_0_maintenance. In 3.0.1, the error will
be an invalid input. In 3.1, it will be an invalid digit.
Comment 9 Olivier Thomann CLA 2004-07-08 12:12:24 EDT
Fixed and released in 3_0_maintenance.
Regression test added.
Comment 10 David Audel CLA 2004-09-06 10:28:32 EDT
Verified for 3.0.1 RC1