33
44use PHPJava \Core \JavaArchive ;
55use PHPJava \Core \JavaClass ;
6+ use PHPJava \Core \JVM \Cache \ResolvedClassesCache ;
67use PHPJava \Core \JVM \Parameters \Runtime ;
78use PHPJava \Core \Stream \Reader \FileReader ;
89use PHPJava \Core \Stream \Reader \ReaderInterface ;
10+ use PHPJava \Kernel \Structures \_Classes ;
911use PHPJava \Packages \java \lang \ClassNotFoundException ;
1012
1113class ClassResolver
@@ -16,6 +18,7 @@ class ClassResolver
1618 const RESOURCE_TYPE_FILE = 'RESOURCE_TYPE_FILE ' ;
1719 const RESOURCE_TYPE_JAR = 'RESOURCE_TYPE_JAR ' ;
1820 const RESOURCE_TYPE_CLASS = 'RESOURCE_TYPE_CLASS ' ;
21+ const RESOURCE_TYPE_INNER_CLASS = 'RESOURCE_TYPE_INNER_CLASS ' ;
1922
2023 // resolved types
2124 const RESOLVED_TYPE_CLASS = 'RESOLVED_TYPE_CLASS ' ;
@@ -42,15 +45,26 @@ public function resolve(string $javaPath, JavaClass $class = null): array
4245 $ relativePath = implode ('/ ' , $ namespaces );
4346 foreach ($ this ->resolves as [$ resourceType , $ value ]) {
4447 switch ($ resourceType ) {
48+ case static ::RESOURCE_TYPE_INNER_CLASS :
49+ // TODO: Implement here
50+ break ;
4551 case static ::RESOURCE_TYPE_FILE :
4652 $ path = realpath ($ value . '/ ' . $ relativePath . '.class ' );
4753 if (($ key = array_search ($ path , $ this ->resolvedPaths , true )) !== false ) {
4854 return $ this ->resolvedPaths [$ key ];
4955 }
56+ /**
57+ * @var JavaClass $initiatedClass
58+ */
5059 if (is_file ($ path )) {
51- $ initiatedClass = new JavaClass (
52- new FileReader ($ path ),
53- $ this ->options
60+ $ initiatedClass = ResolvedClassesCache::resolve (
61+ $ path ,
62+ function () use ($ path ) {
63+ return new JavaClass (
64+ new FileReader ($ path ),
65+ $ this ->options
66+ );
67+ }
5468 );
5569 if (strpos ($ relativePath , '$ ' ) !== false && $ class !== null ) {
5670 $ initiatedClass ->setParentClass ($ class );
@@ -73,7 +87,7 @@ public function resolve(string $javaPath, JavaClass $class = null): array
7387 } catch (ClassNotFoundException $ e ) {
7488 }
7589 break ;
76- case static ::RESOLVED_TYPE_CLASS :
90+ case static ::RESOURCE_TYPE_CLASS :
7791 /**
7892 * @var ReaderInterface $value
7993 */
0 commit comments