Commit 1f42ec56 authored by Vít Kabele's avatar Vít Kabele

DiSL is now created via constructor method. Session local ClassLoader introduced.

parent 7b30c8c0
Pipeline #3307 passed with stages
in 3 minutes and 55 seconds
......@@ -47,7 +47,7 @@ class IsolatedSnippetParser extends SnippetParser {
Class<?> getGuard (final Type guardType) throws Reflection.MissingClassException {
if(guardType == null) return null;
final ByteArrayClassLoader bacl = new ByteArrayClassLoader ();
final DiSLClassLoader bacl = new DiSLClassLoader ();
final String guardName = guardType.getClassName ();
// If the class definition is already in cache, return the cached value
......
......@@ -48,6 +48,14 @@ public final class DiSL {
private final DislClasses __dislClasses;
/**
* Class loader related to one DiSL instance i.e. one instrumentation session.
*
* Note that all classes loaded within the instance will keep the reference to this particular
* class loader instance and vice versa.
*/
private final DiSLClassLoader __classLoader = new DiSLClassLoader ();
/**
* Initializes a DiSL instance by loading transformers, exclusion lists, and
......@@ -145,17 +153,21 @@ public final class DiSL {
/**
* Initialize new instance of the {@link DiSL} class, using received instrumentaion jars.
* @param properties
* @param instrumentations
* @return
*
* It's no longer an static init method, because we want to use the ClassLoader instance during
* initialization.
*
* @param properties System properties.
* @param instrumentations Received instrumentation jars (maybe wrap to something like SessionContext)
* @return New instance of the {@link DiSL} class.
* @throws DiSLException
*/
public static DiSL init(
public DiSL(
final Properties properties,
final List<byte[]> instrumentations
) throws DiSLException
{
final Set <CodeOption> codeOptions = __codeOptionsFrom (
__codeOptions = __codeOptionsFrom (
Objects.requireNonNull (properties)
);
......@@ -183,11 +195,9 @@ public final class DiSL {
.flatMap (Collection::stream)
.collect ( Collectors.toMap (Map.Entry::getKey, Map.Entry::getValue) );
final DislClasses dislClasses = new IsolatedDislClasses (codeOptions, classNodes, allClasses);
final Transformers transformers = new IsolatedTransformers ( transformerList );
final Set<Scope> excludedScopes = ExclusionSetFactory.prepare ( instrumentationJars );
return new DiSL (codeOptions, transformers, excludedScopes, dislClasses);
__dislClasses = new IsolatedDislClasses (__codeOptions, classNodes, allClasses);
__transformers = new IsolatedTransformers ( transformerList );
__excludedScopes = ExclusionSetFactory.prepare ( instrumentationJars );
}
......
......@@ -9,14 +9,14 @@
package ch.usi.dag.disl;
/**
* Load classes from byte array.
* This class is responsible for loading classes related to one {@link DiSL} instance.
*/
class ByteArrayClassLoader extends ClassLoader {
class DiSLClassLoader extends ClassLoader {
/**
* Create new instance of the {@link ByteArrayClassLoader} class.
* Create new instance of the {@link DiSLClassLoader} class.
*/
ByteArrayClassLoader(){
DiSLClassLoader (){
super();
}
......
......@@ -19,7 +19,7 @@ import java.util.stream.Collectors;
*/
class IsolatedTransformers extends Transformers {
private final ByteArrayClassLoader classLoader = new ByteArrayClassLoader ();
private final DiSLClassLoader classLoader = new DiSLClassLoader ();
/**
* Create new instance of {@link IsolatedTransformers} class.
......
......@@ -192,7 +192,7 @@ final class RequestProcessor {
System.setProperty ("disl.disablebypass", "true");
}
final DiSL disl = DiSL.init (System.getProperties (), Instrumentations);
final DiSL disl = new DiSL(System.getProperties (), Instrumentations);
return new RequestProcessor (disl);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment