Class RuntimeClassScanner1
java.lang.Object
org.daiitech.naftah.utils.reflect.RuntimeClassScanner1
Deprecated, for removal: This API element is subject to removal in a future version.
This class is deprecated and marked for removal.
Utility class for scanning runtime classes from the classpath and Java home directories.
This class provides methods to scan class files inside directories and JAR/JMOD archives, and to load them reflectively using different class loaders.
- Author:
- Chakib Daii
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDeprecated, for removal: This API element is subject to removal in a future version.The file extension for compiled Java class files.static final StringDeprecated, for removal: This API element is subject to removal in a future version.Regular expression pattern to match the class file extension.class.static final ClassLoader[]Deprecated, for removal: This API element is subject to removal in a future version.Array of common base package names to be used when scanning classes.static final StringDeprecated, for removal: This API element is subject to removal in a future version.The Java class path obtained from the system propertyjava.class.path.static final StringDeprecated, for removal: This API element is subject to removal in a future version.System property key for the Java class path.Deprecated, for removal: This API element is subject to removal in a future version.A set of class file base names to ignore during scanning.Deprecated, for removal: This API element is subject to removal in a future version.A set of full class file names to ignore during scanning.static final StringDeprecated, for removal: This API element is subject to removal in a future version.The file extension for Java archive files (JAR).static final StringDeprecated, for removal: This API element is subject to removal in a future version.The Java home directory obtained from the system propertyjava.home.static final StringDeprecated, for removal: This API element is subject to removal in a future version.System property key for the Java installation directory (JAVA_HOME).static final StringDeprecated, for removal: This API element is subject to removal in a future version.The file extension for Java module files (JMOD).static final String[]Deprecated, for removal: This API element is subject to removal in a future version.Array of filesystem paths (directories or archives) used as scan roots. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateDeprecated, for removal: This API element is subject to removal in a future version.Private constructor to prevent instantiation. -
Method Summary
Modifier and TypeMethodDescriptionstatic Map<String,ScannedClass> findClassesInDirectory(File root, File dir) Deprecated, for removal: This API element is subject to removal in a future version.Recursively scans for classes inside a directory.static Map<String,ScannedClass> findClassesInJar(File jarFile) Deprecated, for removal: This API element is subject to removal in a future version.Scans for classes inside a JAR or JMOD file.static FilejarEntryToTempFile(JarFile outerJar, JarEntry innerJarEntry) Deprecated, for removal: This API element is subject to removal in a future version.Extracts a nested JAR entry from a JAR file and writes it to a temporary file.static Class<?>loadClass(String className, URLClassLoader classLoader) Deprecated, for removal: This API element is subject to removal in a future version.Attempts to load a class with the given name using a set of class loaders.static Map<String,ScannedClass> Deprecated, for removal: This API element is subject to removal in a future version.Scans for classes in the default classpath and java home paths.static Map<String,ScannedClass> scanCLasses(String[] paths) Deprecated, for removal: This API element is subject to removal in a future version.Scans for classes in the given paths.
-
Field Details
-
CLASS_PATH_PROPERTY
Deprecated, for removal: This API element is subject to removal in a future version.System property key for the Java class path.- See Also:
-
CLASS_PATH
Deprecated, for removal: This API element is subject to removal in a future version.The Java class path obtained from the system propertyjava.class.path. This is a list of paths where classes and resources are searched for. -
JAVA_HOME_PROPERTY
Deprecated, for removal: This API element is subject to removal in a future version.System property key for the Java installation directory (JAVA_HOME).- See Also:
-
JAVA_HOME
Deprecated, for removal: This API element is subject to removal in a future version.The Java home directory obtained from the system propertyjava.home. Typically points to the directory where the JRE or JDK is installed. -
PATHS
Deprecated, for removal: This API element is subject to removal in a future version.Array of filesystem paths (directories or archives) used as scan roots. Initialized statically by combining the classpath and Java home paths, filtering out ignored dependencies if available. -
JAR_EXTENSION
Deprecated, for removal: This API element is subject to removal in a future version.The file extension for Java archive files (JAR).- See Also:
-
JMOD_EXTENSION
Deprecated, for removal: This API element is subject to removal in a future version.The file extension for Java module files (JMOD).- See Also:
-
CLASS_EXTENSION
Deprecated, for removal: This API element is subject to removal in a future version.The file extension for compiled Java class files.- See Also:
-
CLASS_EXTENSION_REGEX
Deprecated, for removal: This API element is subject to removal in a future version.Regular expression pattern to match the class file extension.class. Used to identify class files in file names.- See Also:
-
IGNORE
Deprecated, for removal: This API element is subject to removal in a future version.A set of class file base names to ignore during scanning. Typically these include special files like module-info and package-info. -
IGNORE_CLASS
Deprecated, for removal: This API element is subject to removal in a future version.A set of full class file names to ignore during scanning. This is theIGNOREset with the.classextension appended. -
CLASS_LOADERS
Deprecated, for removal: This API element is subject to removal in a future version.Array of common base package names to be used when scanning classes. Includes standard Java and popular top-level package prefixes.
-
-
Constructor Details
-
RuntimeClassScanner1
private RuntimeClassScanner1()Deprecated, for removal: This API element is subject to removal in a future version.Private constructor to prevent instantiation. Always throws aNaftahBugErrorwhen called.
-
-
Method Details
-
scanCLasses
Deprecated, for removal: This API element is subject to removal in a future version.Scans for classes in the default classpath and java home paths.- Returns:
- a map of fully qualified class names to their corresponding class loaders (may be null if default)
-
scanCLasses
Deprecated, for removal: This API element is subject to removal in a future version.Scans for classes in the given paths.- Parameters:
paths- an array of file system paths (directories or JAR files) to scan for classes- Returns:
- a map of fully qualified class names to their corresponding class loaders (may be null if default)
-
loadClass
Deprecated, for removal: This API element is subject to removal in a future version.Attempts to load a class with the given name using a set of class loaders.The method tries the predefined class loaders, optionally including the provided
URLClassLoader, to load the class without initializing it.- Parameters:
className- the fully qualified name of the class to loadclassLoader- an optionalURLClassLoaderto use for loading the class; may be null- Returns:
- the
Classobject if found and loaded successfully;nullif the class could not be loaded by any of the class loaders
-
findClassesInDirectory
Deprecated, for removal: This API element is subject to removal in a future version.Recursively scans for classes inside a directory.- Parameters:
root- root directory where scanning starteddir- current directory or file to scan- Returns:
- a map of fully qualified class names to their corresponding class loaders (null here)
-
findClassesInJar
Deprecated, for removal: This API element is subject to removal in a future version.Scans for classes inside a JAR or JMOD file.- Parameters:
jarFile- the JAR or JMOD file to scan- Returns:
- a map of fully qualified class names to their associated class loaders (null or URLClassLoader for nested jars)
-
jarEntryToTempFile
Deprecated, for removal: This API element is subject to removal in a future version.Extracts a nested JAR entry from a JAR file and writes it to a temporary file. The temporary file is deleted on JVM exit.- Parameters:
outerJar- the outer JAR file containing the nested JAR entryinnerJarEntry- the nested JAR entry inside the outer JAR- Returns:
- a temporary File representing the extracted nested JAR
- Throws:
IOException- if an I/O error occurs during extraction
-