Class JarFileBuilder
java.lang.Object
simula.compiler.JarFileBuilder
Utilities to build and manipulate jarFiles.
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe intermediate classFileMap.private JarOutputStream
The target JarOutputStream.(package private) String
Main entry name.private File
The output .jar fileprivate ProgramModule
The ProgramModule.private static final boolean
Debug utility. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
Add directory or a file to a JarOutputStream, or Put it into the intermediate classFileMap.void
Add the jarFiles in the includeQueue.void
Add temp .class files to jarOutputStream.static void
addToIncludeQueue
(JarFile jarFile) Add the jarFile to the includeQueue.close()
Close the JarFileBuilder by writing the .jar file.void
expandJarFile
(JarFile jarFile) Expand .jar file entries into the classFileMap.static File
findJarFile
(String identifier, String externalIdentifier) Find the .jar file containing an external class or procedure.static void
listJarFile
(File file) Debug utility: List .jar filestatic void
Load the jarFiles in the includeQueue using simulaClassLoader.private static void
loadJarEntries
(JarFile jarFile, String packetName, SimulaClassLoader loader) Load jarFile entries.static void
Load the Runtime System using simulaClassLoader.void
open
(ProgramModule program) Open the JarFileBuilder.private void
printClassFileMap
(String title) Debug utility: printClassFileMap.void
putMapEntry
(String entryName, byte[] bytes) Put a JarEntry to the intermediate classFileMap.void
writeJarEntry
(String entryName, byte[] bytes) Write a JarEntry to the JarOutputStream.
-
Field Details
-
programModule
The ProgramModule. -
outputJarFile
The output .jar file -
mainEntry
String mainEntryMain entry name. -
classFileMap
-
jarOutputStream
The target JarOutputStream. -
TESTING
private static final boolean TESTINGDebug utility.- See Also:
-
-
Constructor Details
-
JarFileBuilder
public JarFileBuilder()Construct a new JarFileBuilder.
-
-
Method Details
-
open
Open the JarFileBuilder.- Parameters:
program
- the relevant ProgramModule- Throws:
IOException
- if something went wrong
-
putMapEntry
Put a JarEntry to the intermediate classFileMap.- Parameters:
entryName
- the entry namebytes
- the bytes, may be null
-
writeJarEntry
Write a JarEntry to the JarOutputStream.- Parameters:
entryName
- the entry namebytes
- the bytes, may be null- Throws:
IOException
- if something went wrong
-
close
Close the JarFileBuilder by writing the .jar file.- Returns:
- the outputJarFile
- Throws:
IOException
- if something went wrong
-
addTempClassFiles
Add temp .class files to jarOutputStream.- Throws:
IOException
- if something went wrong
-
add
Add directory or a file to a JarOutputStream, or Put it into the intermediate classFileMap.- Parameters:
doPut
- true:put it, otherwise add itsource
- source file or directorypathSize
- the path size- Throws:
IOException
- if something went wrong
-
expandJarFile
Expand .jar file entries into the classFileMap.- Parameters:
jarFile
- the .jar file to read- Throws:
IOException
- if something went wrong
-
printClassFileMap
Debug utility: printClassFileMap.- Parameters:
title
- the title String.
-
findJarFile
-
addToIncludeQueue
Add the jarFile to the includeQueue.- Parameters:
jarFile
- the jarFile to be added- Throws:
IOException
- if something went wrong
-
addIncludeQueue
Add the jarFiles in the includeQueue.- Throws:
IOException
- if something went wrong
-
loadIncludeQueue
Load the jarFiles in the includeQueue using simulaClassLoader.- Throws:
IOException
- if something went wrong
-
loadRuntimeSystem
Load the Runtime System using simulaClassLoader.- Throws:
IOException
- if something went wrong
-
loadJarEntries
private static void loadJarEntries(JarFile jarFile, String packetName, SimulaClassLoader loader) throws IOException Load jarFile entries.- Parameters:
jarFile
- the jarFile.packetName
- the packet name.loader
- the SimulaClassLoader to use.- Throws:
IOException
- if something went wrong.
-
listJarFile
Debug utility: List .jar file- Parameters:
file
- the .jar file
-