Java console bug under windows

后端 未结 1 625
臣服心动
臣服心动 2020-12-19 09:14

The following Code

System.out.println(\"Start\");
String s = \"\";
//936 * 5 = 4680 characters
for (int i = 0; i < 937; i++){
    s += \"1234 \";
}
System         


        
相关标签:
1条回答
  • 2020-12-19 09:36

    I can reproduce this as well, under Windows 7. It looks like a limitation due to the OS in SWT, and it seems to have been around for a very long time (2002). It's marked as WONTFIX. See GC#drawString, drawText don't render more than 10923 characters per line correctly. So this is a known bug.

    The workaround is to go to the Workspace->Preferences->Run/Debug->Console and set the Fixed width console to be something like 4000 chars. This will wrap your lines after 4000 characters, which is a pain, but at least you'll get all of your output.

    I have tried Galileo (3.5), Helios (3.6) and Indigo (3.7), and all exhibit the behaviour, but wierdly, Galileo & Helios have a limit = 818 (4090 chars) and Indigo = 936 (4680) chars as the OP said. The 4090 makes me think of a OS limit (the next would be 4090 + 5 + crlf, > 4096), which matches with the bugs raised in Eclipse/SWT. I can't explain why there is a difference in the number of characters accepted. I can only suggest that it's something in the OS.

    There are a number of duplicate bugs raised in Eclipse:

    1. Bug 19850 - Large string printed in Console overstrikes/disappears depending on length
    2. Bug 44866 - Truncate long strings in variables view
    3. Bug 104588 - Unreadable console output under certain conditions

    Everything seems to have been a consequence of: Bug 11601 - console hangs while displaying long strings without crlf

    0 讨论(0)
提交回复
热议问题