Path: blob/master/src/java.base/share/classes/sun/invoke/util/Wrapper.java
41159 views
/*1* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.invoke.util;2627public enum Wrapper {28// wrapperType simple primitiveType simple char emptyArray format29BOOLEAN( Boolean.class, "Boolean", boolean.class, "boolean", 'Z', new boolean[0], Format.unsigned( 1)),30// These must be in the order defined for widening primitive conversions in JLS 5.1.231// Avoid boxing integral types here to defer initialization of internal caches32BYTE ( Byte.class, "Byte", byte.class, "byte", 'B', new byte[0], Format.signed( 8)),33SHORT ( Short.class, "Short", short.class, "short", 'S', new short[0], Format.signed( 16)),34CHAR (Character.class, "Character", char.class, "char", 'C', new char[0], Format.unsigned(16)),35INT ( Integer.class, "Integer", int.class, "int", 'I', new int[0], Format.signed( 32)),36LONG ( Long.class, "Long", long.class, "long", 'J', new long[0], Format.signed( 64)),37FLOAT ( Float.class, "Float", float.class, "float", 'F', new float[0], Format.floating(32)),38DOUBLE ( Double.class, "Double", double.class, "double", 'D', new double[0], Format.floating(64)),39OBJECT ( Object.class, "Object", Object.class, "Object", 'L', new Object[0], Format.other( 1)),40// VOID must be the last type, since it is "assignable" from any other type:41VOID ( Void.class, "Void", void.class, "void", 'V', null, Format.other( 0)),42;4344public static final int COUNT = 10;4546private final Class<?> wrapperType;47private final Class<?> primitiveType;48private final char basicTypeChar;49private final String basicTypeString;50private final Object emptyArray;51private final int format;52private final String wrapperSimpleName;53private final String primitiveSimpleName;5455private Wrapper(Class<?> wtype, String wtypeName, Class<?> ptype, String ptypeName, char tchar, Object emptyArray, int format) {56this.wrapperType = wtype;57this.primitiveType = ptype;58this.basicTypeChar = tchar;59this.basicTypeString = String.valueOf(this.basicTypeChar);60this.emptyArray = emptyArray;61this.format = format;62this.wrapperSimpleName = wtypeName;63this.primitiveSimpleName = ptypeName;64}6566/** For debugging, give the details of this wrapper. */67public String detailString() {68return wrapperSimpleName+69java.util.Arrays.asList(wrapperType, primitiveType,70basicTypeChar, zero(),71"0x"+Integer.toHexString(format));72}7374private abstract static class Format {75static final int SLOT_SHIFT = 0, SIZE_SHIFT = 2, KIND_SHIFT = 12;76static final int77SIGNED = (-1) << KIND_SHIFT,78UNSIGNED = 0 << KIND_SHIFT,79FLOATING = 1 << KIND_SHIFT;80static final int81SLOT_MASK = ((1<<(SIZE_SHIFT-SLOT_SHIFT))-1),82SIZE_MASK = ((1<<(KIND_SHIFT-SIZE_SHIFT))-1);83static int format(int kind, int size, int slots) {84assert(((kind >> KIND_SHIFT) << KIND_SHIFT) == kind);85assert((size & (size-1)) == 0); // power of two86assert((kind == SIGNED) ? (size > 0) :87(kind == UNSIGNED) ? (size > 0) :88(kind == FLOATING) ? (size == 32 || size == 64) :89false);90assert((slots == 2) ? (size == 64) :91(slots == 1) ? (size <= 32) :92false);93return kind | (size << SIZE_SHIFT) | (slots << SLOT_SHIFT);94}95static final int96INT = SIGNED | (32 << SIZE_SHIFT) | (1 << SLOT_SHIFT),97SHORT = SIGNED | (16 << SIZE_SHIFT) | (1 << SLOT_SHIFT),98BOOLEAN = UNSIGNED | (1 << SIZE_SHIFT) | (1 << SLOT_SHIFT),99CHAR = UNSIGNED | (16 << SIZE_SHIFT) | (1 << SLOT_SHIFT),100FLOAT = FLOATING | (32 << SIZE_SHIFT) | (1 << SLOT_SHIFT),101VOID = UNSIGNED | (0 << SIZE_SHIFT) | (0 << SLOT_SHIFT),102NUM_MASK = (-1) << SIZE_SHIFT;103static int signed(int size) { return format(SIGNED, size, (size > 32 ? 2 : 1)); }104static int unsigned(int size) { return format(UNSIGNED, size, (size > 32 ? 2 : 1)); }105static int floating(int size) { return format(FLOATING, size, (size > 32 ? 2 : 1)); }106static int other(int slots) { return slots << SLOT_SHIFT; }107}108109/// format queries:110111/** How many bits are in the wrapped value? Returns 0 for OBJECT or VOID. */112public int bitWidth() { return (format >> Format.SIZE_SHIFT) & Format.SIZE_MASK; }113/** How many JVM stack slots occupied by the wrapped value? Returns 0 for VOID. */114public int stackSlots() { return (format >> Format.SLOT_SHIFT) & Format.SLOT_MASK; }115/** Does the wrapped value occupy a single JVM stack slot? */116public boolean isSingleWord() { return (format & (1 << Format.SLOT_SHIFT)) != 0; }117/** Does the wrapped value occupy two JVM stack slots? */118public boolean isDoubleWord() { return (format & (2 << Format.SLOT_SHIFT)) != 0; }119/** Is the wrapped type numeric (not void or object)? */120public boolean isNumeric() { return (format & Format.NUM_MASK) != 0; }121/** Is the wrapped type a primitive other than float, double, or void? */122public boolean isIntegral() { return isNumeric() && format < Format.FLOAT; }123/** Is the wrapped type one of int, boolean, byte, char, or short? */124public boolean isSubwordOrInt() { return isIntegral() && isSingleWord(); }125/* Is the wrapped value a signed integral type (one of byte, short, int, or long)? */126public boolean isSigned() { return format < Format.VOID; }127/* Is the wrapped value an unsigned integral type (one of boolean or char)? */128public boolean isUnsigned() { return format >= Format.BOOLEAN && format < Format.FLOAT; }129/** Is the wrapped type either float or double? */130public boolean isFloating() { return format >= Format.FLOAT; }131/** Is the wrapped type either void or a reference? */132public boolean isOther() { return (format & ~Format.SLOT_MASK) == 0; }133134/** Does the JLS 5.1.2 allow a variable of this wrapper's135* primitive type to be assigned from a value of the given wrapper's primitive type?136* Cases:137* <ul>138* <li>unboxing followed by widening primitive conversion139* <li>any type converted to {@code void} (i.e., dropping a method call's value)140* <li>boxing conversion followed by widening reference conversion to {@code Object}141* </ul>142* These are the cases allowed by MethodHandle.asType.143*/144public boolean isConvertibleFrom(Wrapper source) {145if (this == source) return true;146if (this.compareTo(source) < 0) {147// At best, this is a narrowing conversion.148return false;149}150// All conversions are allowed in the enum order between floats and signed ints.151// First detect non-signed non-float types (boolean, char, Object, void).152boolean floatOrSigned = (((this.format & source.format) & Format.SIGNED) != 0);153if (!floatOrSigned) {154if (this.isOther()) return true;155// can convert char to int or wider, but nothing else156if (source.format == Format.CHAR) return true;157// no other conversions are classified as widening158return false;159}160// All signed and float conversions in the enum order are widening.161assert(this.isFloating() || this.isSigned());162assert(source.isFloating() || source.isSigned());163return true;164}165166static {167assert(checkConvertibleFrom());168assert(COUNT == Wrapper.values().length);169}170private static boolean checkConvertibleFrom() {171// Check the matrix for correct classification of widening conversions.172for (Wrapper w : values()) {173assert(w.isConvertibleFrom(w));174assert(VOID.isConvertibleFrom(w));175if (w != VOID) {176assert(OBJECT.isConvertibleFrom(w));177assert(!w.isConvertibleFrom(VOID));178}179// check relations with unsigned integral types:180if (w != CHAR) {181assert(!CHAR.isConvertibleFrom(w));182if (!w.isConvertibleFrom(INT))183assert(!w.isConvertibleFrom(CHAR));184}185if (w != BOOLEAN) {186assert(!BOOLEAN.isConvertibleFrom(w));187if (w != VOID && w != OBJECT)188assert(!w.isConvertibleFrom(BOOLEAN));189}190// check relations with signed integral types:191if (w.isSigned()) {192for (Wrapper x : values()) {193if (w == x) continue;194if (x.isFloating())195assert(!w.isConvertibleFrom(x));196else if (x.isSigned()) {197if (w.compareTo(x) < 0)198assert(!w.isConvertibleFrom(x));199else200assert(w.isConvertibleFrom(x));201}202}203}204// check relations with floating types:205if (w.isFloating()) {206for (Wrapper x : values()) {207if (w == x) continue;208if (x.isSigned())209assert(w.isConvertibleFrom(x));210else if (x.isFloating()) {211if (w.compareTo(x) < 0)212assert(!w.isConvertibleFrom(x));213else214assert(w.isConvertibleFrom(x));215}216}217}218}219return true; // i.e., assert(true)220}221222/** Produce a zero value for the given wrapper type.223* This will be a numeric zero for a number or character,224* false for a boolean, and null for a reference or void.225* The common thread is that this is what is contained226* in a default-initialized variable of the given primitive227* type. (For void, it is what a reflective method returns228* instead of no value at all.)229*/230public Object zero() {231switch (this) {232case BOOLEAN:233return Boolean.FALSE;234case INT:235return (Integer)0;236case BYTE:237return (Byte)(byte)0;238case CHAR:239return (Character)(char)0;240case SHORT:241return (Short)(short)0;242case LONG:243return (Long)(long)0;244case FLOAT:245return FLOAT_ZERO;246case DOUBLE:247return DOUBLE_ZERO;248case VOID:249case OBJECT:250default:251return null;252}253}254255private static final Object DOUBLE_ZERO = (Double)(double)0;256private static final Object FLOAT_ZERO = (Float)(float)0;257258/** Produce a zero value for the given wrapper type T.259* The optional argument must a type compatible with this wrapper.260* Equivalent to {@code this.cast(this.zero(), type)}.261*/262public <T> T zero(Class<T> type) { return convert(zero(), type); }263264/** Return the wrapper that wraps values of the given type.265* The type may be {@code Object}, meaning the {@code OBJECT} wrapper.266* Otherwise, the type must be a primitive.267* @throws IllegalArgumentException for unexpected types268*/269public static Wrapper forPrimitiveType(Class<?> type) {270Wrapper w = findPrimitiveType(type);271if (w != null) return w;272if (type.isPrimitive())273throw new InternalError(); // redo hash function274throw newIllegalArgumentException("not primitive: "+type);275}276277/** Return the wrapper that corresponds to the provided basic type char.278* The basic type char must be for one of the eight primitive types, or void.279* @throws IllegalArgumentException for unexpected types280*/281public static Wrapper forPrimitiveType(char basicTypeChar) {282switch (basicTypeChar) {283case 'I': return INT;284case 'J': return LONG;285case 'S': return SHORT;286case 'B': return BYTE;287case 'C': return CHAR;288case 'F': return FLOAT;289case 'D': return DOUBLE;290case 'Z': return BOOLEAN;291case 'V': return VOID;292default: throw newIllegalArgumentException("not primitive: " + basicTypeChar);293}294}295296static Wrapper findPrimitiveType(Class<?> type) {297Wrapper w = FROM_PRIM[hashPrim(type)];298if (w != null && w.primitiveType == type) {299return w;300}301return null;302}303304/** Return the wrapper that wraps values into the given wrapper type.305* If it is {@code Object}, return {@code OBJECT}.306* Otherwise, it must be a wrapper type.307* The type must not be a primitive type.308* @throws IllegalArgumentException for unexpected types309*/310public static Wrapper forWrapperType(Class<?> type) {311Wrapper w = findWrapperType(type);312if (w != null) return w;313for (Wrapper x : values())314if (x.wrapperType == type)315throw new InternalError(); // redo hash function316throw newIllegalArgumentException("not wrapper: "+type);317}318319static Wrapper findWrapperType(Class<?> type) {320Wrapper w = FROM_WRAP[hashWrap(type)];321if (w != null && w.wrapperType == type) {322return w;323}324return null;325}326327/** Return the wrapper that corresponds to the given bytecode328* signature character. Return {@code OBJECT} for the character 'L'.329* @throws IllegalArgumentException for any non-signature character or {@code '['}.330*/331public static Wrapper forBasicType(char type) {332Wrapper w = FROM_CHAR[hashChar(type)];333if (w != null && w.basicTypeChar == type) {334return w;335}336for (Wrapper x : values())337if (w.basicTypeChar == type)338throw new InternalError(); // redo hash function339throw newIllegalArgumentException("not basic type char: "+type);340}341342/** Return the wrapper for the given type, if it is343* a primitive type, else return {@code OBJECT}.344*/345public static Wrapper forBasicType(Class<?> type) {346if (type.isPrimitive())347return forPrimitiveType(type);348return OBJECT; // any reference, including wrappers or arrays349}350351// Note on perfect hashes:352// for signature chars c, do (c + (c >> 1)) % 16353// for primitive type names n, do (n[0] + n[2]) % 16354// The type name hash works for both primitive and wrapper names.355// You can add "java/lang/Object" to the primitive names.356// But you add the wrapper name Object, use (n[2] + (3*n[1])) % 16.357private static final Wrapper[] FROM_PRIM = new Wrapper[16];358private static final Wrapper[] FROM_WRAP = new Wrapper[16];359private static final Wrapper[] FROM_CHAR = new Wrapper[16];360private static int hashPrim(Class<?> x) {361String xn = x.getName();362if (xn.length() < 3) return 0;363return (xn.charAt(0) + xn.charAt(2)) % 16;364}365private static int hashWrap(Class<?> x) {366String xn = x.getName();367final int offset = 10; assert(offset == "java.lang.".length());368if (xn.length() < offset+3) return 0;369return (3*xn.charAt(offset+1) + xn.charAt(offset+2)) % 16;370}371private static int hashChar(char x) {372return (x + (x >> 1)) % 16;373}374static {375for (Wrapper w : values()) {376int pi = hashPrim(w.primitiveType);377int wi = hashWrap(w.wrapperType);378int ci = hashChar(w.basicTypeChar);379assert(FROM_PRIM[pi] == null);380assert(FROM_WRAP[wi] == null);381assert(FROM_CHAR[ci] == null);382FROM_PRIM[pi] = w;383FROM_WRAP[wi] = w;384FROM_CHAR[ci] = w;385}386//assert(jdk.sun.invoke.util.WrapperTest.test(false));387}388389/** What is the primitive type wrapped by this wrapper? */390public Class<?> primitiveType() { return primitiveType; }391392/** What is the wrapper type for this wrapper? */393public Class<?> wrapperType() { return wrapperType; }394395/** What is the wrapper type for this wrapper?396* Otherwise, the example type must be the wrapper type,397* or the corresponding primitive type.398* (For {@code OBJECT}, the example type can be any non-primitive,399* and is normalized to {@code Object.class}.)400* The resulting class type has the same type parameter.401*/402public <T> Class<T> wrapperType(Class<T> exampleType) {403if (exampleType == wrapperType) {404return exampleType;405} else if (exampleType == primitiveType ||406wrapperType == Object.class ||407exampleType.isInterface()) {408return forceType(wrapperType, exampleType);409}410throw newClassCastException(exampleType, primitiveType);411}412413private static ClassCastException newClassCastException(Class<?> actual, Class<?> expected) {414return new ClassCastException(actual + " is not compatible with " + expected);415}416417/** If {@code type} is a primitive type, return the corresponding418* wrapper type, else return {@code type} unchanged.419*/420public static <T> Class<T> asWrapperType(Class<T> type) {421if (type.isPrimitive()) {422return forPrimitiveType(type).wrapperType(type);423}424return type;425}426427/** If {@code type} is a wrapper type, return the corresponding428* primitive type, else return {@code type} unchanged.429*/430public static <T> Class<T> asPrimitiveType(Class<T> type) {431Wrapper w = findWrapperType(type);432if (w != null) {433return forceType(w.primitiveType(), type);434}435return type;436}437438/** Query: Is the given type a wrapper, such as {@code Integer} or {@code Void}? */439public static boolean isWrapperType(Class<?> type) {440return findWrapperType(type) != null;441}442443/** Query: Is the given type a primitive, such as {@code int} or {@code void}? */444public static boolean isPrimitiveType(Class<?> type) {445return type.isPrimitive();446}447448/** What is the bytecode signature character for this type?449* All non-primitives, including array types, report as 'L', the signature character for references.450*/451public static char basicTypeChar(Class<?> type) {452if (!type.isPrimitive())453return 'L';454else455return forPrimitiveType(type).basicTypeChar();456}457458/** What is the bytecode signature character for this wrapper's459* primitive type?460*/461public char basicTypeChar() { return basicTypeChar; }462463/** What is the bytecode signature string for this wrapper's464* primitive type?465*/466public String basicTypeString() { return basicTypeString; }467468/** What is the simple name of the wrapper type?469*/470public String wrapperSimpleName() { return wrapperSimpleName; }471472/** What is the simple name of the primitive type?473*/474public String primitiveSimpleName() { return primitiveSimpleName; }475476// /** Wrap a value in the given type, which may be either a primitive or wrapper type.477// * Performs standard primitive conversions, including truncation and float conversions.478// */479// public static <T> T wrap(Object x, Class<T> type) {480// return Wrapper.valueOf(type).cast(x, type);481// }482483/** Cast a wrapped value to the given type, which may be either a primitive or wrapper type.484* The given target type must be this wrapper's primitive or wrapper type.485* If this wrapper is OBJECT, the target type may also be an interface, perform no runtime check.486* Performs standard primitive conversions, including truncation and float conversions.487* The given type must be compatible with this wrapper. That is, it must either488* be the wrapper type (or a subtype, in the case of {@code OBJECT}) or else489* it must be the wrapper's primitive type.490* Primitive conversions are only performed if the given type is itself a primitive.491* @throws ClassCastException if the given type is not compatible with this wrapper492*/493public <T> T cast(Object x, Class<T> type) {494return convert(x, type, true);495}496497/** Convert a wrapped value to the given type.498* The given target type must be this wrapper's primitive or wrapper type.499* This is equivalent to {@link #cast}, except that it refuses to perform500* narrowing primitive conversions.501*/502public <T> T convert(Object x, Class<T> type) {503return convert(x, type, false);504}505506private <T> T convert(Object x, Class<T> type, boolean isCast) {507if (this == OBJECT) {508// If the target wrapper is OBJECT, just do a reference cast.509// If the target type is an interface, perform no runtime check.510// (This loophole is safe, and is allowed by the JVM verifier.)511// If the target type is a primitive, change it to a wrapper.512assert(!type.isPrimitive());513if (!type.isInterface())514type.cast(x);515@SuppressWarnings("unchecked")516T result = (T) x; // unchecked warning is expected here517return result;518}519Class<T> wtype = wrapperType(type);520if (wtype.isInstance(x)) {521return wtype.cast(x);522}523if (!isCast) {524Class<?> sourceType = x.getClass(); // throw NPE if x is null525Wrapper source = findWrapperType(sourceType);526if (source == null || !this.isConvertibleFrom(source)) {527throw newClassCastException(wtype, sourceType);528}529} else if (x == null) {530@SuppressWarnings("unchecked")531T z = (T) zero();532return z;533}534@SuppressWarnings("unchecked")535T result = (T) wrap(x); // unchecked warning is expected here536assert (result == null ? Void.class : result.getClass()) == wtype;537return result;538}539540/** Cast a reference type to another reference type.541* If the target type is an interface, perform no runtime check.542* (This loophole is safe, and is allowed by the JVM verifier.)543* If the target type is a primitive, change it to a wrapper.544*/545static <T> Class<T> forceType(Class<?> type, Class<T> exampleType) {546assert(type == exampleType ||547type.isPrimitive() && forPrimitiveType(type) == findWrapperType(exampleType) ||548exampleType.isPrimitive() && forPrimitiveType(exampleType) == findWrapperType(type) ||549type == Object.class && !exampleType.isPrimitive());550@SuppressWarnings("unchecked")551Class<T> result = (Class<T>) type; // unchecked warning is expected here552return result;553}554555/** Wrap a value in this wrapper's type.556* Performs standard primitive conversions, including truncation and float conversions.557* Performs returns the unchanged reference for {@code OBJECT}.558* Returns null for {@code VOID}.559* Returns a zero value for a null input.560* @throws ClassCastException if this wrapper is numeric and the operand561* is not a number, character, boolean, or null562*/563public Object wrap(Object x) {564// do non-numeric wrappers first565switch (basicTypeChar) {566case 'L': return x;567case 'V': return null;568}569Number xn = numberValue(x);570switch (basicTypeChar) {571case 'I': return Integer.valueOf(xn.intValue());572case 'J': return Long.valueOf(xn.longValue());573case 'F': return Float.valueOf(xn.floatValue());574case 'D': return Double.valueOf(xn.doubleValue());575case 'S': return Short.valueOf((short) xn.intValue());576case 'B': return Byte.valueOf((byte) xn.intValue());577case 'C': return Character.valueOf((char) xn.intValue());578case 'Z': return Boolean.valueOf(boolValue(xn.byteValue()));579}580throw new InternalError("bad wrapper");581}582583/** Wrap a value (an int or smaller value) in this wrapper's type.584* Performs standard primitive conversions, including truncation and float conversions.585* Produces an {@code Integer} for {@code OBJECT}, although the exact type586* of the operand is not known.587* Returns null for {@code VOID}.588*/589public Object wrap(int x) {590switch (basicTypeChar) {591case 'L': return (Integer)x;592case 'V': return null;593case 'I': return Integer.valueOf(x);594case 'J': return Long.valueOf(x);595case 'F': return Float.valueOf(x);596case 'D': return Double.valueOf(x);597case 'S': return Short.valueOf((short) x);598case 'B': return Byte.valueOf((byte) x);599case 'C': return Character.valueOf((char) x);600case 'Z': return Boolean.valueOf(boolValue((byte) x));601}602throw new InternalError("bad wrapper");603}604605private static Number numberValue(Object x) {606if (x instanceof Number) return (Number)x;607if (x instanceof Character) return (int)(Character)x;608if (x instanceof Boolean) return (Boolean)x ? 1 : 0;609// Remaining allowed case of void: Must be a null reference.610return (Number)x;611}612613// Parameter type of boolValue must be byte, because614// MethodHandles.explicitCastArguments defines boolean615// conversion as first converting to byte.616private static boolean boolValue(byte bits) {617bits &= 1; // simple 31-bit zero extension618return (bits != 0);619}620621private static RuntimeException newIllegalArgumentException(String message, Object x) {622return newIllegalArgumentException(message + x);623}624private static RuntimeException newIllegalArgumentException(String message) {625return new IllegalArgumentException(message);626}627628// primitive array support629public Object makeArray(int len) {630return java.lang.reflect.Array.newInstance(primitiveType, len);631}632public Class<?> arrayType() {633return emptyArray.getClass();634}635public void copyArrayUnboxing(Object[] values, int vpos, Object a, int apos, int length) {636if (a.getClass() != arrayType())637arrayType().cast(a); // throw NPE or CCE if bad type638for (int i = 0; i < length; i++) {639Object value = values[i+vpos];640value = convert(value, primitiveType);641java.lang.reflect.Array.set(a, i+apos, value);642}643}644public void copyArrayBoxing(Object a, int apos, Object[] values, int vpos, int length) {645if (a.getClass() != arrayType())646arrayType().cast(a); // throw NPE or CCE if bad type647for (int i = 0; i < length; i++) {648Object value = java.lang.reflect.Array.get(a, i+apos);649//Already done: value = convert(value, primitiveType);650assert(value.getClass() == wrapperType);651values[i+vpos] = value;652}653}654}655656657