Skip to content

Commit 2892724

Browse files
authored
Merge pull request #137 from php-java/allow-to-overwrite-the-constantpool
Allow to overwrite the Constant Pool
2 parents 9cf003e + fe52a24 commit 2892724

13 files changed

Lines changed: 48 additions & 100 deletions

File tree

src/Core/JVM/ConstantPool.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ public function count()
122122
}
123123

124124
/**
125+
* @param mixed $offset
126+
* @param mixed $value
125127
* @throws ReadOnlyException
126128
*/
127129
public function offsetSet($offset, $value)
@@ -130,6 +132,7 @@ public function offsetSet($offset, $value)
130132
}
131133

132134
/**
135+
* @param mixed $offset
133136
* @throws ReadOnlyException
134137
*/
135138
public function offsetUnset($offset)

src/Core/JVM/Intern/InternInterface.php

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

src/Core/JVM/Intern/StringIntern.php

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

src/Core/JavaClass.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
use PHPJava\Core\JVM\AttributePool;
55
use PHPJava\Core\JVM\FieldPool;
66
use PHPJava\Core\JVM\InterfacePool;
7-
use PHPJava\Core\JVM\Intern\StringIntern;
87
use PHPJava\Core\JVM\MethodPool;
98
use PHPJava\Core\JVM\ConstantPool;
109
use PHPJava\Core\JVM\Parameters\GlobalOptions;

src/Core/JavaClassInvoker.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
use PHPJava\Core\JVM\DynamicAccessor;
55
use PHPJava\Core\JVM\Field\FieldInterface;
6-
use PHPJava\Core\JVM\Intern\StringIntern;
76
use PHPJava\Core\JVM\Invoker\Invokable;
87
use PHPJava\Core\JVM\Invoker\InvokerInterface;
98
use PHPJava\Core\JVM\Parameters\GlobalOptions;
@@ -12,7 +11,6 @@
1211
use PHPJava\Exceptions\IllegalJavaClassException;
1312
use PHPJava\Kernel\Maps\FieldAccessFlag;
1413
use PHPJava\Kernel\Maps\OpCode;
15-
use PHPJava\Kernel\Provider\InternProvider;
1614
use PHPJava\Kernel\Provider\ProviderInterface;
1715
use PHPJava\Kernel\Structures\_FieldInfo;
1816
use PHPJava\Kernel\Structures\_MethodInfo;
@@ -91,15 +89,6 @@ public function __construct(
9189
}
9290
}
9391

94-
// Intern provider registration.
95-
$this->providers = [
96-
'InternProvider' => (new InternProvider())
97-
->add(
98-
StringIntern::class,
99-
new StringIntern()
100-
),
101-
];
102-
10392
$this->dynamicAccessor = new DynamicAccessor(
10493
$this,
10594
$this->dynamicMethods,

src/Kernel/Mnemonics/_aload.php

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

4-
use PHPJava\Core\JVM\Intern\StringIntern;
54
use PHPJava\Exceptions\NotImplementedException;
65
use PHPJava\Utilities\BinaryTool;
76

@@ -16,10 +15,6 @@ final class _aload implements OperationInterface
1615
public function execute(): void
1716
{
1817
$index = $this->readByte();
19-
$stringIntern = $this->javaClassInvoker
20-
->getProvider('InternProvider')
21-
->get(StringIntern::class);
22-
$internedValue = $stringIntern[spl_object_id($this->getLocalStorage($index))] ?? null;
23-
$this->pushToOperandStack($internedValue ?: $this->getLocalStorage($index));
18+
$this->pushToOperandStack($this->getLocalStorage($index));
2419
}
2520
}

src/Kernel/Mnemonics/_aload_0.php

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

4-
use PHPJava\Core\JVM\Intern\StringIntern;
54
use PHPJava\Exceptions\NotImplementedException;
65
use PHPJava\Packages\java\lang\_Object;
76
use PHPJava\Utilities\BinaryTool;
@@ -17,10 +16,6 @@ final class _aload_0 implements OperationInterface
1716
public function execute(): void
1817
{
1918
$index = 0;
20-
$stringIntern = $this->javaClassInvoker
21-
->getProvider('InternProvider')
22-
->get(StringIntern::class);
23-
$internedValue = $stringIntern[spl_object_id($this->getLocalStorage($index))] ?? null;
24-
$this->pushToOperandStack($internedValue ?: $this->getLocalStorage($index));
19+
$this->pushToOperandStack($this->getLocalStorage($index));
2520
}
2621
}

src/Kernel/Mnemonics/_aload_1.php

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

4-
use PHPJava\Core\JVM\Intern\StringIntern;
54
use PHPJava\Exceptions\NotImplementedException;
65
use PHPJava\Packages\java\lang\_Object;
76
use PHPJava\Utilities\BinaryTool;
@@ -17,10 +16,6 @@ final class _aload_1 implements OperationInterface
1716
public function execute(): void
1817
{
1918
$index = 1;
20-
$stringIntern = $this->javaClassInvoker
21-
->getProvider('InternProvider')
22-
->get(StringIntern::class);
23-
$internedValue = $stringIntern[spl_object_id($this->getLocalStorage($index))] ?? null;
24-
$this->pushToOperandStack($internedValue ?: $this->getLocalStorage($index));
19+
$this->pushToOperandStack($this->getLocalStorage($index));
2520
}
2621
}

src/Kernel/Mnemonics/_aload_2.php

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

4-
use PHPJava\Core\JVM\Intern\StringIntern;
54
use PHPJava\Exceptions\NotImplementedException;
65
use PHPJava\Packages\java\lang\_Object;
76
use PHPJava\Utilities\BinaryTool;
@@ -17,10 +16,6 @@ final class _aload_2 implements OperationInterface
1716
public function execute(): void
1817
{
1918
$index = 2;
20-
$stringIntern = $this->javaClassInvoker
21-
->getProvider('InternProvider')
22-
->get(StringIntern::class);
23-
$internedValue = $stringIntern[spl_object_id($this->getLocalStorage($index))] ?? null;
24-
$this->pushToOperandStack($internedValue ?: $this->getLocalStorage($index));
19+
$this->pushToOperandStack($this->getLocalStorage($index));
2520
}
2621
}

src/Kernel/Mnemonics/_aload_3.php

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

4-
use PHPJava\Core\JVM\Intern\StringIntern;
54
use PHPJava\Exceptions\NotImplementedException;
65
use PHPJava\Utilities\BinaryTool;
76

@@ -16,10 +15,6 @@ final class _aload_3 implements OperationInterface
1615
public function execute(): void
1716
{
1817
$index = 3;
19-
$stringIntern = $this->javaClassInvoker
20-
->getProvider('InternProvider')
21-
->get(StringIntern::class);
22-
$internedValue = $stringIntern[spl_object_id($this->getLocalStorage($index))] ?? null;
23-
$this->pushToOperandStack($internedValue ?: $this->getLocalStorage($index));
18+
$this->pushToOperandStack($this->getLocalStorage($index));
2419
}
2520
}

0 commit comments

Comments
 (0)