Sun SPOT API
Green Release  


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.

Author:
Doug Simon

Method Summary
 void close()
          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.
 byte[] getResourceData(String name)
          Get the bytes for the resource named name.
 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.
 

Method Detail

open

void open(Suite suite,
          String classPath)
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.

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

load

void load(Klass klass)
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

convert

void convert(Klass klass)
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

close

void close()
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.


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.

Sun SPOT API
Green Release  


Copyright © 2006 Sun Microsystems, Inc. All Rights Reserved.