001 package net.sourceforge.retroweaver.runtime.java.lang; 002 003 public class Integer_ { 004 005 private Integer_() { 006 // private constructor 007 } 008 009 private static Integer[] boxedVals = new Integer[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 Integer(val); // NOPMD by xlv 020 } 021 } 022 023 public static Integer valueOf(final int val) { 024 if (val > -129 && val < 128) { 025 return boxedVals[val + 128]; 026 } else { 027 return new Integer(val); // NOPMD by xlv 028 } 029 } 030 }