55use PHPJava \Exceptions \NotImplementedException ;
66use PHPJava \Utilities \BinaryTool ;
77use PHPJava \Utilities \Formatter ;
8+ use PHPJava \Utilities \MethodNameResolver ;
89
910final class _invokespecial implements OperationInterface
1011{
@@ -16,33 +17,43 @@ public function execute(): void
1617 $ cpInfo = $ this ->getConstantPool ()->getEntries ();
1718 $ cp = $ cpInfo [$ this ->readUnsignedShort ()];
1819 $ nameAndTypeIndex = $ cpInfo [$ cp ->getNameAndTypeIndex ()];
19- $ signature = Formatter::parseSignature ($ cpInfo [$ nameAndTypeIndex ->getDescriptorIndex ()]->getString ());
20+ $ signature = $ cpInfo [$ nameAndTypeIndex ->getDescriptorIndex ()]->getString ();
21+ $ parsedSignature = Formatter::parseSignature ($ signature );
2022 $ invokerClass = $ this ->getStack ();
2123
2224 $ arguments = [];
2325
24- for ($ i = 0 ; $ i < $ signature ['arguments_count ' ]; $ i ++) {
26+ for ($ i = 0 ; $ i < $ parsedSignature ['arguments_count ' ]; $ i ++) {
2527 $ arguments [] = $ this ->getStack ();
2628 }
2729
2830 krsort ($ arguments );
2931
3032 $ methodName = $ cpInfo [$ nameAndTypeIndex ->getNameIndex ()]->getString ();
33+ if ($ this ->javaClassInvoker ->isInvoked ($ methodName , $ signature )) {
34+ return ;
35+ }
3136
3237 if ($ invokerClass instanceof JavaClass) {
33- // $result = $invokerClass->getInvoker()->getDynamicMethods()
34- // ->call($methodName, ...$arguments);
38+ $ result = $ invokerClass ->getInvoker ()->getDynamicMethods ()
39+ ->call (
40+ $ methodName ,
41+ ...$ arguments
42+ );
3543 } else {
3644 $ result = call_user_func_array (
3745 [
3846 $ invokerClass ,
39- $ methodName
47+ MethodNameResolver:: resolve ( $ methodName),
4048 ],
4149 $ arguments
4250 );
4351 }
4452
45- if ($ signature [0 ]['type ' ] !== 'void ' ) {
53+ $ this ->javaClassInvoker
54+ ->addToSpecialInvokedList ($ methodName , $ signature );
55+
56+ if ($ parsedSignature [0 ]['type ' ] !== 'void ' ) {
4657 $ this ->pushStack ($ result );
4758 }
4859 }
0 commit comments