Class AgiClassLoader
java.lang.Object
java.lang.ClassLoader
java.security.SecureClassLoader
java.net.URLClassLoader
uno.anahata.asi.toolkit.java.AgiClassLoader
- All Implemented Interfaces:
Closeable, AutoCloseable
A session-scoped
URLClassLoader that maintains identity and holds
in-memory compiled classes (AgiCompiledClass) across turns for an AGI
session.
Serving as the parent classloader for ephemeral script loaders (such as
Java.AnahataClassLoader), AgiClassLoader ensures that classes
compiled via Java.compile(String, String, String, String[], Path)
are defined exactly once in the session metaspace. This completely eliminates
ClassCastException when instantiating compiled types in one turn and
casting them in subsequent turns (e.g. via sessionMap).
- Author:
- anahata
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAgiClassLoader(List<URL> urls, Java javaToolkit, ClassLoader parent) Constructs a newAgiClassLoader. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddExtraClassPath(String extraClassPath) Adds extra classpath directory or JAR entries dynamically to this loader's URLs.private byte[]Resolves bytecode for a class or any of its inner/nested classes fromAgiCompiledClasses.Returns a set of all URLs currently registered on this classloader.booleanisClassLoaded(String name) Checks whether a class has already been loaded and defined by this classloader.protected Class<?> Implements session-scoped classloading: Returns previously loaded classes (guaranteeing single-instance identity). Delegates parent-first infrastructure classes to the host loader. Defines in-memory compiled bytecode from activeAgiCompiledClasses inJava. Searches child-first URLs for libraries supplied in extra classpath. Falls back to the host parent classloader. Queries toolkit fallback bytes and extra sibling classloaders (e.g.Methods inherited from class URLClassLoader
addURL, close, definePackage, findClass, findResource, findResources, getPermissions, getResourceAsStream, getURLs, newInstance, newInstanceMethods inherited from class SecureClassLoader
defineClass, defineClassMethods inherited from class ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getResource, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
Field Details
-
javaToolkit
-
-
Constructor Details
-
AgiClassLoader
Constructs a newAgiClassLoader.- Parameters:
urls- initial classpath URLs (from extraClassPath entries across compiled classes).javaToolkit- the owning Java toolkit instance.parent- the host parent classloader.
-
-
Method Details
-
addExtraClassPath
Adds extra classpath directory or JAR entries dynamically to this loader's URLs.- Parameters:
extraClassPath- path-separator delimited classpath string.
-
getRegisteredUrls
-
isClassLoaded
Checks whether a class has already been loaded and defined by this classloader.- Parameters:
name- the binary name of the class.- Returns:
trueif the class is already defined in this loader.
-
loadClass
Implements session-scoped classloading:- Returns previously loaded classes (guaranteeing single-instance identity).
- Delegates parent-first infrastructure classes to the host loader.
- Defines in-memory compiled bytecode from active
AgiCompiledClasses inJava. - Searches child-first URLs for libraries supplied in extra classpath.
- Falls back to the host parent classloader.
- Queries toolkit fallback bytes and extra sibling classloaders (e.g. JavaFX).
- Overrides:
loadClassin classClassLoader- Parameters:
name- the binary name of the class.resolve- if true, resolves the class.- Returns:
- the resulting Class object.
- Throws:
ClassNotFoundException- if the class cannot be found.
-
findAgiCompiledBytecode
Resolves bytecode for a class or any of its inner/nested classes fromAgiCompiledClasses.- Parameters:
name- the binary class name.- Returns:
- the bytecode byte array, or null if not found.
-

