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
3
votes
4 answers

Reflections returning Set with null elements

I'm using Reflections to find classes that have an specific annotation. My project structure is the following One WAR package: WEB-INF/classes/...packages.../ClassAnnoted1.class One JAR package that is included by the war that has a class that…
Hoffmann
  • 14,369
  • 16
  • 76
  • 91
3
votes
1 answer

reflections.getTypesAnnotatedWith(...) finds class, but getAnnotations().length is 0

When using the Java reflections library I can correctly find classes decorated with an annotation: Set> annotated = reflections.getTypesAnnotatedWith(CommandName.class); but when I try to see how many annotations are on each class I always…
Dejas
  • 3,511
  • 4
  • 24
  • 36
2
votes
3 answers

Play framework - Is it possible to force Play to generate the .class files, even in PROD mode?

In my Play application, I use Reflections ( http://code.google.com/p/reflections/ ) to get some fields annotated with a particular annotation. Reflections requires to have access to the .class files to create its index. In DEV mode it works great…
electrotype
  • 8,342
  • 11
  • 59
  • 96
2
votes
1 answer

Java MethodHandlers.lookup().findStatic throws NoSuchMethodException

So i have been doing some things that involve Java MethodHandlers. And the reflection api has been around for a long time so there is a lot of documentation about it. MethodHandlers on the other hand hasn't been around as long so there is a lot…
Toerktumlare
  • 12,548
  • 3
  • 35
  • 54
2
votes
0 answers

Reflections 0.10.1 and 0.10.2 broken for ClassLoaders?

I have some existing code which uses Reflections like this: ClassLoader myClassLoader = MyClassUtils.getMyClassLoader(); // above call returns a URLClassLoader Reflections reflections = new Reflections(myClassLoader); This code was…
Vicky
  • 16,679
  • 54
  • 139
  • 232
2
votes
1 answer

Why Class.getDeclaredFields() are sorted alphabetically unexpectedly?

It is said on the docs of Class.getDeclaredFields() that The elements in the returned array are not sorted and are not in any particular order. But I found that the results are actually sorted in perfect alphabetical order instead of the…
xjunz
  • 31
  • 4
2
votes
1 answer

Class inspection via reflection API. Use of custom annotations

I have done my research before asking but no luck. I have a StartUp Singleton bean. In this bean I have an @Inject @Any Instance. I loop all the implementations and try to check if the class is annotated with a custom annotation. All the…
geminal
  • 23
  • 6
2
votes
1 answer

Reflections not finding classes on docker container/jar

I have silly problem when running my application inside docker container or using jar file. When application is started locally migration library which is using reflections: new Reflections("package").getTypesAnnotatedWith(SomeClass.class) Is able…
Tomasz
  • 21
  • 3
2
votes
1 answer

@Cacheable in Spring does not understand dynamically assigned values

I need to dynamically assign values of cacheResolver for @Cacheable in runtime because cacheResolver has the same value for @Cacheable in every method. Hence, I use Spring AOP to dynamically assign the value but then Spring does not recognize the…
futurexv
  • 41
  • 2
2
votes
1 answer

Java - Using Reflections To Scan Classes From All Packages

I am developing an application that is supposed to scan all classes and interfaces in a given classpath and match an implementing class for DI creation. I have an annotation: @Target(TYPE) @Retention(RUNTIME) public @interface RequiresBinding…
Guy Yafe
  • 991
  • 1
  • 8
  • 26
2
votes
1 answer

Using reflection to verify all instances of a trait have a unique field

Consider the following code. Animals should have a unique ID. I want to dynamically verify (in a test) that all concrete subtypes of Animal have unique IDs. I want my test to fail if, for example, Cat and Fish both try to pass in uniqueId =…
PolyglotPiglet
  • 279
  • 2
  • 12
2
votes
1 answer

AWS Lambda and Java Reflections (Guava)

I am trying to run Guava reflections in my AWS Lambda function but it seems to not work in production.. The Code i am trying to run is supposed to create a Map with class name and class. Code: val converterClassMap by lazy { val cl…
Oreex0
  • 324
  • 3
  • 15
2
votes
0 answers

Why getTypesAnnotatedWith returns classes without annotation

I'm trying to use class annotations in Java, and I have the strange behaviour where getTypesAnnotatedWith returns a class on which getAnnotation returns null. Is there some reason getTypesAnnotatedWith returns classes without annotation? For…
Federico
  • 1,925
  • 14
  • 19
2
votes
1 answer

If i use reflections to get the classes extending a common class will the list contain all the recursively inherited classes too?

Suppose I have class A{} class B extends A{} class C extends A{} class D extends C{} class E extends B{} and I have the following code Reflections reflections = new Reflections(); Set> classes =…
Kaushik Vijayakumar
  • 755
  • 3
  • 10
  • 19
2
votes
1 answer

Reflections Library to Find All Classes within a Package

I am using the below code to find all of the Classes within a given package name. This works fine when the code is placed directly into my project. However, calling the service from a Commons Jar I put together isn't returning the data from my…
wheeleruniverse
  • 1,511
  • 2
  • 20
  • 37
1 2
3
10 11