APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.tools.javac.launcher

pack-priv final Class MemoryContext

extends Object
Class Inheritance
Imports
com.sun.source.util.TaskEvent, .TaskListener, com.sun.tools.javac.api.JavacTool, com.sun.tools.javac.code.Lint.LintCategory, com.sun.tools.javac.file.JavacFileManager, com.sun.tools.javac.resources.LauncherProperties.Errors, com.sun.tools.javac.util.Context, .Context.Factory, .Log, javax.tools.JavaFileManager, .JavaFileObject, .StandardLocation, java.io.File, .IOException, .PrintWriter, java.lang.module.ModuleDescriptor, .ModuleFinder, .ModuleReference, java.nio.ByteBuffer, java.nio.file.Files, .Path, java.util.ArrayList, .Arrays, .HashMap, .List, .Map, .Set

An object to encapsulate the set of in-memory classes, such that they can be written by a file manager and subsequently used by a class loader.

This is NOT part of any supported API. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.

Field Summary

Modifier and TypeField and Description
private final JavacTool
private final ProgramDescriptor
private final Map<String, byte[]>
private final JavaFileManager
private final RelevantJavacOptions
private final PrintWriter
private final JavacFileManager

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv byte[]

Returns:

the byte code of the compiled class or null if no source file was found for the given name
compileJavaFileByName
(String
the name of the class to be compiled.
name
)

Determines a source file from the given class name and compiles it.

pack-priv void
compileProgram()

Compiles a source file, placing the class files in a map in memory.

private static ModuleFinder
private void
enableNativeAccess(ModuleLayer.Controller controller, boolean shouldWarn)

Grants native access to modules selected using the --enable-native-access command line option.

pack-priv Set<String>
pack-priv ProgramDescriptor
pack-priv String
pack-priv ClassLoader

Returns:

class loader object able to find and load the desired class
newClassLoaderFor
(ClassLoader
the class loader to be used as the parent loader
parent
,
String
the fully-qualified name of the application class to load
mainClassName
)

Create a new class load for the main entry-point class.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

compilerback to summary
private final JavacTool compiler
descriptorback to summary
private final ProgramDescriptor descriptor
inMemoryClassesback to summary
private final Map<String, byte[]> inMemoryClasses
memoryFileManagerback to summary
private final JavaFileManager memoryFileManager
optionsback to summary
private final RelevantJavacOptions options
outback to summary
private final PrintWriter out
standardFileManagerback to summary
private final JavacFileManager standardFileManager

Constructor Detail

MemoryContextback to summary
pack-priv MemoryContext(PrintWriter out, ProgramDescriptor descriptor, RelevantJavacOptions options) throws Fault

Method Detail

compileJavaFileByNameback to summary
pack-priv byte[] compileJavaFileByName(String name)

Determines a source file from the given class name and compiles it. Any messages generated during compilation will be written to the stream provided when this object was created.

This method is passed a reference to an instance of MemoryClassLoader, that uses it to compile a source file on demand.

Parameters
name:String

the name of the class to be compiled.

Returns:byte[]

the byte code of the compiled class or null if no source file was found for the given name

compileProgramback to summary
pack-priv void compileProgram() throws Fault

Compiles a source file, placing the class files in a map in memory. Any messages generated during compilation will be written to the stream provided when this object was created.

Exceptions
Fault:
if any compilation errors occur, or if no class was found
createModuleFinderFromModulePathback to summary
private static ModuleFinder createModuleFinderFromModulePath()
enableNativeAccessback to summary
private void enableNativeAccess(ModuleLayer.Controller controller, boolean shouldWarn)

Grants native access to modules selected using the --enable-native-access command line option.

Annotations
@SuppressWarnings:restricted
getNamesOfCompiledClassesback to summary
pack-priv Set<String> getNamesOfCompiledClasses()
getProgramDescriptorback to summary
pack-priv ProgramDescriptor getProgramDescriptor()
getSourceFileAsStringback to summary
pack-priv String getSourceFileAsString()
newClassLoaderForback to summary
pack-priv ClassLoader newClassLoaderFor(ClassLoader parent, String mainClassName) throws Fault

Create a new class load for the main entry-point class.

Parameters
parent:ClassLoader

the class loader to be used as the parent loader

mainClassName:String

the fully-qualified name of the application class to load

Returns:ClassLoader

class loader object able to find and load the desired class

Exceptions
Fault:
if a modular application class is in the unnamed package