1818use PHPJava \Kernel \Mnemonics \OperationInterface ;
1919use PHPJava \Kernel \Structures \_MethodInfo ;
2020use PHPJava \Utilities \Formatter ;
21+ use PHPJava \Utilities \SuperClassResolver ;
2122use PHPJava \Utilities \TypeResolver ;
2223
2324trait Invokable
@@ -59,15 +60,22 @@ public function call(string $name, ...$arguments)
5960 /**
6061 * @var _MethodInfo|null $method
6162 */
62- $ methodReferences = $ this ->methods [$ name ] ?? null ;
63- if ($ methodReferences === null ) {
64- throw new UndefinedMethodException ('Call to undefined method ' . $ name . '. ' );
63+ $ methodReferences = array_merge (
64+ $ this ->methods [$ name ] ?? [],
65+ (new SuperClassResolver ())->resolveMethod ($ name , $ this ->javaClassInvoker ->getJavaClass ())[$ name ] ?? []
66+ );
67+
68+ if (empty ($ methodReferences )) {
69+ if (!isset ($ methodReferences )) {
70+ throw new UndefinedMethodException ('Call to undefined method ' . $ name . '. ' );
71+ }
6572 }
6673
67- $ constantPool = $ this ->javaClassInvoker
74+ $ currentConstantPool = $ this ->javaClassInvoker
6875 ->getJavaClass ()
69- ->getConstantPool ()
70- ->getEntries ();
76+ ->getConstantPool ();
77+
78+ $ constantPool = $ currentConstantPool ->getEntries ();
7179
7280 if ($ name === '<init> ' && $ this ->javaClassInvoker ->getJavaClass ()->hasParentClass ()) {
7381 array_unshift (
@@ -88,8 +96,11 @@ function ($argument) {
8896
8997 $ method = null ;
9098
91- // the special method
9299 foreach ($ methodReferences as $ methodReference ) {
100+ $ constantPool = ($ currentConstantPool = $ methodReference ->getConstantPool ())->getEntries ();
101+ /**
102+ * @var _MethodInfo $methodReference
103+ */
93104 $ methodSignature = Formatter::buildArgumentsSignature (
94105 Formatter::parseSignature ($ constantPool [$ methodReference ->getDescriptorIndex ()]->getString ())['arguments ' ]
95106 );
@@ -140,7 +151,7 @@ function ($argument) {
140151 $ mnemonic = $ mnemonicMap ->getName ($ opcode );
141152
142153 if ($ mnemonic === null ) {
143- throw new UndefinedOpCodeException ('Call to undefined OpCode ' . sprintf ('0x%X ' , $ cursor ) . '. ' );
154+ throw new UndefinedOpCodeException ('Call to undefined OpCode ' . sprintf ('0x%X ' , $ opcode ) . '. ' );
144155 }
145156 $ pointer = $ reader ->getOffset () - 1 ;
146157
@@ -152,7 +163,7 @@ function ($argument) {
152163 * @var OperationInterface|Accumulator|ConstantPool $executor
153164 */
154165 $ executor = new $ fullName ();
155- $ executor ->setConstantPool ($ this -> javaClassInvoker -> getJavaClass ()-> getConstantPool () );
166+ $ executor ->setConstantPool ($ currentConstantPool );
156167 $ executor ->setParameters (
157168 $ this ->javaClassInvoker ,
158169 $ reader ,
@@ -171,4 +182,9 @@ function ($argument) {
171182 $ this ->javaClassInvoker ->getJavaClass ()->appendDebug ($ debugTraces );
172183 return null ;
173184 }
185+
186+ public function getList (): array
187+ {
188+ return $ this ->methods ;
189+ }
174190}
0 commit comments