JDK-6584897 : Cannot invoke class from command line with args containing non-ASCII characters
  • Type: Bug
  • Component: tools
  • Sub-Component: launcher
  • Affected Version: 6,6u10,6u24
  • Priority: P4
  • Status: Resolved
  • Resolution: Won't Fix
  • OS: windows_xp,windows_7
  • CPU: x86
  • Submitted: 2007-07-24
  • Updated: 2015-06-17
  • Resolved: 2014-02-25
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.6.0_02"
Java(TM) SE Runtime Environment (build 1.6.0_02-b06)
Java HotSpot(TM) Client VM (build 1.6.0_02-b06, mixed mode, sharing)


ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
When invoking a class from the command line with arguments that contain characters higher than 0xFF, the arguments in the String array passed to the class' main method do not match the arguments specified on the command line.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the test program, and specify an argument with a character higher than 0xFF. (see attachment for sample)

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expect the test program to print the same output twice -- once for the hard-coded string and once for the same characters specified on the command line.
ACTUAL -
The first set of output (for the hard-coded string is correct), but the second set is not:
A?
0x41
0x3c0

Ap
0x41
0x70

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
public class Test
{
	public static void main (String[] args)
	{
		String testStr1 = "A\u03c0";
		System.out.println(testStr1);
		printHexVals(testStr1);

		if (args.length > 0) {
			String testStr2 = args[0];
			System.out.println();
			System.out.println(testStr2);
			printHexVals(testStr2);
		}
	}
	private static void printHexVals(String str) {
		for (int i=0; i<str.codePointCount(0, str.length()); i++) {
			System.out.println("0x" + Integer.toHexString(str.codePointAt(i)));
		}
	}
}
---------- END SOURCE ----------

Comments
EVALUATION Note command line arguments can be passed correctly from the environment to Java the launcher does thic correctly if the System is configured correctly for Windows check the Regional Settings etc. Attached a screen shot to show the translations do occur correctly. However there are other issues with launcher which stymies paths and such because the launcher is not Unicode friendly on Windows.
15-03-2011

EVALUATION This is another instance where the characters are lost in translation as the launcher is not Unicode friendly.
02-08-2010