jeudi 30 novembre 2017

How to load a class file dynamically and pass it as a parameter

Static Implementation

import com.this.class.ImportedClass;
getElementsAnnotatedWith(ImportedClass.class)

the above method call works when I use import, but when I want to load the same class dynamically

ImportedClass Class = Class.forName("com.this.class.ImportedClass");
getElementsAnnotatedWith(importedClass.class)

When I pass the .class file it wont take the parameter.





Aucun commentaire:

Enregistrer un commentaire