Skip to content

Commit da84d38

Browse files
committed
Try testing emulate anotation (trying deprecated annotation)
1 parent c01ddaa commit da84d38

5 files changed

Lines changed: 69 additions & 2 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
namespace PHPJava\Kernel\Annotations;
3+
4+
use PHPJava\Exceptions\NotImplementedException;
5+
use PHPJava\Utilities\BinaryTool;
6+
7+
final class Annotation implements AnnotationInterface
8+
{
9+
use \PHPJava\Kernel\Core\BinaryReader;
10+
use \PHPJava\Kernel\Core\ConstantPool;
11+
12+
private $typeIndex = 0;
13+
private $numElementValuePairs = 0;
14+
private $elementValuePairs = [];
15+
16+
public function execute(): void
17+
{
18+
$this->typeIndex = $this->readUnsignedShort();
19+
$this->numElementValuePairs = $this->readUnsignedShort();
20+
for ($i = 0; $i < $this->numElementValuePairs; $i++) {
21+
$elementValuePair = (new ElementValuePairs($this->reader))
22+
->setConstantPool($this->getConstantPool());
23+
$elementValuePair->execute();
24+
$this->elementValuePairs[] = $elementValuePair;
25+
}
26+
}
27+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
namespace PHPJava\Kernel\Annotations;
3+
4+
interface AnnotationInterface
5+
{
6+
public function execute(): void;
7+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
namespace PHPJava\Kernel\Annotations;
3+
4+
use PHPJava\Exceptions\NotImplementedException;
5+
use PHPJava\Utilities\BinaryTool;
6+
7+
final class ElementValuePairs implements AnnotationInterface
8+
{
9+
use \PHPJava\Kernel\Core\BinaryReader;
10+
use \PHPJava\Kernel\Core\ConstantPool;
11+
12+
private $elementNameIndex = 0;
13+
private $tag;
14+
15+
public function execute(): void
16+
{
17+
$this->elementNameIndex = $this->readUnsignedShort();
18+
$this->tag = $this->readByte();
19+
20+
var_dump($this->elementNameIndex, $this->tag);
21+
exit();
22+
}
23+
}

src/Kernel/Attributes/DeprecatedAttribute.php

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

12+
1213
public function execute(): void
1314
{
14-
throw new NotImplementedException(__CLASS__);
1515
}
1616
}

src/Kernel/Attributes/RuntimeVisibleAnnotationsAttribute.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,25 @@
22
namespace PHPJava\Kernel\Attributes;
33

44
use PHPJava\Exceptions\NotImplementedException;
5+
use PHPJava\Kernel\Annotations\Annotation;
56
use PHPJava\Utilities\BinaryTool;
67

78
final class RuntimeVisibleAnnotationsAttribute implements AttributeInterface
89
{
910
use \PHPJava\Kernel\Core\BinaryReader;
1011
use \PHPJava\Kernel\Core\ConstantPool;
1112

13+
private $numAnnotations = 0;
14+
private $annotations = [];
15+
1216
public function execute(): void
1317
{
14-
throw new NotImplementedException(__CLASS__);
18+
$this->numAnnotations = $this->readUnsignedShort();
19+
for ($i = 0; $i < $this->numAnnotations; $i++) {
20+
$annotation = new Annotation($this->reader);
21+
$annotation->setConstantPool($this->getConstantPool());
22+
$annotation->execute();
23+
$this->annotations[] = $annotation;
24+
}
1525
}
1626
}

0 commit comments

Comments
 (0)