Skip to content
This repository was archived by the owner on Jun 7, 2019. It is now read-only.

Commit 587c9dd

Browse files
committed
Fix SDK, update JarClassLoader
1 parent f4deb23 commit 587c9dd

File tree

5 files changed

+56
-17
lines changed

5 files changed

+56
-17
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/.gradle/**
22
/.idea/**
33
/build/**
4+
/bundle/**
45
/gradle/
56
/jars/**
67
/out/**

package.php.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: java-reflection-ext
2-
version: 1.2.0
2+
version: 1.2.1
33
description: Java Reflection API
44

55
plugins:
@@ -20,7 +20,7 @@ doc:
2020
ru: Русский
2121

2222
develnext-bundle:
23-
version: 1.2.0
23+
version: 1.2.1
2424
name: "Java Reflection API"
2525
author: "Venity Studio"
2626
icon: "develnext/bundle/reflection/icon32.png"

sdk/java/reflection/JarClassLoader.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,15 @@ class JarClassLoader
1111
/**
1212
* @param File $jarFile
1313
*/
14-
public function __construct(File $jarFile) {}
14+
public function __construct(File $jarFile = null) {}
15+
16+
/**
17+
* @param File $jar
18+
*/
19+
public function addJar(File $jar) {}
20+
21+
/**
22+
* @param File[] $jars
23+
*/
24+
public function addJars(array $jars) {}
1525
}

sdk/java/reflection/ReflectionTypes.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,77 +8,77 @@ class ReflectionTypes
88
/**
99
* @return ReflectionClass
1010
*/
11-
public function typeInt(): ReflectionClass {}
11+
public static function typeInt(): ReflectionClass {}
1212

1313
/**
1414
* @return ReflectionClass
1515
*/
16-
public function typeBool(): ReflectionClass {}
16+
public static function typeBool(): ReflectionClass {}
1717

1818
/**
1919
* @return ReflectionClass
2020
*/
21-
public function typeLong(): ReflectionClass {}
21+
public static function typeLong(): ReflectionClass {}
2222

2323
/**
2424
* @return ReflectionClass
2525
*/
26-
public function typeDouble(): ReflectionClass {}
26+
public static function typeDouble(): ReflectionClass {}
2727

2828
/**
2929
* @return ReflectionClass
3030
*/
31-
public function typeFloat(): ReflectionClass {}
31+
public static function typeFloat(): ReflectionClass {}
3232

3333
/**
3434
* @return ReflectionClass
3535
*/
36-
public function typeByte(): ReflectionClass {}
36+
public static function typeByte(): ReflectionClass {}
3737

3838
/**
3939
* @return ReflectionClass
4040
*/
41-
public function typeShort(): ReflectionClass {}
41+
public static function typeShort(): ReflectionClass {}
4242

4343
/**
4444
* @param $data
4545
* @return ReflectionObject
4646
*/
47-
public function toInt($data): ReflectionObject {}
47+
public static function toInt($data): ReflectionObject {}
4848

4949
/**
5050
* @param $data
5151
* @return ReflectionObject
5252
*/
53-
public function toLong($data): ReflectionObject {}
53+
public static function toLong($data): ReflectionObject {}
5454

5555
/**
5656
* @param $data
5757
* @return ReflectionObject
5858
*/
59-
public function toDouble($data): ReflectionObject {}
59+
public static function toDouble($data): ReflectionObject {}
6060

6161
/**
6262
* @param $data
6363
* @return ReflectionObject
6464
*/
65-
public function toFloat($data): ReflectionObject {}
65+
public static function toFloat($data): ReflectionObject {}
6666

6767
/**
6868
* @param $data
6969
* @return ReflectionObject
7070
*/
71-
public function toByte($data): ReflectionObject {}
71+
public static function toByte($data): ReflectionObject {}
7272

7373
/**
7474
* @param $data
7575
* @return ReflectionObject
7676
*/
77-
public function toShort($data): ReflectionObject {}
77+
public static function toShort($data): ReflectionObject {}
7878

7979
/**
8080
* Null for java
8181
* @return ReflectionObject
8282
*/
83-
public function getNull(): ReflectionObject {}
83+
public static function getNull(): ReflectionObject {}
8484
}

src-jvm/main/java/org/venity/javareflection/classes/JarClassLoader.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import php.runtime.reflection.ClassEntity;
88

99
import java.io.File;
10+
import java.lang.reflect.InvocationTargetException;
11+
import java.lang.reflect.Method;
1012
import java.net.MalformedURLException;
1113
import java.net.URL;
1214
import java.net.URLClassLoader;
@@ -37,6 +39,32 @@ public void __construct(File jar) throws MalformedURLException {
3739
);
3840
}
3941

42+
@Reflection.Signature
43+
public void __construct() throws MalformedURLException {
44+
classLoader = new URLClassLoader(
45+
new URL[0],
46+
this.getClass().getClassLoader()
47+
);
48+
}
49+
50+
@Reflection.Signature
51+
public void addJar(File jar)
52+
throws MalformedURLException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
53+
Method addURL = classLoader
54+
.getClass()
55+
.getDeclaredMethod("addURL", URL.class);
56+
addURL.setAccessible(true);
57+
addURL.invoke(classLoader, jar);
58+
}
59+
60+
@Reflection.Signature
61+
public void addJars(File[] jars)
62+
throws InvocationTargetException, MalformedURLException, IllegalAccessException, NoSuchMethodException {
63+
for (File jar: jars)
64+
addJar(jar);
65+
}
66+
67+
4068
public URLClassLoader getClassLoader() {
4169
return classLoader;
4270
}

0 commit comments

Comments
 (0)