cglib/src/main/java/net/sf/cglib/core/CodeEmitter.java
public void box(Type type) {
        if (TypeUtils.isPrimitive(type)) {
            if (type == Type.VOID_TYPE) {
                aconst_null();
            } else {
                Type boxed = TypeUtils.getBoxedType(type);
                new_instance(boxed);
                if (type.getSize() == 2) {
                    // Pp -> Ppo -> oPpo -> ooPpo -> ooPp -> o
                    dup_x2();
                    dup_x2();
                    pop();
                } else {
                    // p -> po -> opo -> oop -> o
                    dup_x1();
                    swap();
                }
                invoke_constructor(boxed, new Signature(Constants.CONSTRUCTOR_NAME, Type.VOID_TYPE, new Type[]{ type }));
            }
        }
    }
public void box(Type type) {
        if (TypeUtils.isPrimitive(type)) {
            if (type == Type.VOID_TYPE) {
                aconst_null();
            } else {
                Type boxed = TypeUtils.getBoxedType(type);
                new_instance(boxed);
                if (type.getSize() == 2) {
                    // Pp -> Ppo -> oPpo -> ooPpo -> ooPp -> o
                    dup_x2();
                    dup_x2();
                    pop();
                } else {
                    // p -> po -> opo -> oop -> o
                    dup_x1();
                    swap();
                }
                invoke_constructor(boxed, new Signature(Constants.CONSTRUCTOR_NAME, Type.VOID_TYPE, new Type[]{ type }));
            }
        }
    }
public void box ( Type type ) { if ( TypeUtils . isPrimitive ( type ) ) { if ( type == Type . VOID_TYPE ) { aconst_null ( ) ; } else { Type boxed = TypeUtils . getBoxedType ( type ) ; new_instance ( boxed ) ; if ( type . getSize ( ) == 2 ) { // Pp -> Ppo -> oPpo -> ooPpo -> ooPp -> o dup_x2 ( ) ; dup_x2 ( ) ; pop ( ) ; } else { // p -> po -> opo -> oop -> o dup_x1 ( ) ; swap ( ) ; } invoke_constructor ( boxed , new Signature ( Constants . CONSTRUCTOR_NAME , Type . VOID_TYPE , new Type [ ] { type } ) ) ; } } }
If the argument is a primitive class, replaces the primitive value
on the top of the stack with the wrapped (Object) equivalent. For
example, char -> Character.
If the class is Void, a null is pushed onto the stack instead.
@param type the class indicating the current type of the top stack value
If the argument is a primitive class replaces the primitive value on the top of the stack with the wrapped ( Object ) equivalent . For example char - > Character . If the class is Void a null is pushed onto the stack instead .