Mantis - Quercus
Viewing Issue Advanced Details
5185 minor always 08-21-12 10:44 08-23-12 15:10
matthiasblaesing  
nam  
normal  
closed  
fixed  
none    
none 4.0.31  
0005185: Marshalling (php->enum) of null for enums fails
When testing quercus for internal systems I noticed, that some aspects of our internal api could not be used, as the system failed to correctly marshal null values for enums.

---------- Minimal example: -----------

===== File: Test.java ======
public class Test {
    public void testEnum(TestEnum x) {
        System.out.println(x);
    }
}

===== File: TestEnum.java ======
public enum TestEnum { A, B }

===== File: test.php =====
<?

import Test;
import TestEnum;

$a = new Test();

$a->testEnum( null );
$a->testEnum( "A" );
$a->testEnum( TestEnum::B );

===== Invokation ======
java -cp lib/resin.jar:. com.caucho.quercus.CliQuercus test.php

===== Output =====
Exception in thread "main" java.lang.IllegalArgumentException: No enum constant TestEnum.
    at java.lang.Enum.valueOf(Enum.java:236)
    at com.caucho.quercus.marshal.EnumMarshal.marshal(EnumMarshal.java:59)
    at com.caucho.quercus.env.JavaInvoker.callJavaMethod(JavaInvoker.java:748)
    at com.caucho.quercus.env.JavaInvoker.callMethod(JavaInvoker.java:684)
    at com.caucho.quercus.program.JavaClassDef.callMethod(JavaClassDef.java:661)
    at com.caucho.quercus.env.JavaValue.callMethod(JavaValue.java:327)
    at com.caucho.quercus.expr.AbstractMethodExpr.eval(AbstractMethodExpr.java:91)
    at com.caucho.quercus.expr.ObjectMethodExpr.eval(ObjectMethodExpr.java:97)
    at com.caucho.quercus.expr.Expr.evalTop(Expr.java:528)
    at com.caucho.quercus.statement.ExprStatement.execute(ExprStatement.java:67)
    at com.caucho.quercus.statement.BlockStatement.execute(BlockStatement.java:105)
    at com.caucho.quercus.program.QuercusProgram.execute(QuercusProgram.java:414)
    at com.caucho.quercus.page.InterpretedPage.execute(InterpretedPage.java:89)
    at com.caucho.quercus.env.Env.executePageTop(Env.java:4239)
    at com.caucho.quercus.env.Env.executeTop(Env.java:4182)
    at com.caucho.quercus.env.Env.execute(Env.java:4157)
    at com.caucho.quercus.Quercus.execute(Quercus.java:202)
    at com.caucho.quercus.Quercus.execute(Quercus.java:177)
    at com.caucho.quercus.CliQuercus.main(CliQuercus.java:63)

===== Expected Output =====
null
A
B

---------- Proposed Fix: -----------

Handle the null pointer / NullPointer in marshal Method in EnumMarshal.java (see attached file)
 enum_marshalling.patch [^] (806 bytes) 08-21-12 10:44

Notes
(0006015)
nam   
08-23-12 15:10   
php/0cs2