gov.llnl.babel.backend.jdk

Class Java


public class Java
extends java.lang.Object

Class Java contains common Java language binding routines shared by the Java backend code generators. This class simply collects many common Java binding routines into one place.

Method Summary

static void
declareIORVariable(LanguageWriterForC writer, Argument arg, String prefix, Context context)
Declare and initialize a variable with an IOR type.
static void
declareIORVariable(LanguageWriterForC writer, Type type, String variable, Context context)
Declare and initialize a variable with an IOR type.
static void
declareJavaVariable(LanguageWriterForC writer, Type type, String variable)
Declare and initialize a variable with a Java type.
static void
declareJavaVariable(LanguageWriterForJava writer, Type type, String variable)
Declare and initialize a variable with a Java type.
static void
declareServerInOutVariable(LanguageWriterForC writer, Type type, String variable)
This is a quick modification of declareJavaVariable (above).
static Set
generateStubIncludes(LanguageWriterForC writer, Extendable ext)
Generates include directives for all the Babel clases used in this fortran stub or skel
static String
getClientJNIFile(SymbolID id)
Generate the JNI source filename for the client using the specified symbol identifier.
static String
getClientJavaFile(SymbolID id)
Generate the Java filename for the client using the specified symbol identifier.
static String
getDefaultJNIReturnValue(Method method)
Generate a string that will print a default return value (JNI) for given method
static String
getDefaultReturnValue(Method method)
Generate a string that will print a default return value (Java) for given method
static String
getDescriptor(String type)
Convert a type string to a JNI descriptor.
static String
getEnsureArray(Type arrayType)
Returns a string for the name of the ensure function to call for this array type.
static String
getFullJavaSymbolName(SymbolID id)
Return the fully qualified Java name that corresponds to a sidl symbol type.
static String
getHeaderFile(SymbolID id)
Generate the JNI source filename for the client using the specified symbol identifier.
static String
getHolderName()
Return the name of the inner holder class used for inout and out method arguments.
static String
getInterfaceWrapper()
Return the name of the inner wrapper class for interfaces.
static String
getJNIEnsureName(String name)
Return the name of the given argument temporary variable for use in calls to ensure.
static String
getJNIEnsureName(Argument arg)
Return the name of the given argument temporary variable for use in calls to ensure.
static String
getJNIFormalArgument(Argument arg)
Return a string for the JNI argument corresponding to the specified sidl argument.
static String
getJNIFunction(Method method)
Return the name of the JNI function corresponding to the specified sidl method.
static String
getJNINativeType(String type)
Return a string for the JNI native type corresponding to the specified Java type.
static String
getJNIReturnType(Type type)
Return a string for the JNI native type corresponding to the specified Java return type.
static String
getJavaArgument(Argument arg)
Return a string for the Java argument corresponding to the specified sidl argument.
static String
getJavaBaseArray()
Return the string name of the Java base array that all automatically generated sidl arrays must extend.
static String
getJavaBaseClass()
Return the string name of the Java base class that all automatically generated sidl classes must extend.
static String
getJavaBaseInterface()
Return the string name of the Java base interface that all automatically generated sidl interfaces must extend.
static String
getJavaFormalArgument(Argument arg)
Return a string for the Java argument corresponding to the specified sidl argument with a formal name.
static String
getJavaImplSourceFile(SymbolID id)
Generate the Java filename for the server using the specified symbol identifier.
static String
getJavaReturnType(Type type)
Return a string for the Java return type corresponding to the specified sidl type.
static String
getJavaServerArgument(Argument arg)
static String
getJavaServerClassName(SymbolID id)
Return the name of the java server class.
static String
getJavaServerMethodName(Method meth)
Return the name of Java Server Methods.
static String
getJavaServerSignature(Method method)
Convert the method argument list and return type into a Java signature string according to JNI conventions.
static String
getJavaSignature(Method method)
Convert the method argument list and return type into a Java signature string according to JNI conventions.
static String
getJavaSymbolName(SymbolID id)
Return the shortened Java name of a sidl symbol type.
static String
getRegisterFunction(SymbolID id)
Return the name of the JNI registration function.
static String
getServerJNIFile(SymbolID id)
Generate the JNI source filename for the server using the specified symbol identifier.
static String
getSuperJNIFunction(Method method)
Return the name of the JNI function corresponding to the specified sidl method.
static int
localJavaVars(Method m)
Return an upper bound on the number of Java local object references required in the Java skeleton for the indicated method.
static void
postprocessJNIArgument(LanguageWriterForC writer, Argument arg, String prefix, Context context)
Method postprocessJNIArgument converts between IOR arguments and Java arguments.
static void
postprocessJNIReturn(LanguageWriterForC writer, Type type, String ior_result, String java_result)
Method postprocessJNIReturn converts between IOR return arguments and Java return arguments.
static void
postprocessServerJNIArgument(LanguageWriterForC writer, Argument arg, String prefix, Context context)
Method postprocessServerJNIArgument converts Java arguments to IOR arguments.
static void
postprocessServerJNIReturn(LanguageWriterForC writer, Type type, String java_result, String ior_result, Context context)
Method postprocessServerJNIReturn converts from java return arguments to IOR return arguments.
static void
preprocessJNIArgument(LanguageWriterForC writer, Argument arg, String prefix, Context context)
Method preprocessJNIArgument converts between Java arguments and IOR arguments.
static void
preprocessServerJNIArgument(LanguageWriterForC writer, Argument arg, String prefix, Context context)
Method preprocessServerJNIArgument converts IOR arguments to Java arguments.

Method Details

declareIORVariable

public static void declareIORVariable(LanguageWriterForC writer,
                                      Argument arg,
                                      String prefix,
                                      Context context)
            throws CodeGenerationException
Declare and initialize a variable with an IOR type. This method converts the sidl type into an IOR type string and substitutes the type string in the initialization phrase from the initialization hash table. (In JNI)

declareIORVariable

public static void declareIORVariable(LanguageWriterForC writer,
                                      Type type,
                                      String variable,
                                      Context context)
            throws CodeGenerationException
Declare and initialize a variable with an IOR type. This method converts the sidl type into an IOR type string and substitutes the type string in the initialization phrase from the initialization hash table.

declareJavaVariable

public static void declareJavaVariable(LanguageWriterForC writer,
                                       Type type,
                                       String variable)
Declare and initialize a variable with a Java type. This method converts the sidl type into a Java type string and substitutes the type string in the initialization phrase from the initialization hash table. (IN JNI)

declareJavaVariable

public static void declareJavaVariable(LanguageWriterForJava writer,
                                       Type type,
                                       String variable)
Declare and initialize a variable with a Java type.

declareServerInOutVariable

public static void declareServerInOutVariable(LanguageWriterForC writer,
                                              Type type,
                                              String variable)
This is a quick modification of declareJavaVariable (above). Basically, in the Server side JNI all INOUT/OUT variables are Passed in holders, which are all jobjects. Hence, no need for the usual hash map approach used above.

generateStubIncludes

public static Set generateStubIncludes(LanguageWriterForC writer,
                                       Extendable ext)
            throws CodeGenerationException
Generates include directives for all the Babel clases used in this fortran stub or skel
Parameters:
writer - Language writer for C
ext - Extendible (Class or Interface) to generate dependencies

getClientJNIFile

public static String getClientJNIFile(SymbolID id)
Generate the JNI source filename for the client using the specified symbol identifier. Simply append the suffix "_jniStub.c" to the symbol name.

getClientJavaFile

public static String getClientJavaFile(SymbolID id)
Generate the Java filename for the client using the specified symbol identifier. Simply append the suffix ".java" to the symbol name.

getDefaultJNIReturnValue

public static String getDefaultJNIReturnValue(Method method)
Generate a string that will print a default return value (JNI) for given method
Parameters:
method - the method that needs a default return string

getDefaultReturnValue

public static String getDefaultReturnValue(Method method)
Generate a string that will print a default return value (Java) for given method
Parameters:
method - the method that needs a default return string

getDescriptor

public static String getDescriptor(String type)
Convert a type string to a JNI descriptor. Convert the basic types according to the hash table map. If the type is not one of the basic types, then convert the symbol type according to JNI conventions.

getEnsureArray

public static String getEnsureArray(Type arrayType)
Returns a string for the name of the ensure function to call for this array type. Used in jniSkel files when an array is defined by the sidl file to be either column or row major order.

getFullJavaSymbolName

public static String getFullJavaSymbolName(SymbolID id)
Return the fully qualified Java name that corresponds to a sidl symbol type. This name is the same as the sidl name, including all package information.

getHeaderFile

public static String getHeaderFile(SymbolID id)
Generate the JNI source filename for the client using the specified symbol identifier. Simply append the suffix "_jniStub.c" to the symbol name.

getHolderName

public static String getHolderName()
Return the name of the inner holder class used for inout and out method arguments.

getInterfaceWrapper

public static String getInterfaceWrapper()
Return the name of the inner wrapper class for interfaces.

getJNIEnsureName

public static String getJNIEnsureName(String name)
Return the name of the given argument temporary variable for use in calls to ensure.

getJNIEnsureName

public static String getJNIEnsureName(Argument arg)
Return the name of the given argument temporary variable for use in calls to ensure.

getJNIFormalArgument

public static String getJNIFormalArgument(Argument arg)
Return a string for the JNI argument corresponding to the specified sidl argument. This method converts the sidl argument into a Java argument and then converts the Java argument into its JNI native representation. The formal argument name is prepended with an "_arg_" to prevent name collisions with other argument types.

getJNIFunction

public static String getJNIFunction(Method method)
Return the name of the JNI function corresponding to the specified sidl method. These names are the static local names used in the JNI stub file.

getJNINativeType

public static String getJNINativeType(String type)
Return a string for the JNI native type corresponding to the specified Java type. Everything that is not a primitive type like integer or boolean is converted into an JNI object.

getJNIReturnType

public static String getJNIReturnType(Type type)
Return a string for the JNI native type corresponding to the specified Java return type. This method calls getJavaReturnType and converts the resulting strings into its JNI representation.

getJavaArgument

public static String getJavaArgument(Argument arg)
Return a string for the Java argument corresponding to the specified sidl argument. The mapping between sidl argument and Java argument is fairly simple for most primitive types and object types. For arguments that are IN, the type is the same as the return type. For INOUT and OUT arguments, the type is the special holder class. This routine removes the "$" for inner classes and replaces it with a ".".

getJavaBaseArray

public static String getJavaBaseArray()
Return the string name of the Java base array that all automatically generated sidl arrays must extend.

getJavaBaseClass

public static String getJavaBaseClass()
Return the string name of the Java base class that all automatically generated sidl classes must extend.

getJavaBaseInterface

public static String getJavaBaseInterface()
Return the string name of the Java base interface that all automatically generated sidl interfaces must extend.

getJavaFormalArgument

public static String getJavaFormalArgument(Argument arg)
Return a string for the Java argument corresponding to the specified sidl argument with a formal name.

getJavaImplSourceFile

public static String getJavaImplSourceFile(SymbolID id)
Generate the Java filename for the server using the specified symbol identifier. Simply append the suffix ".java" to the symbol name.

getJavaReturnType

public static String getJavaReturnType(Type type)
Return a string for the Java return type corresponding to the specified sidl type. The return string from this routine is a valid Java type. The mapping between sidl type and Java type is fairly simple for most primitive types and object types.

getJavaServerArgument

public static String getJavaServerArgument(Argument arg)

getJavaServerClassName

public static String getJavaServerClassName(SymbolID id)
Return the name of the java server class. This name is the same as the client side class name + "_Impl"

getJavaServerMethodName

public static String getJavaServerMethodName(Method meth)
Return the name of Java Server Methods. These are the same as the names of the methods on the client side + "_Impl"

getJavaServerSignature

public static String getJavaServerSignature(Method method)
Convert the method argument list and return type into a Java signature string according to JNI conventions. See any JNI reference for the type mapping.

getJavaSignature

public static String getJavaSignature(Method method)
Convert the method argument list and return type into a Java signature string according to JNI conventions. See any JNI reference for the type mapping.

getJavaSymbolName

public static String getJavaSymbolName(SymbolID id)
Return the shortened Java name of a sidl symbol type. The Java name is the same as the sidl name without the namespace information. This name is the one used when declaring the Java type. The fully qualified name is returned by getFullJavaSymbolName.

getRegisterFunction

public static String getRegisterFunction(SymbolID id)
Return the name of the JNI registration function. The registration function is the one invoked whenever a new Java class or interface is loaded.

getServerJNIFile

public static String getServerJNIFile(SymbolID id)
Generate the JNI source filename for the server using the specified symbol identifier. Simply append the suffix "_jniSkel.c" to the symbol name.

getSuperJNIFunction

public static String getSuperJNIFunction(Method method)
Return the name of the JNI function corresponding to the specified sidl method. These names are the static local names used in the JNI stub file.

localJavaVars

public static int localJavaVars(Method m)
Return an upper bound on the number of Java local object references required in the Java skeleton for the indicated method.

postprocessJNIArgument

public static void postprocessJNIArgument(LanguageWriterForC writer,
                                          Argument arg,
                                          String prefix,
                                          Context context)
            throws CodeGenerationException
Method postprocessJNIArgument converts between IOR arguments and Java arguments. Conversion routines are output to the language writer. This routine retrieves the conversion string from the hash table and then substitutes the appropriate variable names in the conversion string.

postprocessJNIReturn

public static void postprocessJNIReturn(LanguageWriterForC writer,
                                        Type type,
                                        String ior_result,
                                        String java_result)
Method postprocessJNIReturn converts between IOR return arguments and Java return arguments. Conversion routines are output to the language writer. This routine retrieves the conversion string from the hash table and then substitutes the appropriate variable names in the conversion string.

postprocessServerJNIArgument

public static void postprocessServerJNIArgument(LanguageWriterForC writer,
                                                Argument arg,
                                                String prefix,
                                                Context context)
            throws CodeGenerationException
Method postprocessServerJNIArgument converts Java arguments to IOR arguments. Conversion routines are output to the language writer. This routine retrieves the conversion string from the hash table and then substitutes the appropriate variable names in the conversion string.

postprocessServerJNIReturn

public static void postprocessServerJNIReturn(LanguageWriterForC writer,
                                              Type type,
                                              String java_result,
                                              String ior_result,
                                              Context context)
            throws CodeGenerationException
Method postprocessServerJNIReturn converts from java return arguments to IOR return arguments. Conversion routines are output to the language writer. This routine retrieves the conversion string from the hash table and then substitutes the appropriate variable names in the conversion string.

preprocessJNIArgument

public static void preprocessJNIArgument(LanguageWriterForC writer,
                                         Argument arg,
                                         String prefix,
                                         Context context)
            throws CodeGenerationException
Method preprocessJNIArgument converts between Java arguments and IOR arguments. Conversion routines are output to the language writer. This routine retrieves the conversion string from the appropriate hash table and then substitutes the appropriate variable names in the conversion string.

preprocessServerJNIArgument

public static void preprocessServerJNIArgument(LanguageWriterForC writer,
                                               Argument arg,
                                               String prefix,
                                               Context context)
            throws CodeGenerationException
Method preprocessServerJNIArgument converts IOR arguments to Java arguments. Conversion routines are output to the language writer. This routine retrieves the conversion string from the appropriate hash table and then substitutes the appropriate variable names in the conversion string.