Let\'s say a java codebase has a package called \"com.example\".
At runtime, we can get this Package by calling
Package p = Package.getPackage( \"com
I'm afraid that your assumptions are not valid. Classloaders do package book-keeping as they load classes.
You can pass a wildcard to ClassLoader.getResources
and force it to pick up the classes in a package, which will in turn do the work.
You can make your own ClassLoader that calls definePackage
, but that won't help you with the usual vanilla classloaders in use.