Compilation error cannot be resolved to a type in FFI class

A compilation error can be raised when the classpath contains unexpected classes, for example:

Exception in thread "main" java.lang.Error: Unresolved compilation problems:
        ArrayComparisonFailure cannot be resolved to a type
        ArrayComparisonFailure cannot be resolved to a type

        at java.lang.Throwable.fillInStackTrace(
        at java.lang.Throwable.<init>(
        at java.lang.Error.<init>(
        at com.microej.js.JsFfi.ffi_toString_0(
        at com.microej.js.JsCode$1$1.invoke(

As described in the FFI section, in order to call Java methods from JavaScript code, all the methods with the given names are searched in the classpath. Since the classpath can contain test dependencies which are not available at compile time, the generated FFI can contain classes from these dependencies and therefore fail to compile. The following classes are excluded by default:

  • ej.junit.*
  • org.junit.*
  • junit.*
  • org.hamcrest.*
  • java.lang.String
  • java.lang.Number

This list can be changed by setting the system property js.ffi.excludes.classes to a comma-separated list of FQN patterns. For example:



Defining this property overwrites the default value, so do not forget to keep the default excluded classes (unless you know what you are doing).