mercredi 21 février 2018

java reflection: get list of classes in a package at compile to use at runtime

I have console application that do some reflection operations on list of classes (log field names, annotations, etc.).

Right now I create list of classnames by hand as strings in a file. I would love to be able to add project/package/configure path to build folder/etc. to my console project, build it and somehow use classnames got during compile in runtime.

Simple usecase: compile my app with a package, run on production site to check if every data class has proper database configuration.

Found this solution: https://dzone.com/articles/get-all-classes-within-package but it works during runtime and I prefer to get those names during compile time... is it possible? Or am I getting this wrong?





Aucun commentaire:

Enregistrer un commentaire