google-reflections

Why doesn't reflections.getSubTypesOf(Object.class) find enums?

﹥>﹥吖頭↗ 提交于 2019-12-22 04:08:12
问题 If I have Reflections reflections = new Reflections("my.package", classLoader, new SubTypesScanner(false)); then this finds my enum classes Set<Class<? extends Enum>> enums = reflections.getSubTypesOf(Enum.class); but this doesn't Set<Class<?>> classes = reflections.getSubTypesOf(Object.class); Is there a reason for this? Reproducible example: package cupawntae; import org.reflections.Reflections; import org.reflections.scanners.SubTypesScanner; public class Reflector { public static void

Using Google-Reflection within Groovy causes exception whereas equivalent Java code works

只愿长相守 提交于 2019-12-11 08:49:54
问题 I'm trying to use some code from another answer on SO, and while the code run in Java, from Groovy it causes an exception. The code in question is: Reflections reflections = new Reflections(new ConfigurationBuilder() .setScanners( new SubTypesScanner(false /* don't exclude Object.class */), new ResourcesScanner() ) .setUrls(ClasspathHelper.forClassLoader(classLoadersList.toArray(new ClassLoader[0]))) .filterInputsBy( new FilterBuilder() .include( prefix( "net.initech" ) ) .exclude( prefix(

Reflections could not get class type

寵の児 提交于 2019-12-10 01:52:25
问题 So I am using the Java Reflections API to search another jar for Classes that extend Foo using the following code: Reflections reflections = new Reflections("com.example"); for(Class<? extends Foo> e : reflections.getSubTypesOf(Foo.class)) { doSomething() } When I do this Reflections throws the following error: org.reflections.ReflectionsException: could not get type for name com.example.ExtendsFoo Does anyone know how to fix this cause I'm stumped? Thanks in advance! 回答1: The problem may be

How to scan JAR's, which are loaded at runtime, with Google reflections library?

不想你离开。 提交于 2019-12-07 09:41:16
问题 Is there a solution to configure the reflection library so that it scans also JAR's which are added at runtime with URLClassLoader? For now, reflections just scans the URLs in the ClassLoader. This is the configuration which I am using now: Reflections reflections = new Reflections(new ConfigurationBuilder().setUrls(ClasspathHelper.forClassLoader())); I couldn't find any hints in the doc of the reflections library. EDIT: This is how I load the jar File: File f = new File("C:/Users/mkorsch

How to scan JAR's, which are loaded at runtime, with Google reflections library?

若如初见. 提交于 2019-12-05 16:45:28
Is there a solution to configure the reflection library so that it scans also JAR's which are added at runtime with URLClassLoader? For now, reflections just scans the URLs in the ClassLoader. This is the configuration which I am using now: Reflections reflections = new Reflections(new ConfigurationBuilder().setUrls(ClasspathHelper.forClassLoader())); I couldn't find any hints in the doc of the reflections library. EDIT: This is how I load the jar File: File f = new File("C:/Users/mkorsch/Desktop/test-reflections.jar"); URLClassLoader urlCl = new URLClassLoader(new URL[] {f.toURI().toURL()}

Unit test using the Reflections google library fails only when executed by Maven

纵然是瞬间 提交于 2019-11-30 08:34:42
问题 I am using the Google Reflections library for querying certain resources in the classpath. Those resources are located in the same location than the classes in my project. I wrote some unit tests that succeed when executed as a unit test in Eclipse, but when I try to execute them with Maven (with a maven install for example), they are not working as expected. After some debugging, apparently the problem is that when executed with Maven, the Reflections library cannot find the classpath url

Reflections - Java 8 - invalid constant type

白昼怎懂夜的黑 提交于 2019-11-27 13:11:10
I have a problem with Reflections library. I am trying to load dynamically all classes which implement specific interface. Everything works fine (all classes are loaded) as long as I do not use lambda expression in these classes (java 8). I tried upgrade lib version but effect was the same (java.io.IOException: invalid constant type: 18). Dependency and build in pom.xml <dependency> <groupId>org.reflections</groupId> <artifactId>reflections</artifactId> <version>0.9.10</version> <exclusions> <exclusion> <groupId>javassist</groupId> <artifactId>javassist</artifactId> </exclusion> </exclusions>

Reflections - Java 8 - invalid constant type

让人想犯罪 __ 提交于 2019-11-26 13:57:53
问题 I have a problem with Reflections library. I am trying to load dynamically all classes which implement specific interface. Everything works fine (all classes are loaded) as long as I do not use lambda expression in these classes (java 8). I tried upgrade lib version but effect was the same (java.io.IOException: invalid constant type: 18). Dependency and build in pom.xml <dependency> <groupId>org.reflections</groupId> <artifactId>reflections</artifactId> <version>0.9.10</version> <exclusions>