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 Java 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.

This table shows 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 conversions by Genero with Java method / Java method returns
Genero data type Java equivalent
CHAR java.lang.String
VARCHAR java.lang.String
STRING java.lang.String
DATE com.fourjs.fgl.lang.FglDate
DATETIME com.fourjs.fgl.lang.FglDateTime
INTERVAL com.fourjs.fgl.lang.FglInterval
BIGINT long (64-bit signed integer)
INTEGER int (32-bit signed integer)
SMALLINT short (16-bit signed integer)
TINYINT tinyint (8-bit signed integer)
FLOAT double (64-bit signed floating point number)
SMALLFLOAT float (32-bit signed floating point number)
DECIMAL com.fourjs.fgl.lang.FglDecimal
MONEY com.fourjs.fgl.lang.FglDecimal
BYTE com.fourjs.fgl.lang.FglByteBlob
TEXT com.fourjs.fgl.lang.FglTextBlob
RECORD structure com.fourjs.fgl.lang.FglRecord
Java Array This is a native Java Array
Table 2. Native language data types that cannot be converted to Java types
Genero data type
ARRAY structures
Built-in classes