Skip to content

Commit 1660b96

Browse files
committed
WIP commit
1 parent e7f9ff5 commit 1660b96

17 files changed

Lines changed: 79 additions & 47 deletions

src/bridge/java/lang/StringBuilder.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ public function append($arg)
1010
if ($arg instanceof _String) {
1111
$this->sequence .= $arg->toString();
1212
} else {
13+
if (is_array($arg)) {
14+
$arg = implode($arg);
15+
}
1316
$this->sequence .= $arg;
1417
}
1518
return $this;

src/core/JavaClassInvoker.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
namespace PHPJava\Core;
33

4-
use PHPJava\Core\JVM\Field\GetFieldInterface;
4+
use PHPJava\Core\JVM\Field\FieldInterface;
55
use PHPJava\Core\JVM\Invoker\Invokable;
66
use PHPJava\Core\JVM\Invoker\InvokerInterface;
77
use PHPJava\Kernel\Maps\AccessFlag;
@@ -55,6 +55,9 @@ public function __construct(JavaClass $javaClass)
5555
$this->staticFields[$fieldName] = $fieldInfo;
5656
}
5757
}
58+
59+
// call <clinit>
60+
$this->getStaticMethods()->{'<clinit>'}();
5861
}
5962

6063
public function getJavaClass(): JavaClass
@@ -69,16 +72,16 @@ public function getDynamicMethods(): InvokerInterface
6972

7073
public function getStaticMethods(): InvokerInterface
7174
{
72-
return new JVM\Invoker\StaticMethodInvoker($this, $this->dynamicMethods);
75+
return new JVM\Invoker\StaticMethodInvoker($this, $this->staticMethods);
7376
}
7477

75-
public function getDynamicFields(): GetFieldInterface
78+
public function getDynamicFields(): FieldInterface
7679
{
77-
return new JVM\Field\DynamicFieldGetter($this, $this->dynamicFields);
80+
return new JVM\Field\DynamicField($this, $this->dynamicFields);
7881
}
7982

80-
public function getStaticFields(): GetFieldInterface
83+
public function getStaticFields(): JVM\Field\StaticField
8184
{
82-
return new JVM\Field\StaticFieldGetter($this, $this->staticFields);
85+
return new JVM\Field\StaticField();
8386
}
8487
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
namespace PHPJava\Core\JVM\Field;
3+
4+
use PHPJava\Core\JavaClassInvoker;
5+
6+
class DynamicField implements FieldInterface
7+
{
8+
use FieldGettable;
9+
use FieldSettable;
10+
11+
private $javaClassInvoker;
12+
private $fields = [];
13+
14+
public function __construct(JavaClassInvoker $javaClassInvoker, array $fields)
15+
{
16+
$this->javaClassInvoker = $javaClassInvoker;
17+
$this->fields = $fields;
18+
}
19+
}

src/core/jvm/field/DynamicFieldGetter.php

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/core/jvm/field/FieldGettable.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,6 @@
55

66
trait FieldGettable
77
{
8-
private $javaClassInvoker;
9-
private $fields = [];
10-
11-
public function __construct(JavaClassInvoker $javaClassInvoker, array $fields)
12-
{
13-
$this->javaClassInvoker = $javaClassInvoker;
14-
$this->fields = $fields;
15-
}
16-
178
public function __get($name)
189
{
1910
return $this->fields[$name];
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
use PHPJava\Core\JavaClassInvoker;
55

6-
interface GetFieldInterface
6+
interface FieldInterface
77
{
88
public function __construct(JavaClassInvoker $javaClassInvoker, array $fields);
99
public function __get($name);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
namespace PHPJava\Core\JVM\Field;
3+
4+
use PHPJava\Core\JavaClassInvoker;
5+
6+
trait FieldSettable
7+
{
8+
public function __set($name, $value)
9+
{
10+
$this->fields[$name] = $value;
11+
}
12+
}

src/core/jvm/field/StaticField.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
namespace PHPJava\Core\JVM\Field;
3+
4+
use PHPJava\Core\JavaClassInvoker;
5+
6+
class StaticField
7+
{
8+
private static $fields = [];
9+
10+
public function __get($name)
11+
{
12+
return static::$fields[$name];
13+
}
14+
public function __set($name, $value)
15+
{
16+
static::$fields[$name] = $value;
17+
}
18+
}

src/core/jvm/field/StaticFieldGetter.php

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/core/jvm/invoker/Invokable.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ public function __call($name, $arguments)
8383
}
8484
}
8585

86-
var_dump($codeAttribute);
87-
exit();
86+
return null;
8887
}
8988

9089
private function getCodeAttribute(array $attributes): ?CodeAttribute

0 commit comments

Comments
 (0)