Interoperability with Java

Flix is a Java Virtual Machine (JVM)-based programming language, hence:

  • Flix programs compile to efficient JVM bytecode.
  • Flix programs run on any Java Virtual Machine1.
  • Flix programs can call Java code.

Flix supports most Java features necessary for interoperability:

Thus Flix programs can reuse the Java Class Library. In addition, the Flix package manager has Maven support.

Flix and Java share the same base types, but they have different names, as shown in the table:

Flix TypeJava Type
Boolboolean
Charchar
Float32float
Float64double
Int8byte
Int16short
Int32int
Int64long
StringString

In Flix primitive types are always unboxed. Hence, to call a Java method that expects a java.lang.Integer, if you have a Flix Int32, it must be boxed by calling java.lang.Integer.valueOf.

1

Flix requires at least Java 21.