| jdynamicCompile {Java} | R Documentation |
This uses the dynamic byte-code generator facility in Omegahat to
create a new Java class with a given name. By default, the new class
extends the RForeignReference class and implements a
specifiable collection of Java interfaces. Each method in these
interfaces is implemented by calling the corresponding
R function in the R reference object.
jdynamicCompile(interface, newClass, generatorClass="ForeignReferenceClassGenerator", load=T)
interface |
the (fully qualified) name of one or more
Java interface classes that the new class should implement.
The methods in these interfaces are implemented as calls to the
correspondingly named R function in the R object identified by
the RForeignReference's key.
|
newClass |
the name of the new class to be created. |
generatorClass |
the name of the
Java class to which is to be used as the dynamic compiler.
This is rarely specified, but allows one to use classes that
implement the code differently, e.g. by extending
ForeignReferenceClassGenerator. |
load |
logical value indicating whether the new class
should be loaded into the Omegahat list of available classes.
If this is FALSE, one usually writes the newly generated class
definition to a file. |
A reference to a Java ForeignReferenceClassGenerator.
Duncan Temple Lang
jdynamicCompile("java.awt.event.ActionListener", "RActionListener")
l <- .JNew("RActionListener", foreignReference(list(actionPerformed=function() {print("ok")} )))
button$add(l)
def <- jdynamicCompile("java.awt.event.ActionListener", "RActionListener", load=F)
def$write()