3

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 I am using a new reflection object to find all classes that extend CommandModel and print the count, but the count is 0.

Reflections commands = new Reflections("net.gd.globalwars.commands");
System.err.println(commands.getSubTypesOf(CommandModel.class).size());

Thanks in advance!

DeGambler
  • 31
  • 1

1 Answers1

0

Using this maven dependency, the code works as it should and returns 1:

<dependency>
     <groupId>org.reflections</groupId>
     <artifactId>reflections</artifactId>
     <version>0.9.9-RC1</version>
</dependency>

Assuming: Country, CommandModel, and the calling class are in the same package, though I doubt this makes a difference

Jonathan Schneider
  • 26,852
  • 13
  • 75
  • 99