javaClass<MyClass>() not as nice as MyClass.class

javaClass<MyClass>() not as nice as MyClass.class.  Any plans to add simpler static class references?  We use static class references all through out our code with our Dependency Inject engine, and Dynamic Transforms, the kotlin function is not as strait forward as the java static reference.  

Once there's Kotlin reflection, the syntax most likely will be:

MyClass::class

, which will return an instance of a Kotlin class. This is work in progress right now.

including

this::class

?

Will the Kotlin Class be compatible with a java class?  For example will ArrayList.class == ArrayList::class?

Yes, but we've yet to decide the syntax for getting a class by an instance. Allowing arbitrary expressions on the left hand side creates a problem for classes with class objects ('MyClass' can be seen both as a type symbol and as an expression)

No, it'll be a separate platform-agnostic API. On JVM, we'll provide a way to get a Java class by a Kotlin class to interoperate with existing Java libraries.

But to answer your original question (which I suppose implied that you use some dependency injection library in Java): I’m afraid javaClass is the best that you can get. Hopefully some day there’ll be a dependency injection framework in Kotlin and you’ll only need to use Kotlin reflection from then on :slight_smile:

Could we also have similar references for fields and methods?

Like

val fieldRef:kotlin.Field<MyClass,FieldType> = MyClass::field(“fieldName”) // compile-time check if argument is constant

val methodRef:kotlin.Method<MyClass,FunctionN<ReturnType,ArgType1,…,ArgTypeN>> = MyClass::method(“methodName”); // for overloaded methods, argument type list should be provided

val fieldVal:FieldType = fieldRef.get(myClassInstance);

fieldRef.set(myClassInstance,fieldVal);

val methodVal:ReturnType = methodRef.get(myClassInstance)(arg1,...,argN);

References to fields of object could be made like this:

data class FieldRef<C,T>(val field:Field<C,T>, val obj:C) {

  fun get() = field.get(obj);

  fun set(value:T) = field.set(obj,value);

}

Already there for functions, properties are coming

Is current language documentation available and maintained somewhere? I can't find anything about callable references on http://confluence.jetbrains.com/display/Kotlin/

We are working on an updated docs site. The only docs available about this feature can be found here: http://blog.jetbrains.com/kotlin/2013/06/kotlin-m5-3-idea-13-delegated-properties-and-more/