Class literals for annotation values

There are several annotations that require class literals or even arrays of class literals, Remote or Resource come mind.

In Java I would write something like:

@Remote({FirstInterface.class, SecondInterface.class})
public class SampleEJB implements FirstInterface.class SecondInterface {

  @Resource(name = “datasources/first”, class = DataSource.class)
  private DataSource dataSource;


Is there a way to do this with Kotlin?

Yes, named arguments will help, and to pass an array, you can use the array() function.

Ok, I got the following working in the IDE

Singleton Remote(javaClass<TTenant>()) class TenantBean : TTenant { }

And the byte code in the IDE looks good

public final class com/acme/TenantBean implements jet/JetObject com/acme/TTenant  {

  // compiled from: Implementation.kt




However I had to add kotlin-stdlib otherwise it would not compile on the command line and complain about

Unresolved reference: javaClass 

(I’m using Maven)