How to declare constructor and constructor-parameter annotations?


Hi, I'm developing a Guice based Java-framework that dependends heavily on annotations and Guice supports many type of ways to inject dependencies via them. So far, I haven't found information about how to annotate constructors or their parameters. So given following Java-example, how is it expressed in Kotlin?

public class FooService {

  public FooService(DatabaseConnection connection,
                   @Named(“debugMode”) String debuMode) {


[Transactional] class FooService   [Inject] (c: DatabaseConnection, [Named("debugMode")] dm: String) {


Square brackets are optional im post cases


It seems that the parameter annotation works differently in Kotlin than in Java, because parameter annotation is not present. I made this kind of test:

import java.lang.annotation.Target;
import java.lang.annotation.Retention;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;

public @interface TestAnnotation {

public class JavaClass {
    public JavaClass(String foo, @TestAnnotation String foo2) {


public class KotlinClass(foo: String, [TestAnnotation] foo2 : String) {

import org.junit.Test;

import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;

public class AnnotationTest {

  private void listAnnotations(Class cl) {
  System.out.println(cl + “: Constructor annotations”);

  &nbsp;&nbsp;for (Constructor<!--?--> constructor : cl.getConstructors()) {

           int i = 0;
           for (Annotation[] annos : constructor.getParameterAnnotations()) {
           System.out.print(“Parameter " + i + “:”);
           for (Annotation _ : annos) {
                   System.out.print(” " + _.annotationType());

  public void test() {

The result is following:

class JavaClass: Constructor annotations
Parameter 0:
Parameter 1: interface TestAnnotation
class KotlinClass: Constructor annotations
Parameter 0: interface jet.runtime.typeinfo.JetValueParameter
Parameter 1: interface jet.runtime.typeinfo.JetValueParameter

Is this by design or a bug?


It's a bug. Please, report it to the tracker. Thanks