001 package net.sourceforge.retroweaver.runtime.java.lang; 002 003 public class Short_ { 004 005 private Short_() { 006 // private constructor 007 } 008 009 private static Short[] boxedVals = new Short[256]; 010 011 // Small lookup table for boxed objects 012 // 013 // The spec says that the range should be from -127 to 128, 014 // but a byte's range is from -128 to 127. Neal Gafter seems to imply 015 // that this is a bug in the spec. 016 static { 017 for (int i = 0; i < 256; ++i) { 018 byte val = (byte) (i - 128); 019 boxedVals[i] = new Short(val); // NOPMD by xlv 020 } 021 } 022 023 public static Short valueOf(final short val) { 024 if (val > -129 && val < 128) { 025 return boxedVals[val + 128]; 026 } else { 027 return new Short(val); 028 } 029 } 030 }