简体   繁体   中英

Find a java class that extends an abstract class

How would I find a class that extends another abstract class?

Currently I have this:

public PluginFinder(ClassLoader cl, File f) throws MalformedURLException, ClassNotFoundException {
    super(new URL[]{f.toURI().toURL()}, cl);
    Class<?> jarClass = Class.forName("com.ngxdev.demoplugin.main.MainClass", true, this);
    this.instance = new PluginParser(jarClass).instance;
}

It works, but it's static, I need to find that "com.ngxdev.demoplugin.main.MainClass" without specifying it because the location can be "com.example.ExampleClass" for all I know.

I tried to use: Reflections reflections = new Reflections("my.project.prefix"); but I don't really know how to use it.

Reflections can also scan files, for example:

Reflections reflections = new Reflections(new File("/plugin/example.jar"));

Using this libary

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM