Search code examples
kotlinjavacard

Kotlin for Java Card?


Is it possible to use Kotlin language to develop Java Card applets?

I know Kotlin produces JVM compatible byte code, but I am not sure Kotlin compilers can produce Java Card compatible byte code. Google knows nothing about this..


Solution

  • You might think that this should be possible as byte code is byte code. However, Java Card is a limited subset of Java both when it comes to the runtime as well as the API. As there has been no similar subset of Kotlin defined it would be next to impossible to use Kotlin for this.

    As far as I understood, Kotlin uses some tricks to implement certain features, e.g. generated bytecode that may use other objects. If these tricks use any Java that is not included in Java Card then a direct translation from Kotlin code to Java Card compliant code would fail. Note that Java Card even misses features such as strings, that int is optional and that new objects are created in persistent memory, the Kotlin specific bytecode almost certainly won't take such restrictions into account.

    In short, you'll have to familiarize yourself with Java and Java Card to develop for it.