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