Class PythonProcessingSession
java.lang.Object
io.micronaut.python.processing.PythonProcessingSession
- All Implemented Interfaces:
AutoCloseable
Owns the initialized GraalPy processing context across multiple serialized compilations.
A session is not thread safe. Callers must serialize compilations that share it.
- Since:
- 5.2.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclassLoader(List<File> classpath, Supplier<ClassLoader> factory) Obtains the annotation processor class loader associated with this processing session.voidclose()booleanReports whether GraalPy has been initialized.parser(ClassLoader classLoader, boolean incremental) Obtains the parser for a compilation, initializing GraalPy on first use.
-
Constructor Details
-
PythonProcessingSession
public PythonProcessingSession()
-
-
Method Details
-
classLoader
Obtains the annotation processor class loader associated with this processing session.The GraalPy context retains its host class loader. Reusing the context while creating a different processor class loader for every compilation makes annotation types loaded by Python incompatible with the visitors loaded for the current compilation. The class loader must therefore have the same lifetime as the context.
- Parameters:
classpath- The effective annotation processor classpathfactory- Creates the class loader when the classpath changes- Returns:
- The session class loader
-
parser
Obtains the parser for a compilation, initializing GraalPy on first use.- Parameters:
classLoader- The annotation processor class loaderincremental- Whether the compilation is incremental- Returns:
- The session parser
-
initialized
public boolean initialized()Reports whether GraalPy has been initialized.- Returns:
- Whether GraalPy has been initialized for this session
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-