| 1 | package net.sourceforge.retroweaver.runtime.java.lang; |
| 2 | |
| 3 | public class Short_ { |
| 4 | |
| 5 | private Short_() { |
| 6 | // private constructor |
| 7 | } |
| 8 | |
| 9 | private static Short[] boxedVals = new Short[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 Short(val); // NOPMD by xlv |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | public static Short valueOf(final short val) { |
| 24 | if (val > -129 && val < 128) { |
| 25 | return boxedVals[val + 128]; |
| 26 | } else { |
| 27 | return new Short(val); |
| 28 | } |
| 29 | } |
| 30 | } |