public class Loader extends Object implements Closeable
SourceClassLoader
that can only be used
by the Engine
that created it.Constructor and Description |
---|
Loader(EngineId engineId,
long number,
boolean isAttached,
ClassReleaser classReleaser,
SourceClassLoader sourceClassLoader)
constructor, with given class releaser.
|
Loader(EngineId engineId,
long number,
boolean isAttached,
SourceClassLoader sourceClassLoader)
constructor, with default class releaser.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
release metadata for all classed ever loaded using this loader.
|
boolean |
equals(Object obj)
two loaders are equal if and only if their loader number and their engine ID are equal.
|
long |
getNumber()
gets the loader number.
|
SourceClassLoader |
getSourceClassLoader(EngineId engineId)
gets the source class loader (if the engine ID matches).
|
int |
hashCode()
implementation based on loader number and engine ID.
|
boolean |
isAttached()
gets whether the loader is attached to the engine or not.
|
void |
setSourceClassLoader(EngineId engineId,
SourceClassLoader sourceClassLoader)
sets the source class loader (if the engine ID matches).
|
String |
toString()
returns a string suitable for logging.
|
public Loader(EngineId engineId, long number, boolean isAttached, SourceClassLoader sourceClassLoader)
engineId
- the engine ID, used to authenticate the caller in some instance methodsnumber
- the loader numberisAttached
- whether the loader is attached to the engine or notsourceClassLoader
- the SourceClassLoader
to use for loading classesNullPointerException
- if any of the arguments is nullpublic Loader(EngineId engineId, long number, boolean isAttached, ClassReleaser classReleaser, SourceClassLoader sourceClassLoader)
engineId
- the engine ID, used to authenticate the caller in some instance methodsnumber
- the loader numberisAttached
- whether the loader is attached to the engine or notclassReleaser
- the class releasersourceClassLoader
- the SourceClassLoader
to use for loading classesNullPointerException
- if any of the arguments is nullpublic SourceClassLoader getSourceClassLoader(EngineId engineId)
engineId
- engine IDIllegalArgumentException
- if the engine ID does not matchpublic void setSourceClassLoader(EngineId engineId, SourceClassLoader sourceClassLoader)
engineId
- engine IDsourceClassLoader
- source class loaderIllegalArgumentException
- if the engine ID does not matchpublic long getNumber()
public boolean isAttached()
public boolean equals(Object obj)
public int hashCode()
public String toString()
public void close()
Allows to remove metadata associated by Groovy (or Java) with a class, which is often necessary to get on-the-fly garbage collection.
Generally call only when really done using this loader and all loaded classes; subsequently trying to use this loader or its classes results generally in undefined behavior.
close
in interface Closeable
close
in interface AutoCloseable