Blog Post

#2945 Build 1.0.82

brian Thu 26 Jun

We have posted build 1.0.82 for download and updated the online docs.

Fanc

We are introducing a new command line tool fanc as the hub for all compiler and transpiler tools. This initial version provides access to existing JavaScript transpiler tools. Plus we are introducing a brand new feature to transpile Fantom to Java source code.

Java Transpiler

Using fanc you can now transpile a set of Fantom pods into Java source code. This provides some advantages over using JarDist in that it integrates more cleanly into Java projects for build and IDE tools. See docLang/Java for more details. We also spend quite a bit of effort to make the Java APIs more ergonimic including making Fantom List/Map Java generic types and they now implement their respective java.util interfaces.

Java Changes

In order to support a more ergonomic Java API for Fantom code we did introduce some breaking changes to the Java implementation of Fantom classes:

  • fan.sys.List now implements java.util.List and uses Java generics
  • fan.sys.Map now implements java.util.Map and uses Java generics
  • List constructors replaced with List.make
  • Generic types are package private
  • Use Type.makeFunc and makeMap to construct generic types, or Map.make(k, v)
  • Use Type.x to access generic parameters if required
  • Some methods and List/Map prefixed with _ so then can implement java.util APIs
  • Chained List.add needs to be _add now

Unicode in Java

Under the covers we have made several changes to improve Java support for surrogate pairs for Unicode chars above plane 0 including emojis. We have also added support for a new Unicode escape sequence \u{xxxxx} that works just like JavaScript for hex code points that are over 16-bits.

JavaScript Design Transition

Starting in build 1.0.81 we are no longer implementing new methods in the old JavaScript code, only in the new ECMA design. We are now defaulting WebJsMode to es for all FilePack APIs. The current plan is to fully remove support for the old JavaScript design in build 1.0.83.

ChangeLog

Build 1.0.82 (26 Jun 2025)

  • New fanc tool for transpiling to Java source
  • Java make List/Map generic types
  • Java List implements java.util.List
  • Java Map implements java.util.Map
  • Java make fan.sys.Type subclasses package scope
  • Java make all Map and List constructors package scope
  • Compiler: rename CParam.paramType to type
  • Compiler: rename CMethod.returnType to returns
  • Compiler: rename CField.fieldType to type
  • Compiler: rename MethodDef.ret to returns
  • Compiler: rename FuncType.ret to returns
  • Default default WebJsMode to es
  • Add File.withIn and File.withOut
  • Add StrBuf.joinNotNull
  • Add Win.devicePixelRatio
  • Add Stroke.scale
  • Add Doc.hasFocus
  • Add Win.hisState
  • Add concurrent ActorContext
  • Add util::SyntheticFile
  • Date convenience methods for quarter, year
  • ES support for IntArray and FloatArray
  • New docs: Interop, Java, and Fanc
  • Add string literal escape sequence for \u{xxx}
  • Improve surrogate pair support in Java
  • France locale change start of week from Sun to Mon

Naren S Yesterday

Hi Brain,

Firstly, thank you for adding all the new features to Fantom — I really appreciate the team’s effort and improvements so far.

However, I haven’t seen any changes implemented by the team on the

  1. echo function
  2. and append "+" operator

so far in release notes.

I have identified a bug with the parameterised echo function. It works fine when printing a simple string message, but it fails whenever I try to print a parameter or variable value.

The same if I tried to append a variable value into any string

eg. welcome := "Hello, "+name

//Test class

class FantomTest {

static Void main() {
    echo("Hello, Fantom 1.0.82  ") // works perfectly fine
}

Str printData(Str msg) {
    echo("Received message: " + msg) // error caused statement
    return msg
}

Str testAddOperator(Str msg) {
    Str result := "Hello, " + msg    // error caused statement
    return result
}

}

and compilation error:

CompileJs ERR: Internal compiler error sys::UnknownSlotErr: sys::Method.inheritedReturnType

fan.sys.ClassType.slot (ClassType.java:104)
fan.sys.FanObj.doTrap (FanObj.java:191)
fan.sys.FanObj.trap (FanObj.java:187)
fan.sys.Slot.trap (Slot.java:118)
fan.sys.Method.trap (Method.java:99)
fan.sys.FanObj.trap (FanObj.java:179)
compiler::ReflectMethod.inheritedReturnType (ReflectSlot.fan:91)
compiler::FPod.addMethodRef (FPod.fan:134)
compiler::FPod.addMethodRef (FPod.fan)
compiler::CodeAsm.addStr (CodeAsm.fan:1529)
compiler::CodeAsm.shortcut (CodeAsm.fan:1367)
compiler::CodeAsm.expr (CodeAsm.fan:666)
compiler::CodeAsm.assignLocalVar (CodeAsm.fan:1023)
compiler::CodeAsm.assign (CodeAsm.fan:1001)
compiler::CodeAsm.expr (CodeAsm.fan:652)
compiler::CodeAsm.localVarDefStmt (CodeAsm.fan:192)
compiler::CodeAsm.stmt (CodeAsm.fan:48)
compiler::CodeAsm.block (CodeAsm.fan:39)
fan.sys.List.each (List.java:662)
compiler::CodeAsm.block (CodeAsm.fan:39)
compiler::Assembler.assembleCode (Assembler.fan:152)
compiler::Assembler.assembleMethod (Assembler.fan:122)
compiler::Assembler.assembleType (Assembler.fan:65)
fan.sys.List.map (List.java:922)
compiler::Assembler.assembleType (Assembler.fan:65)
28 More...

BUILD FAILED [269ms]!

Login or Signup to reply.