Skip to content

Commit 54b51e0

Browse files
committed
Fix attribution missed
1 parent 9bdc462 commit 54b51e0

File tree

7 files changed

+47
-8
lines changed

7 files changed

+47
-8
lines changed

src/Core/JVM/ActiveMethods.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ public function __construct(JavaClassReaderInterface $reader, int $entries, Cons
1313
{
1414
$this->reader = $reader;
1515
for ($i = 0; $i < $entries; $i++) {
16-
// not implemented, read only
1716
$this->entries[$i] = new _MethodInfo($reader);
1817
$this->entries[$i]->setConstantPool($constantPool);
1918
$this->entries[$i]->execute();

src/Core/JVM/ConstantPool.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use PHPJava\Kernel\Structures\_Fieldref;
1010
use PHPJava\Kernel\Structures\_Float;
1111
use PHPJava\Kernel\Structures\_Integer;
12+
use PHPJava\Kernel\Structures\_InterfaceMethodref;
1213
use PHPJava\Kernel\Structures\_Long;
1314
use PHPJava\Kernel\Structures\_Methodref;
1415
use PHPJava\Kernel\Structures\_NameAndType;
@@ -74,12 +75,14 @@ private function read($entryTag): ?StructureInterface
7475
return new _NameAndType($this->reader);
7576
case ConstantPoolTag::CONSTANT_Utf8:
7677
return new _Utf8($this->reader);
78+
case ConstantPoolTag::CONSTANT_InterfaceMethodref:
79+
return new _InterfaceMethodref($this->reader);
7780
case ConstantPoolTag::CONSTANT_MethodHandle:
7881
case ConstantPoolTag::CONSTANT_MethodType:
7982
case ConstantPoolTag::CONSTANT_Module:
8083
case ConstantPoolTag::CONSTANT_Package:
81-
throw new ReadEntryException('Entry tag ' . sprintf('0x%06X', $entryTag) . ' is not implemented.');
84+
throw new ReadEntryException('Entry tag ' . sprintf('0x%04X', $entryTag) . ' is not implemented.');
8285
}
83-
throw new ReadEntryException('Entry tag ' . sprintf('0x%06X', $entryTag) . ' is not defined.');
86+
throw new ReadEntryException('Entry tag ' . sprintf('0x%04X', $entryTag) . ' is not defined.');
8487
}
8588
}

src/Kernel/Attributes/AttributeInfo.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
namespace PHPJava\Kernel\Attributes;
33

44
use PHPJava\Exceptions\NotImplementedException;
5+
use PHPJava\Kernel\Structures\_Methodref;
56
use PHPJava\Utilities\BinaryTool;
67

78
final class AttributeInfo implements AttributeInterface
@@ -18,9 +19,6 @@ public function execute(): void
1819
$this->attributeNameIndex = $this->readUnsignedShort();
1920
$this->attributeLength = $this->readUnsignedInt();
2021
$cpInfo = $this->getConstantPool()->getEntries();
21-
if ($this->attributeNameIndex == 0) {
22-
return;
23-
}
2422
$classAttributeName = '\\PHPJava\\Kernel\\Attributes\\' . $cpInfo[$this->attributeNameIndex]->getString() . 'Attribute';
2523
$this->attributeData = new $classAttributeName($this->reader);
2624
$this->attributeData->setConstantPool($this->getConstantPool());

src/Kernel/Attributes/SignatureAttribute.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,15 @@ final class SignatureAttribute implements AttributeInterface
99
use \PHPJava\Kernel\Core\BinaryReader;
1010
use \PHPJava\Kernel\Core\ConstantPool;
1111

12+
private $signatureIndex = 0;
13+
1214
public function execute(): void
1315
{
14-
throw new NotImplementedException(__CLASS__);
16+
$this->signatureIndex = $this->readUnsignedShort();
17+
}
18+
19+
public function getSignatureIndex()
20+
{
21+
return $this->signatureIndex;
1522
}
1623
}

src/Kernel/Structures/_FieldInfo.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ public function execute(): void
2222
$this->descriptorIndex = $this->readUnsignedShort();
2323
$this->attributeCount = $this->readUnsignedShort();
2424
for ($i = 0; $i < $this->attributeCount; $i++) {
25-
$this->attributes[$i] = new \PHPJava\Kernel\Attributes\AttributeInfo($this->reader);
25+
$attribute = new \PHPJava\Kernel\Attributes\AttributeInfo($this->reader);
26+
$attribute->setConstantPool($this->getConstantPool());
27+
$attribute->execute();
28+
29+
$this->attributes[] = $attribute;
2630
}
2731
}
2832

src/Kernel/Structures/_Integer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class _Integer implements StructureInterface
1010
use \PHPJava\Kernel\Core\ConstantPool;
1111

1212
private $bytes = null;
13+
1314
public function execute(): void
1415
{
1516
$this->bytes = $this->readInt();
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
namespace PHPJava\Kernel\Structures;
3+
4+
use PHPJava\Exceptions\NotImplementedException;
5+
use PHPJava\Utilities\BinaryTool;
6+
7+
class _InterfaceMethodref implements StructureInterface
8+
{
9+
use \PHPJava\Kernel\Core\BinaryReader;
10+
use \PHPJava\Kernel\Core\ConstantPool;
11+
12+
private $classIndex = null;
13+
private $nameAndTypeIndex = null;
14+
public function execute(): void
15+
{
16+
$this->classIndex = $this->readUnsignedShort();
17+
$this->nameAndTypeIndex = $this->readUnsignedShort();
18+
}
19+
public function getClassIndex()
20+
{
21+
return $this->classIndex;
22+
}
23+
public function getNameAndTypeIndex()
24+
{
25+
return $this->nameAndTypeIndex;
26+
}
27+
}

0 commit comments

Comments
 (0)