File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -107,9 +107,6 @@ public function __construct(JavaClass $javaClass)
107107
108108 public function construct (): self
109109 {
110- if (isset ($ this ->staticMethods ['<init> ' ])) {
111- $ this ->getStaticMethods ()->call ('<init> ' );
112- }
113110
114111 // reset dynamic fields
115112 $ this ->dynamicFieldAccessor = new JVM \Field \DynamicField (
@@ -122,6 +119,12 @@ public function construct(): self
122119 $ this ->dynamicMethods
123120 );
124121
122+ if (isset ($ this ->dynamicMethods ['<init> ' ])) {
123+ $ this ->getDynamicMethods ()->call (
124+ '<init> '
125+ );
126+ }
127+
125128 return $ this ;
126129 }
127130
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ class DynamicField implements FieldInterface
99 use FieldSettable;
1010
1111 private $ javaClassInvoker ;
12- private $ fields = [];
12+ public $ fields = [];
1313
1414 public function __construct (JavaClassInvoker $ javaClassInvoker , array $ fields )
1515 {
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ trait FieldGettable
1515 public function get (string $ name )
1616 {
1717 if (!isset ($ this ->fields [$ name ])) {
18+ debug_print_backtrace ();
1819 throw new NoSuchFieldException ('Get to undefined field ' . $ name );
1920 }
2021 if ($ this ->fields [$ name ] instanceof _String) {
Original file line number Diff line number Diff line change @@ -34,6 +34,9 @@ public function execute(): void
3434 return ;
3535 }
3636
37+ $ this ->javaClassInvoker
38+ ->addToSpecialInvokedList ($ methodName , $ signature );
39+
3740 if ($ invokerClass instanceof JavaClass) {
3841 $ result = $ invokerClass ->getInvoker ()->getDynamicMethods ()
3942 ->call (
@@ -50,9 +53,6 @@ public function execute(): void
5053 );
5154 }
5255
53- $ this ->javaClassInvoker
54- ->addToSpecialInvokedList ($ methodName , $ signature );
55-
5656 if ($ parsedSignature [0 ]['type ' ] !== 'void ' ) {
5757 $ this ->pushStack ($ result );
5858 }
Original file line number Diff line number Diff line change @@ -12,15 +12,13 @@ final class _putfield implements OperationInterface
1212 public function execute (): void
1313 {
1414 $ cpInfo = $ this ->getConstantPool ()->getEntries ();
15-
1615 $ cp = $ cpInfo [$ this ->readUnsignedShort ()];
1716 $ class = $ cpInfo [$ cp ->getNameAndTypeIndex ()];
18-
17+
1918 $ value = $ this ->getStack ();
2019 $ name = $ cpInfo [$ class ->getNameIndex ()]->getString ();
21-
2220 $ objectref = $ this ->getStack ();
23-
24- $ objectref ->setInstance ($ name , $ value );
21+
22+ $ objectref ->getInvoker ()-> getDynamicFields ()-> set ($ name , $ value );
2523 }
2624}
Original file line number Diff line number Diff line change 99 new \PHPJava \Core \JavaClassReader (__DIR__ . '/Test.class ' )
1010);
1111
12-
13- var_dump (
14- $ javaClass ->getInvoker ()
15- ->construct ()
16- ->getDynamicFields ()
17- ->get ('z ' )
18- );
19-
2012$ javaClass ->getInvoker ()->getStaticFields ()
2113 ->set ('c ' , 100 )
2214 ->set ('b ' , 'New String ' );
You can’t perform that action at this time.
0 commit comments