Package org.elasticsearch.test.jar
Class JarUtils
java.lang.Object
org.elasticsearch.test.jar.JarUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic PathCreates a jar file with the given manifest and list of (empty) jar file entry names.static voidcreateJarWithEntries(Path jarfile, Map<String, byte[]> entries) Creates a jar file with the given entries.static voidcreateJarWithEntriesUTF(Path jarfile, Map<String, String> entries) Creates a jar file with the given entries.Creates a class loader for the given jar file.static ModuleLayer.ControllerloadModule(Path path, ClassLoader loader, String name)
-
Method Details
-
createJar
public static Path createJar(Path dir, String name, Manifest manifest, String... files) throws IOException Creates a jar file with the given manifest and list of (empty) jar file entry names. The jar file entries will be added to the jar, but will all be empty (no contents).- Parameters:
dir- the directory in which the jar will be createdname- the name of the jar filemanifest- the manifest, may be nullfiles- the list of jar entry names, to be added to the jar- Returns:
- the path of the jar file
- Throws:
IOException- if an I/O error occurs
-
createJarWithEntries
public static void createJarWithEntries(Path jarfile, Map<String, byte[]> entries) throws IOExceptionCreates a jar file with the given entries.- Parameters:
jarfile- the jar file pathentries- map of entries to add; jar entry name to byte contents- Throws:
IOException- if an I/O error occurs
-
createJarWithEntriesUTF
public static void createJarWithEntriesUTF(Path jarfile, Map<String, String> entries) throws IOExceptionCreates a jar file with the given entries. Entry values are converted to bytes using UTF-8.- Parameters:
jarfile- the jar file pathentries- map of entries to add; jar entry name to String contents- Throws:
IOException- if an I/O error occurs
-
loadJar
Creates a class loader for the given jar file.- Parameters:
path- Path to the jar file to load- Returns:
- A URLClassLoader that will load classes from the jar. It should be closed when no longer needed.
-
loadModule
-