Question

A few months ago I created a Java application which calculates chess ratings. I only ever tested it on my computer, but the program worked as expected.

I only just found out that on certain operating systems, the program doesn't work as it should. I've included a picture of the incorrect output on Windows 7 whereas this is what I get on Windows 8. (The player's rating should decrease since he scored only 1.5/5 against lower rated opposition). It seems that the program does not allow the player's rating to decrease.

Can anyone point me in the right direction as to why the program is behaving differently between these two versions of Windows? I was unable to find any explanation here on SO or anywhere else.

Was it helpful?

Solution 3

For future Googlers, the problem wasn't with Java; it was a problem with newlines in a text file from which my program was reading data. For some reason, the "\n" character separating values in my text file was not showing up in Windows 7 but worked fine in Windows 8. Very strange but glad that it's fixed!

OTHER TIPS

I think the most plausible explanation is that the Windows 7 version has a different argument there in the field 2: 2068 whereas Windows 8 has 2048.

Firstly, here are a couple of things that will NOT be the cause.

  • Arithmetic does not behave differently between Java on Windows 7 and 8. If you are running the same (single-threaded) algorithm with the same inputs, then the outputs should be the same.

  • Arithmetic does not change on 32-bit versus 64-bit JVMs.

So what could it be? Assuming that it is the same JAR, then it is likely that the algorithm doesn't change. So here are a couple of possibilities.

  • It could be a result of different inputs. Without looking at the algorithm, we can't exclude the possibility that there is something about it that makes it sensitive to the inputs in an unexpected way.

  • If there was a race condition in your code, you could find that that some aspect of your program doesn't work properly on some Java platforms ... due to differences in CPU speed, memory architecture and / or thread scheduling.


That's about as precise an answer as you could possibly get ... without looking at your code. So I think you are going to have to debug this yourself.

  • Get access to some Windows 7 machine that exhibits the problem.

  • Run the application with a debugger attached to see if the problem recurs under those conditions. If it does, then debug in the normal way to figure out why the algorithm is not working.

  • If attaching a debugger (and setting breakpoints) changes the way the program behaves (i.e. it makes the problem "go away") then you have evidence that points to a race condition of some kind.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top