Mapping native and Java data types

Java and Genero have different built-in data types. Unlike Genero, Java is a strongly typed language: You cannot call a method with a String if it was defined to get an int parameter. To call a Java method, Genero native typed values need to be converted to/from Java types such as byte, int, short, char or data objects such as java.lang.String. If possible, the fglrun runtime system will do this conversion implicitly.

The fglcomp compiler will raise the error -6606, if the native data type does not match the Java (primitive) type, using Widening Primitive Conversions. For example, passing a Genero DECIMAL when a Java double is expected will fail, but passing a SMALLFLOAT (equivalent to float) when a Java double is expected will compile and run.

Genero has advanced native data types such as DECIMAL, which do not have an equivalent primitive type or class in Java. For such Genero types, you need to use a specific Java class provided in the FGLDIR/lib/fgl.jar package, like com.fourjs.fgl.lang.FglDecimal. You can then manipulate the Genero specific value in the Java code.

Genero also implements structured types with RECORD definitions, converted to com.fourjs.fgl.lang.FglRecord objects for Java.

The Genero arrays cannot be used to call Java methods. You must use a native Java arrays instead.

In some cases you need to explicitly cast with the new CAST() operator. See the section about CAST() operator for more details.

The next tables show the implicit conversions done by the runtime system when a Java method is called, or when a Java method returns a value or object reference:

Table 1. Implicit BDL/Java conversions using simple types
Genero data type Java equivalent
BIGINT long (64-bit signed integer)
BOOLEAN Boolean
BYTE com.fourjs.fgl.lang.FglByteBlob
CHAR java.lang.String
DATE com.fourjs.fgl.lang.FglDate
DATETIME com.fourjs.fgl.lang.FglDateTime
DECIMAL com.fourjs.fgl.lang.FglDecimal
FLOAT double (64-bit signed floating point number)
INTEGER int (32-bit signed integer)
INTERVAL com.fourjs.fgl.lang.FglInterval
MONEY com.fourjs.fgl.lang.FglDecimal
SMALLFLOAT float (32-bit signed floating point number)
SMALLINT short (16-bit signed integer)
STRING java.lang.String
TEXT com.fourjs.fgl.lang.FglTextBlob
TINYINT byte (8-bit signed integer)
VARCHAR java.lang.String
Table 2. Implicit BDL/Java conversions using structured types
Genero data type Java equivalent
RECORD structure com.fourjs.fgl.lang.FglRecord
Java Array This is a native Java Array
Table 3. Native BDL types that cannot be converted to Java types
Genero data type
ARRAY structures
Built-in classes