File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -87,15 +87,17 @@ function ($argument) {
8787 Formatter::parseSignature ($ constantPool [$ methodReference ->getDescriptorIndex ()]->getString ())['arguments ' ]
8888 );
8989
90+ var_dump ($ methodSignature , $ convertedPassedArguments );
91+
9092 if ($ methodSignature === $ convertedPassedArguments ) {
9193 $ method = $ methodReference ;
9294 break ;
9395 }
9496 }
9597
9698 if ($ method === null ) {
97- // var_dump($convertedPassedArguments);
98- // debug_print_backtrace();
99+
100+ debug_print_backtrace ();
99101 throw new NoSuchMethodException ('Call to undefined method ' . $ name . '. ' );
100102 }
101103
Original file line number Diff line number Diff line change @@ -66,6 +66,8 @@ class JavaClass
6666
6767 private $ innerClasses = [];
6868
69+ private $ parentClass ;
70+
6971 /**
7072 * JavaClass constructor.
7173 * @param JavaClassReader $reader
@@ -179,6 +181,22 @@ public function appendDebug($log)
179181 return $ this ;
180182 }
181183
184+ public function hasParentClass (): bool
185+ {
186+ return isset ($ this ->parentClass );
187+ }
188+
189+ public function setParentClass (JavaClass $ class ): self
190+ {
191+ $ this ->parentClass = $ class ;
192+ return $ this ;
193+ }
194+
195+ public function getParentClass (): JavaClass
196+ {
197+ return $ this ->parentClass ;
198+ }
199+
182200 public function debug (): void
183201 {
184202 $ cpInfo = $ this ->getConstantPool ()->getEntries ();
Original file line number Diff line number Diff line change @@ -93,17 +93,18 @@ public function __construct(JavaClass $javaClass)
9393 }
9494
9595 /**
96+ * @param array $arguments
9697 * @return JavaClassInvoker
9798 */
98- public function construct (): self
99+ public function construct (array $ arguments = [] ): self
99100 {
100101 $ this ->dynamicAccessor = new DynamicAccessor (
101102 $ this ,
102103 $ this ->dynamicMethods
103104 );
104105
105106 if (isset ($ this ->dynamicMethods ['<init> ' ])) {
106- $ this ->getDynamic ()->getMethods ()->call ('<init> ' );
107+ $ this ->getDynamic ()->getMethods ()->call ('<init> ' , ... $ arguments );
107108 }
108109
109110 return $ this ;
Original file line number Diff line number Diff line change @@ -26,21 +26,13 @@ public function execute(): void
2626 /**
2727 * @var \PHPJava\Core\JavaClass $classObject
2828 */
29- $ classObject = $ classObject
30- ->getInvoker ()
31- ->construct ()
32- ->getJavaClass ();
3329
34- $ className = explode (
35- '$ ' ,
36- $ classObject ->getClassName ()
37- );
38-
39- if (count ($ className ) > 1 ) {
40- $ classObject ->setParentClass ($ this ->javaClass );
30+ $ classObjectInvoker = $ classObject ->getInvoker ();
31+ $ arguments = [];
32+ if ($ classObject ->hasParentClass ()) {
33+ $ arguments [] = $ this ->javaClass ;
4134 }
42-
43- $ this ->pushStack ($ classObject );
35+ $ this ->pushStack ($ classObjectInvoker ->construct (...$ arguments )->getJavaClass ());
4436 return ;
4537 }
4638 $ this ->pushStack (new $ classObject ());
Original file line number Diff line number Diff line change @@ -34,15 +34,14 @@ public static function resolve($javaPath): array
3434 foreach (static ::$ resolves as [$ resourceType , $ value ]) {
3535 switch ($ resourceType ) {
3636 case static ::RESOURCE_TYPE_FILE :
37- $ relativePathByMainClass = explode ('$ ' , $ relativePath , 2 )[0 ];
38- $ path = realpath ($ value . '/ ' . $ relativePathByMainClass . '.class ' );
37+ $ path = realpath ($ value . '/ ' . $ relativePath . '.class ' );
3938 if (($ key = array_search ($ path , static ::$ resolvedPaths , true )) !== false ) {
4039 return static ::$ resolvedPaths [$ key ];
4140 }
4241 if (is_file ($ path )) {
4342 return $ resolvedPaths [] = [
4443 static ::RESOLVED_TYPE_CLASS ,
45- new JavaClass (new JavaClassReader ($ path )),
44+ ( new JavaClass (new JavaClassReader ($ path )))
4645 ];
4746 }
4847 break ;
You can’t perform that action at this time.
0 commit comments