gov.llnl.babel.backend.jdk
Class Java

java.lang.Object
  extended by gov.llnl.babel.backend.jdk.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.


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

Constructor Detail

Java

public Java()
Method Detail

getClientJavaFile

public static java.lang.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.


getClientJNIFile

public static java.lang.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.


getHeaderFile

public static java.lang.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.


getJavaImplSourceFile

public static java.lang.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.


getServerJNIFile

public static java.lang.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.


getJavaSymbolName

public static java.lang.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.


getFullJavaSymbolName

public static java.lang.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.


getJavaServerClassName

public static java.lang.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 java.lang.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"


getRegisterFunction

public static java.lang.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.


getJavaBaseClass

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


getJavaBaseInterface

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


getJavaBaseArray

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


getInterfaceWrapper

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


getHolderName

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


getEnsureArray

public static java.lang.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.


getJavaReturnType

public static java.lang.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.


getDescriptor

public static java.lang.String getDescriptor(java.lang.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.


getJavaArgument

public static java.lang.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 ".".


getJavaServerArgument

public static java.lang.String getJavaServerArgument(Argument arg)

getJavaFormalArgument

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


getJavaSignature

public static java.lang.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.


getJavaServerSignature

public static java.lang.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.


getDefaultReturnValue

public static java.lang.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

getDefaultJNIReturnValue

public static java.lang.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

getJNIFunction

public static java.lang.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.


getSuperJNIFunction

public static java.lang.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.


getJNINativeType

public static java.lang.String getJNINativeType(java.lang.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 java.lang.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.


declareIORVariable

public static void declareIORVariable(LanguageWriterForC writer,
                                      Type type,
                                      java.lang.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.

Throws:
CodeGenerationException

declareIORVariable

public static void declareIORVariable(LanguageWriterForC writer,
                                      Argument arg,
                                      java.lang.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)

Throws:
CodeGenerationException

declareJavaVariable

public static void declareJavaVariable(LanguageWriterForC writer,
                                       Type type,
                                       java.lang.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,
                                       java.lang.String variable)
Declare and initialize a variable with a Java type.


declareServerInOutVariable

public static void declareServerInOutVariable(LanguageWriterForC writer,
                                              Type type,
                                              java.lang.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.


getJNIFormalArgument

public static java.lang.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.


getJNIEnsureName

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


getJNIEnsureName

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


preprocessJNIArgument

public static void preprocessJNIArgument(LanguageWriterForC writer,
                                         Argument arg,
                                         java.lang.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.

Throws:
CodeGenerationException

postprocessJNIArgument

public static void postprocessJNIArgument(LanguageWriterForC writer,
                                          Argument arg,
                                          java.lang.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.

Throws:
CodeGenerationException

postprocessJNIReturn

public static void postprocessJNIReturn(LanguageWriterForC writer,
                                        Type type,
                                        java.lang.String ior_result,
                                        java.lang.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.


preprocessServerJNIArgument

public static void preprocessServerJNIArgument(LanguageWriterForC writer,
                                               Argument arg,
                                               java.lang.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.

Throws:
CodeGenerationException

postprocessServerJNIArgument

public static void postprocessServerJNIArgument(LanguageWriterForC writer,
                                                Argument arg,
                                                java.lang.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.

Throws:
CodeGenerationException

postprocessServerJNIReturn

public static void postprocessServerJNIReturn(LanguageWriterForC writer,
                                              Type type,
                                              java.lang.String java_result,
                                              java.lang.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.

Throws:
CodeGenerationException

generateStubIncludes

public static java.util.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
Throws:
CodeGenerationException

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.