1 | package net.sourceforge.retroweaver.runtime.java.lang; |
2 | |
3 | public class Byte_ { |
4 | |
5 | private Byte_() { |
6 | // private constructor |
7 | } |
8 | |
9 | private static Byte[] boxedVals = new Byte[256]; |
10 | |
11 | // Small lookup table for boxed objects |
12 | // |
13 | // The spec says that the range should be from -127 to 128, |
14 | // but a byte's range is from -128 to 127. Neal Gafter seems to imply |
15 | // that this is a bug in the spec. |
16 | static { |
17 | for (int i = 0; i < 256; ++i) { |
18 | byte val = (byte) (i - 128); |
19 | boxedVals[i] = new Byte(val); // NOPMD by xlv |
20 | } |
21 | } |
22 | |
23 | public static Byte valueOf(final byte val) { |
24 | return boxedVals[val + 128]; |
25 | } |
26 | |
27 | } |