https://github.com/j4ts/j4ts-reflection
https://github.com/j4ts/j4ts-reflection
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/j4ts/j4ts-reflection
- Owner: j4ts
- License: gpl-3.0
- Created: 2018-06-29T04:19:37.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-06-29T05:20:52.000Z (over 7 years ago)
- Last Synced: 2025-01-14T03:39:14.408Z (11 months ago)
- Language: Java
- Size: 19.5 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# j4ts-reflection
A JSweet implementation for https://github.com/ronmamo/reflections reflection lib
example:
```
import org.reflections.Reflections;
public class Test {
public static void main( String[] args ) throws InvocationTargetException, IllegalAccessException {
System.out.println("Write all class path under \"java.util\" package");
Reflections org = new Reflections("java.util");
for (Class> className : org.getSubTypesOf(java.lang.Cloneable.class)) {
System.out.println(className.getName());
}
ArrayList strings = new ArrayList<>(Arrays.asList("1", "2", "3"));
System.out.println();
System.out.println("Get all method of ArrayList class: ");
Method savedMethod = null;
for (Method method : ReflectionUtils.getAllMethods(ArrayList.class)) {
System.out.println("ArrayList." + method.getName());
if (Objects.equals(method.getName(), "size")) {
Object size = method.invoke(strings);
System.out.println("Array size is: " + size);
if (savedMethod != null)
break;
} else if (Objects.equals(method.getName(), "subList")) {
savedMethod = method;
}
}
System.out.println("subList() parameter count: " + savedMethod.getParameterCount());
}
}
```
add maven dependency to your repo, and you can use it java such as javascript side
```
org.reflections
reflections
0.9.11
```