@@ -25,6 +25,7 @@ public function __call ($methodName, $arguments) {
2525
2626 }
2727
28+ // メソッドのシグネチャを取得する
2829 $ javaArguments = JavaClass::parseSignature ($ cpInfo [$ methodInfo ->getDescriptorIndex ()]->getString ());
2930
3031 if (sizeof ($ arguments ) !== $ javaArguments ['argumentsCount ' ]) {
@@ -68,7 +69,7 @@ public function __call ($methodName, $arguments) {
6869 3 => null
6970 );
7071
71- $ i = 0 ;
72+ $ i = 1 ;
7273 foreach ($ arguments as $ argument ) {
7374
7475 $ localstorage [$ i ] = $ argument ;
@@ -92,14 +93,23 @@ public function __call ($methodName, $arguments) {
9293
9394 $ statement = new $ name ($ methodName , $ this , $ byteCodeStream , $ stacks , $ localstorage , $ cpInfo , $ attributeData , $ pointer );
9495 $ returnValue = $ statement ->execute ();
95-
96+
9697 // write trace
9798 $ this ->getClass ()->appendTrace ($ opcode , $ pointer , $ stacks , $ byteCodeStream ->getOperands ());
9899
99100 if ($ returnValue !== null ) {
100101
101102 $ this ->getClass ()->traceCompletion ();
102- return $ returnValue ;
103+ if ($ javaArguments [0 ]['type ' ] !== 'class ' ) {
104+ // java typeの取得
105+ $ javaType = 'JavaType ' . ucfirst ($ javaArguments [0 ]['type ' ]);
106+ return new $ javaType ($ returnValue );
107+ }
108+
109+ // javaのオブジェクトの場合
110+
111+ $ javaType = '\\' . str_replace ('/ ' , '\\' , $ javaArguments [0 ]['className ' ]);
112+ return new $ javaType ($ returnValue );
103113
104114 }
105115
@@ -118,7 +128,7 @@ public function __call ($methodName, $arguments) {
118128
119129 }
120130
121- throw new JavaInvokerException ('Unknown Error ' );
131+ throw new JavaInvokerException ('undefined method " ' . $ methodName . ' " ' );
122132
123133 }
124134
0 commit comments