"

2013 FRC Java API

"

com.sun.squawk
Interface TranslatorInterface


public interface TranslatorInterface

The TranslatorInterface is the interface by which new classes can be created and loaded into the runtime system.

The runtime system (per isolate) can have at most one open connection with a translator (i.e. an object that implements this interface). The correct usage of a translator is described by the following state transistion machine:


             +----------- open() ----------+     +---------+
             |                             |     |         |
             |                             V     V         |
        +--------+                       +---------+       |
   ---> | CLOSED |                       |  OPEN   |  load() / convert()
        +--------+                       +---------+       |
             ^                             |     |         |
             |                             |     |         |
             +---------- close() ----------+     +---------+

 

That is, a translator can be opened and then have any number of load(com.sun.squawk.Klass) and convert(com.sun.squawk.Klass) operations performed on it before being closed.


Method Summary
 void close(int type)
          Closes the connection with the translator.
 void convert(Klass klass)
          Ensures that all the methods (if any) in a given class have been verified and converted to Squawk bytecodes.
 String getLastClassName()
          For error recovery, you can get the name of the last class that was processed.
 byte[] getResourceData(String name)
          Get the bytes for the resource named name.
 boolean isOption(String arg)
          If arg represents a valid translator argument, then return true.
 boolean isValidClassName(String name)
          Determines if a given name is a valid class name according the JVM specification.
 void load(Klass klass)
          Ensures that a given class has had its definition initialized, loading it from a class file if necessary.
 void open(Suite suite, String classPath)
          Opens a connection with the translator to load & create classes in the context of a given suite.
 void printOptionProperties(PrintStream out, boolean asParameters)
          Print the usage information for the translator'soption properties to the outputstream.
 void printTraceFlags(PrintStream out)
          Print the usage information for the translator's trace flags to the outputstream.
 boolean processOption(String arg)
          If arg represents a valid translator argument, then process it by parsing into property name and value, and set the property value.
 

Method Detail

open

void open(Suite suite,
          String classPath)
          throws NoClassDefFoundError
Opens a connection with the translator to load & create classes in the context of a given suite.

Parameters:
suite - the suite in which classes created during the connection with this translator will be installed.
Throws:
NoClassDefFoundError

isValidClassName

boolean isValidClassName(String name)
Determines if a given name is a valid class name according the JVM specification.

Parameters:
name - the class name to test
Returns:
true is name is a valid class name

getLastClassName

String getLastClassName()
For error recovery, you can get the name of the last class that was processed. If an exception occurs during the convert or close cycle, you can use this to get the class that was being processed.


load

void load(Klass klass)
          throws NoClassDefFoundError
Ensures that a given class has had its definition initialized, loading it from a class file if necessary. This does not include verifying the bytecodes for the methods (if any) and converting them to Squawk bytecodes.

Parameters:
klass - the class whose definition must be initialized
Throws:
java.lang.LinkageError - if there were any problems while loading and linking the class
NoClassDefFoundError

convert

void convert(Klass klass)
             throws NoClassDefFoundError
Ensures that all the methods (if any) in a given class have been verified and converted to Squawk bytecodes.

Parameters:
klass - the class whose methods are to be verified and converted
Throws:
java.lang.LinkageError - if there were any problems while converting the class
NoClassDefFoundError

close

void close(int type)
           throws NoClassDefFoundError
Closes the connection with the translator. This computes the closure of the classes in the current suite and ensures they are all loaded and converted.

Parameters:
suiteType - indicates if the the translator can assume that package-private classes and member will not be accessible outside of the the unit of translation (the suite). The value pased should be one of the constants specified in java.lang.Suite
Throws:
NoClassDefFoundError

getResourceData

byte[] getResourceData(String name)
Get the bytes for the resource named name. The first resource found by combining each classPath entry of the currently active suite will be returned. Meaning that name is relative to the root/default package.

Parameters:
name - of the resource to fetch
Returns:
byte[] null if there is no resource name to be found.

printTraceFlags

void printTraceFlags(PrintStream out)
Print the usage information for the translator's trace flags to the outputstream.

Parameters:
out - the stream to print on.

printOptionProperties

void printOptionProperties(PrintStream out,
                           boolean asParameters)
Print the usage information for the translator'soption properties to the outputstream. Can print as either generic properties or as command line parameters: -Dtranslator.foo=value -foo:value

Parameters:
out - the stream to print on.
asParameters - if true, print prop as "-foo:value", instead of "-Dtranslator.foo=value"

processOption

boolean processOption(String arg)
If arg represents a valid translator argument, then process it by parsing into property name and value, and set the property value. and return true. Otherwise return false.

Parameters:
arg -

isOption

boolean isOption(String arg)
If arg represents a valid translator argument, then return true. Otherwise return false.

Parameters:
arg -

"

2013 FRC Java API

"

"
For updated information see the Java FRC site
"