corentin59/ArtNetStack — pull request #1 by TheConstructor (2012-08-06 21:13:59+00:00)
Title: Some basic improvements

Hi,

I just stumbled across your project and wanted to correct a mistake with your code.

As Java only uses signed byte values you should really look out for byte-values larger than 127 as they are interpreted as negative values.

The real problem?
When a unsigned byte value like 128 is stored, it is interpreted as the signed value -127. If you now cast this byte value to an int value Java adds 3 0xff-bytes so it has a int of value -127.
Result:
(anything < 8) | (-127) == -127
Work-Arround: Remove the unnecessary 3 0xff-bytes, so you have (-127 & 0xff) = 128.

To make sure, that you don't miss such bugs, you should add tests to you project and run "mvn test" frequently.

Regards

TC.