Package eu.bandm.tools.lljava.live
Class ClosureFactory<C>
java.lang.Object
eu.bandm.tools.lljava.live.ClosureFactory<C>
- Type Parameters:
C
- the class of the closure prototype
A factory to create new objects from a closure prototype.
A closure is a class that has been augmented with synthetic fields and
constructor arguments to retain values of enclosing this
references
(for non-static nested classes) and captured variables (for local and
anonymous classes).
This factory implementation support both the creation of new objects of the same class and objects of dynamically constructed subclasses, with the same values for the synthetic fields as present in a given prototype object.
The class of the prototype is assume to have an accessible constructor that has exactly the synthetic parameters, and no others. This is automatically the case if there is no constructor in Java source code, and a default is defined implicitly.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
isEmpty()
Returns a new object of the same class as the prototype.newInstance
(C closure)
-
Constructor Details
-
ClosureFactory
Creates a new factory.- Parameters:
closurePrototype
- the prototype- Throws:
NoSuchMethodException
IllegalAccessException
-
-
Method Details
-
isEmpty
public boolean isEmpty() -
newInstance
public C newInstance() throws InstantiationException, IllegalAccessException, InvocationTargetExceptionReturns a new object of the same class as the prototype.- Returns:
- a new object of the same class as the prototype that is constructed with the same values for all synthetic fields
- Throws:
InstantiationException
IllegalAccessException
InvocationTargetException
-
newInstance
public C newInstance(C closure) throws InstantiationException, IllegalAccessException, InvocationTargetException -
getSuperEnvironment
-