private static InsnList returnDummy(Type returnType) {
        Validate.notNull(returnType);
        Validate.isTrue(returnType.getSort() != Type.METHOD);

        InsnList ret = new InsnList();

        switch (returnType.getSort()) {
            case Type.VOID:
                ret.add(new InsnNode(Opcodes.RETURN));
                break;
            case Type.BOOLEAN:
            case Type.BYTE:
            case Type.SHORT:
            case Type.CHAR:
            case Type.INT:
                ret.add(new InsnNode(Opcodes.ICONST_0));
                ret.add(new InsnNode(Opcodes.IRETURN));
                break;
            case Type.LONG:
                ret.add(new InsnNode(Opcodes.LCONST_0));
                ret.add(new InsnNode(Opcodes.LRETURN));
                break;
            case Type.FLOAT:
                ret.add(new InsnNode(Opcodes.FCONST_0));
                ret.add(new InsnNode(Opcodes.FRETURN));
                break;
            case Type.DOUBLE:
                ret.add(new InsnNode(Opcodes.DCONST_0));
                ret.add(new InsnNode(Opcodes.DRETURN));
                break;
            case Type.OBJECT:
            case Type.ARRAY:
                ret.add(new InsnNode(Opcodes.ACONST_NULL));
                ret.add(new InsnNode(Opcodes.ARETURN));
                break;
            default:
                throw new IllegalStateException();
        }

        return ret;
    }
private static InsnList returnDummy ( Type returnType ) { Validate . notNull ( returnType ) ; Validate . isTrue ( returnType . getSort ( ) != Type . METHOD ) ; InsnList ret = new InsnList ( ) ; switch ( returnType . getSort ( ) ) { case Type . VOID : ret . add ( new InsnNode ( Opcodes . RETURN ) ) ; break ; case Type . BOOLEAN : case Type . BYTE : case Type . SHORT : case Type . CHAR : case Type . INT : ret . add ( new InsnNode ( Opcodes . ICONST_0 ) ) ; ret . add ( new InsnNode ( Opcodes . IRETURN ) ) ; break ; case Type . LONG : ret . add ( new InsnNode ( Opcodes . LCONST_0 ) ) ; ret . add ( new InsnNode ( Opcodes . LRETURN ) ) ; break ; case Type . FLOAT : ret . add ( new InsnNode ( Opcodes . FCONST_0 ) ) ; ret . add ( new InsnNode ( Opcodes . FRETURN ) ) ; break ; case Type . DOUBLE : ret . add ( new InsnNode ( Opcodes . DCONST_0 ) ) ; ret . add ( new InsnNode ( Opcodes . DRETURN ) ) ; break ; case Type . OBJECT : case Type . ARRAY : ret . add ( new InsnNode ( Opcodes . ACONST_NULL ) ) ; ret . add ( new InsnNode ( Opcodes . ARETURN ) ) ; break ; default : throw new IllegalStateException ( ) ; } return ret ; }
Generates instructions that returns a dummy value. Return values are as follows:
<ul>
<li>void -&gt; no value</li>
<li>boolean -&gt; false</li>
<li>byte/short/char/int -&gt; 0</li>
<li>long -&gt; 0L</li>
<li>float -&gt; 0.0f</li>
<li>double -&gt; 0.0</li>
<li>Object -&gt; null</li>
</ul>

@param returnType return type of the method this generated bytecode is for
@return instructions to return a dummy value
@throws NullPointerException if any argument is {@code null}
@throws IllegalArgumentException if {@code returnType}'s sort is of {@link Type#METHOD}