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
4
votes
1 answer

Configuration Reflections to scan test classes

Using Reflections library, I wrote a simple utility class that indexes all test methods together with their annotations. Reflections library helps me like that: Reflections reflections = new Reflections(new ConfigurationBuilder() …
dzieciou
  • 4,049
  • 8
  • 41
  • 85
4
votes
0 answers

ClassLoader.getResources returns an empty Set

I am developing an Android application that uses the Reflections library to search for some annotated classes. After some debugging hours spent trying to figure out why this library always returned empty sets to every query I did, I found out that…
Jon Rios
  • 63
  • 3
4
votes
1 answer

Is org.reflections.Reflections thread safe

To avoid having to create multiple instances of the org.reflections.Reflections class I was thinking of just creating one and reusing as needed. Anyone know if this class is thread safe? If its not thread safe I know I can use Java's ThreadLocal…
Jose Martinez
  • 11,452
  • 7
  • 53
  • 68
3
votes
1 answer

How to set default value to annotation variable as the class type of the variable annotated?

I have a custom annotation with a single variable. I use it to annotate attributes in a class and what i need is that the annotation default value for the variable, be the type of the attribute declared. Here the…
3
votes
0 answers

Using Reflections.getSubTypeOf() to get subtypes of Parameterized interface

I'm trying to extract all classes that implement an interface and put these in a Set. However, that interface is Parameterized and I'd like to communicate that it's all subclasses, regardless of their "parameter" I want, using a wildcard or…
3
votes
1 answer

Unable to find out where reflections-maven plugin comes from

There executes a particular Maven plugin and I struggle to find out where it comes from to either remove or replace it as its compile dependency link is broken. I am talking about org.reflections:reflections-maven:0.9.8 that depends on…
Nikolas Charalambidis
  • 40,893
  • 16
  • 117
  • 183
3
votes
1 answer

How do I dynamically cast Java object

I have the following method: public static Category getImpl(Class category) throws IllegalAccessException, InstantiationException { Reflections reflections = new Reflections("com.dpd.modules"); Set
Joe Doe
  • 41
  • 1
3
votes
1 answer

Java Reflections doesn't work with Android instant run

I'm writing some code that uses java reflections on it. I'm scanning my package for a certain class using this method: /** * Called to get list of classes included in the current project * * @param packageName the name of application package *…
mnagy
  • 1,085
  • 1
  • 17
  • 36
3
votes
1 answer

Build classpath from JAR inside a WAR file

I am trying to dynamically extract configuration from a given WAR file. My goal is to find all class that implement some interface (Parameter). The war file is not on the classpath, so I create a temporary classloader to inspect its classes. URL…
Olivier.Roger
  • 4,241
  • 5
  • 40
  • 68
3
votes
3 answers

`Class.newInstance()` throws java.lang.StackOverflowError with Reflections

Code: Reflections reflections = new Reflections("com.erby.tab.tabs"); for(Class t : reflections.getSubTypesOf(BaseTab.class)) { try { BaseTab tab = t.newInstance(); System.out.println(tab.toString()); }…
3legit4quit
  • 593
  • 1
  • 6
  • 10
3
votes
1 answer

How to scan for a particular annotation of java classes loaded at runtime as a bytecode?

If a java class loaded at runtime as a bytecode (e.g. via ASM library or other mechanism), is it on a classpath of java? I don't see it. How to scan all annotations of classes loaded this way, if it's not on the java classpath? I use google…
Ivan Voroshilin
  • 5,233
  • 3
  • 32
  • 61
3
votes
2 answers

Java Reflections library: find subclasses in package non recursively

Given the following snippet: Set> allClasses = new Reflections("mypackage").getSubTypesOf(MyClass.class); The library recursively search for all the classes extending MyClass in the given package and subpackages. I need…
Giovanni Botta
  • 9,626
  • 5
  • 51
  • 94
3
votes
1 answer

Reflections returning 0 even though class clearly exists

I have a problem with reflections. I have a class that extends another class called ClassModel: package net.gd.globalwars.commands; public class Country extends CommandModel { } And as you can see it is in package "net.gd.globalwars.commands" Now…
DeGambler
  • 31
  • 1
3
votes
1 answer

Is it possible to use reflections-maven to scan for classes inside jars in web-Inf/lib?

I need to create a list of subclasses for a particular interface during maven build process and then use that at runtime to load those classes. I have added reflections-maven (from google code reflections) in my webapp pom but during maven build,…
user2175901
  • 31
  • 1
  • 5
3
votes
1 answer

Retrieve a list of all packages in a project with Google reflections library?

I'm talking about the reflections lib. Is there any possibility to get a list of all packages which are included in the project where I let the code compile? I've tried it with the following code bracket but I don't want to insert a project…
MKorsch
  • 3,822
  • 3
  • 16
  • 21
1
2
3
10 11