File tree Expand file tree Collapse file tree 3 files changed +18
-1
lines changed
Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,12 @@ final class Runtime
2121 const LOG_PATH = 'php://stderr ' ;
2222 const LOG_LEVEL = Logger::EMERGENCY ;
2323
24+ const LOAD_ATTRIBUTES = [
25+ 'Code ' ,
26+ 'Exceptions ' ,
27+ 'SourceFile ' ,
28+ ];
29+
2430 const PHP_PACKAGES_MAPS = [
2531 'String ' => '_String ' ,
2632 'Object ' => '_Object ' ,
Original file line number Diff line number Diff line change 11<?php
22namespace PHPJava \Kernel \Attributes ;
33
4+ use PHPJava \Core \JVM \Parameters \GlobalOptions ;
5+ use PHPJava \Core \JVM \Parameters \Runtime ;
46use PHPJava \Exceptions \NotImplementedException ;
57use PHPJava \Exceptions \ValidatorException ;
68use PHPJava \Kernel \Structures \_Methodref ;
@@ -19,12 +21,21 @@ final class AttributeInfo implements AttributeInterface
1921
2022 public function execute (): void
2123 {
24+ $ loadAttributes = GlobalOptions::get ('load_attributes ' ) ?? Runtime::LOAD_ATTRIBUTES ;
25+
2226 $ this ->attributeNameIndex = $ this ->readUnsignedShort ();
2327 $ this ->attributeLength = $ this ->readUnsignedInt ();
2428 $ cpInfo = $ this ->getConstantPool ();
2529 $ currentOffset = $ this ->getOffset ();
2630
2731 $ attributeName = $ cpInfo [$ this ->attributeNameIndex ]->getString ();
32+
33+ if ($ loadAttributes !== null && !in_array ($ attributeName , $ loadAttributes , true )) {
34+ $ this ->read ($ this ->attributeLength );
35+ $ this ->getDebugTool ()->getLogger ()->debug ('Skip to load an attribute: ' . $ attributeName );
36+ return ;
37+ }
38+
2839 $ classAttributeName = '\\PHPJava \\Kernel \\Attributes \\' . $ attributeName . 'Attribute ' ;
2940 $ this ->getDebugTool ()->getLogger ()->debug ('Load an attribute: ' . $ attributeName );
3041 $ this ->attributeData = new $ classAttributeName ($ this ->reader );
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ public function getStartPc()
2323 {
2424 return $ this ->startPc ;
2525 }
26-
26+
2727 public function getLineNumber ()
2828 {
2929 return $ this ->lineNumber ;
You can’t perform that action at this time.
0 commit comments