0

This happened when I decompiled some classes from a jar file. These are the only errors I cannot get past.

All of these errors are 'Possible lossy conversion from int to byte'.

this.onDemandFetcher.method563(1, 2, i2);
this.worldController.method291(i1, j, i, -119);
this.method563(2, 3, this.mapIndices3[k]);
this.method563(2, 3, this.mapIndices2[k]);

and

public boolean method286(final int j, final int k, final Animable class30_sub2_sub4, final int l, final int i1, final int j1, final int k1, final int l1, final int i2, final int j2, final int k2) {
        return class30_sub2_sub4 == null || this.method287(j, l1, k2, i2 - l1 + 1, i1 - k2 + 1, j1, k, k1, class30_sub2_sub4, l, true, j2, 0);
    }

and

return this.method287(i, l2, i2, j2 - l2 + 1, k2 - i2 + 1, k1, i1, k, class30_sub2_sub4, j, true, l, 0);

All of these errors are classified as the same thing. What exactly am I doing wrong? Could you please fix the code for me and show me the difference?

John Vegas
  • 51
  • 6
  • Add a `(byte)` cast for the (relevant) parameters that are declared as `byte`. If we assume that the code originally worked, then the `(byte)` casts would presumably have been in the original code ... – Stephen C Jun 11 '14 at 03:39

1 Answers1

2

"Possible lossy conversion from int to byte" means that some part of your code wants a byte, and you are passing it an int. Bytes are 8 bits and ints 32, so information may be lost by doing this conversion.

You haven't posted enough of the code to know, but it's probably in the arguments to method287. If it wants bytes, then passing it the int variables will trigger this error. You should also remember that whole-number constants are ints by default - you can cast them to bytes if you need it.

Now you know what the message means you should be able to go through the code and check where these conversions occur.

DJClayworth
  • 26,349
  • 9
  • 53
  • 79