jdynamicCompile {Java}R Documentation

Dynamically Compile a Java Class

Description

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.

Usage

jdynamicCompile(interface, newClass, generatorClass="ForeignReferenceClassGenerator", load=T)

Arguments

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.

Value

A reference to a Java ForeignReferenceClassGenerator.

Author(s)

Duncan Temple Lang

References

http://www.omegahat.org

See Also

Examples

 
  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()