Questions tagged [reflections]

For questions about the Java Reflections library (org.reflections.reflections) by ronmamo, which performs Java runtime metadata analysis, in the spirit of Scannotations.

Official GitHub Repository: https://github.com/ronmamo/reflections

155 questions
35
votes
6 answers

Reflections - Java 8 - invalid constant type

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…
Lukasz
  • 517
  • 1
  • 8
  • 20
18
votes
3 answers

Reflections could not get class type

I am using a third party library called Reflections (not to be mistaken with Java reflection) to search another jar for Classes that extend Foo using the following code: Reflections reflections = new Reflections("com.example"); for(Class
Kezz
  • 1,680
  • 3
  • 19
  • 37
11
votes
1 answer

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

If I have Reflections reflections = new Reflections("my.package", classLoader, new SubTypesScanner(false)); then this finds my enum classes Set> enums = reflections.getSubTypesOf(Enum.class); but this doesn't Set>…
CupawnTae
  • 14,192
  • 3
  • 29
  • 60
11
votes
1 answer

Reflections from Maven Mojo

I'd like to use Google Reflections to scan classes from the compiled project from my Maven plugin. But plugins by default don't see the compiled classes of the project. From Maven 3 documentation I read: Plugins that need to load classes from the…
vertti
  • 7,539
  • 4
  • 51
  • 81
11
votes
2 answers

How do I get only instantiable classes with reflections

I am using the reflections package to get a set of classes that implement a certain interface. This set will be used as a list of possible command line options. My problem is that I only want to get instantiable classes, but right now get both…
halfdan
  • 33,545
  • 8
  • 78
  • 87
10
votes
5 answers

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

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,…
Sergio
  • 8,532
  • 11
  • 52
  • 94
7
votes
2 answers

Using Google Reflections to get a list of all classes -- but java.* seems to be missing

I am using the google Reflections package to build an index of all classes that are available for calling. The following code is supposed to return all classes that are loaded in the JVM: List classLoadersList = new…
pinecone
  • 81
  • 1
  • 1
  • 6
6
votes
2 answers

Google Reflections & Maven - not finding data in Maven but works in IDE

Problem Simple process request: find all extensions of List.class in the java.util package. Here is the source I am using: Reflections reflections = new Reflections("java.util"); Set> subtypes =…
el n00b
  • 1,957
  • 7
  • 37
  • 64
5
votes
1 answer

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

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 …
MKorsch
  • 3,822
  • 3
  • 16
  • 21
4
votes
1 answer

Guice and Reflections inside Jar File

I am experimenting with Google Guice (3.0) and Google Reflections (0.9.6). I have the following files: Operation.java: package com.company1.calculator; public interface Operation { public int apply(int a, int b); } Addition.java: package…
4
votes
0 answers

Moshi: When is Reflection needed?

Currently using Moshi with Retrofit but need to look back as I noticed I am not implementing it right and confused when to add kotlin-reflect in the dependencies. According to README The reflection adapter requires the following additional…
Bitwise DEVS
  • 2,858
  • 4
  • 24
  • 67
4
votes
1 answer

org.reflection.Reflections 0.10.2 fails when running as jar (e.g. in a docker container)

I used org.reflections (latest): new Reflections("my.package").getSubTypesOf(MyService.class); It works well running in IntelliJ and returns all implementations of MyService.class. But running in a docker container, it returns an empty…
t777
  • 3,099
  • 8
  • 35
  • 53
4
votes
1 answer

Why does invoke not work when using proguard obfuscation

I have a Fabric 1.17.1 (Java 16) mod for Minecraft that I am trying to obfuscate. Included with this mod is my event system that handles all the events for my mod. This event system uses the invoke method to call events in my event listener class at…
MisterCow1
  • 41
  • 4
4
votes
1 answer

Find anonymous classes by annotation

Is there a way to find anonymous classes by some annotation with some java reflection library like (Reflections)? I have this code: it use declare a inner class (extends Object) and annotated it with @DemoAnnotation public class DemoUsageService { …
Ralph
  • 118,862
  • 56
  • 287
  • 383
4
votes
1 answer

Find all implementations of an interface including lambdas

I have a unit test that searches through my project and finds all implementations of a particular interface. Then for each implementation that is an inner class, I assert that it does not capture the outer class. I use the Reflections library to do…
whistling_marmot
  • 3,561
  • 3
  • 25
  • 39
1
2 3
10 11