Logo Search packages:      
Sourcecode: janino version File versions  Download package

void org::codehaus::janino::UnitCompiler::boxingConversion ( Locatable  l,
IClass  sourceType,
IClass  targetType 
) throws CompileException [inline, private]

Parameters:
sourceType a primitive type (except VOID)
targetType the corresponding wrapper type

Definition at line 7512 of file UnitCompiler.java.

References org::codehaus::janino::IClass::hasIMethod().

                                                                                                             {

        // In some pre-1.5 JDKs, only some wrapper classes have the static "Target.valueOf(source)" method.
        if (targetType.hasIMethod("valueOf", new IClass[] { sourceType })) {
            this.writeOpcode(l, Opcode.INVOKESTATIC);
            this.writeConstantMethodrefInfo(
                targetType.getDescriptor(),
                "valueOf",                                         // classFD
                '(' + sourceType.getDescriptor() + ')' + targetType.getDescriptor() // methodFD
            );
            return;
        }
        // new Target(source)
        this.writeOpcode(l, Opcode.NEW);
        this.writeConstantClassInfo(targetType.getDescriptor());
        if (Descriptor.hasSize2(sourceType.getDescriptor())) {
            this.writeOpcode(l, Opcode.DUP_X2);
            this.writeOpcode(l, Opcode.DUP_X2);
            this.writeOpcode(l, Opcode.POP);
        } else
        {
            this.writeOpcode(l, Opcode.DUP_X1);
            this.writeOpcode(l, Opcode.SWAP);
        }
        this.writeOpcode(l, Opcode.INVOKESPECIAL);
        this.writeConstantMethodrefInfo(
            targetType.getDescriptor(),
            "<init>",                               // classFD
            '(' + sourceType.getDescriptor() + ')' + Descriptor.VOID_ // methodMD
        );
    }


Generated by  Doxygen 1.6.0   Back to index