-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Description
From within a Feature
running at image build time, it is currently not possible to get the class path or module path of the application using proper API.
We should provide methods like this (exact list and signatures to be discussed):
List<Path> getClassOrModulePath()
: The value of the-cp
or-modulepath
options passed tonative-image
boolean isModulePath()
: Whether the list is a class or module pathClassLoader getApplicationClassLoader()
: Returns the class loader used for the classpath / modulepath.
The methods can either be in FeatureAccess
, or in a separate class as static
helper methods. I prefer FeatureAccess
because the callers should be at a defined point in a Feature
and not, e.g., at a random class initializer.
Why provide class and module path in the same method, and a boolean flag if distinction is necessary? Code that scans the path for, e.g., resources or classes likely works the same for class and module path, making it easier to support both.
Alternatives:
- Subclass and annotation information is currently available via non-API, but that is planned to be removed in Remove scanning and loading of all classes at beginning of image build #2599
- The application class loader can also be queried by calling
getClassLoader()
on any known application class (like aFeature
implementation class).
sbrannen