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

Commit

Permalink
Fix SDK, update JarClassLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
MWGuy committed May 17, 2019
1 parent f4deb23 commit 587c9dd
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/.gradle/**
/.idea/**
/build/**
/bundle/**
/gradle/
/jars/**
/out/**
Expand Down
4 changes: 2 additions & 2 deletions package.php.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: java-reflection-ext
version: 1.2.0
version: 1.2.1
description: Java Reflection API

plugins:
Expand All @@ -20,7 +20,7 @@ doc:
ru: Русский

develnext-bundle:
version: 1.2.0
version: 1.2.1
name: "Java Reflection API"
author: "Venity Studio"
icon: "develnext/bundle/reflection/icon32.png"
Expand Down
12 changes: 11 additions & 1 deletion sdk/java/reflection/JarClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,15 @@ class JarClassLoader
/**
* @param File $jarFile
*/
public function __construct(File $jarFile) {}
public function __construct(File $jarFile = null) {}

/**
* @param File $jar
*/
public function addJar(File $jar) {}

/**
* @param File[] $jars
*/
public function addJars(array $jars) {}
}
28 changes: 14 additions & 14 deletions sdk/java/reflection/ReflectionTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,77 +8,77 @@ class ReflectionTypes
/**
* @return ReflectionClass
*/
public function typeInt(): ReflectionClass {}
public static function typeInt(): ReflectionClass {}

/**
* @return ReflectionClass
*/
public function typeBool(): ReflectionClass {}
public static function typeBool(): ReflectionClass {}

/**
* @return ReflectionClass
*/
public function typeLong(): ReflectionClass {}
public static function typeLong(): ReflectionClass {}

/**
* @return ReflectionClass
*/
public function typeDouble(): ReflectionClass {}
public static function typeDouble(): ReflectionClass {}

/**
* @return ReflectionClass
*/
public function typeFloat(): ReflectionClass {}
public static function typeFloat(): ReflectionClass {}

/**
* @return ReflectionClass
*/
public function typeByte(): ReflectionClass {}
public static function typeByte(): ReflectionClass {}

/**
* @return ReflectionClass
*/
public function typeShort(): ReflectionClass {}
public static function typeShort(): ReflectionClass {}

/**
* @param $data
* @return ReflectionObject
*/
public function toInt($data): ReflectionObject {}
public static function toInt($data): ReflectionObject {}

/**
* @param $data
* @return ReflectionObject
*/
public function toLong($data): ReflectionObject {}
public static function toLong($data): ReflectionObject {}

/**
* @param $data
* @return ReflectionObject
*/
public function toDouble($data): ReflectionObject {}
public static function toDouble($data): ReflectionObject {}

/**
* @param $data
* @return ReflectionObject
*/
public function toFloat($data): ReflectionObject {}
public static function toFloat($data): ReflectionObject {}

/**
* @param $data
* @return ReflectionObject
*/
public function toByte($data): ReflectionObject {}
public static function toByte($data): ReflectionObject {}

/**
* @param $data
* @return ReflectionObject
*/
public function toShort($data): ReflectionObject {}
public static function toShort($data): ReflectionObject {}

/**
* Null for java
* @return ReflectionObject
*/
public function getNull(): ReflectionObject {}
public static function getNull(): ReflectionObject {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import php.runtime.reflection.ClassEntity;

import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
Expand Down Expand Up @@ -37,6 +39,32 @@ public void __construct(File jar) throws MalformedURLException {
);
}

@Reflection.Signature
public void __construct() throws MalformedURLException {
classLoader = new URLClassLoader(
new URL[0],
this.getClass().getClassLoader()
);
}

@Reflection.Signature
public void addJar(File jar)
throws MalformedURLException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
Method addURL = classLoader
.getClass()
.getDeclaredMethod("addURL", URL.class);
addURL.setAccessible(true);
addURL.invoke(classLoader, jar);
}

@Reflection.Signature
public void addJars(File[] jars)
throws InvocationTargetException, MalformedURLException, IllegalAccessException, NoSuchMethodException {
for (File jar: jars)
addJar(jar);
}


public URLClassLoader getClassLoader() {
return classLoader;
}
Expand Down

0 comments on commit 587c9dd

Please sign in to comment.