Issues Upgrading for m14 to 1.0b


I have a gradle project that i'm using the kotlin plugin for. I hopefully have something configured wrong and it's an easy fix :D My build.gradle

group 'com.iamshb’

version '1.0-SNAPSHOT’

apply plugin: 'java’
apply plugin: 'kotlin’

buildscript {
  ext.kotlin_version = ‘1.0.0-beta-1038’
  repositories {
  dependencies {
  classpath “org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version

sourceCompatibility = 1.8

repositories {

dependencies {
  testCompile group: ‘junit’, name: ‘junit’, version: ‘4.11’
  compile “org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version
sourceSets { += ‘src/main/kotlin’

Things that do not work anymore:

this worked before but now “javaClass” is not found

fun getResource(prefix: String, name: String) : InputStream {
  return Any::class.javaClass.classLoader.getResourceAsStream(</span>prefix<span>name)


This is inside a forEach Unit. it is no longer found, and toRegex() is no longer found.
and println is longer found.
if (it.matches("\s*#.*$".toRegex())) return@forEach;
println(parse(it, readBuffer)); 

Screen Shot 2015-10-22 at 1.54.37 PM.png (35.6 KB)


Does anything else from the Kotlin runtime work? Can you check if a simple hello world program would compile and run?

Please try to invalidate caches and restart (File -> Invalidate Caches / Restart…).

Also BTW “Any::class.javaClass” is probably not what you meant since this expression returns the runtime Java class of the expression “Any::class”, which happens to be KClass. More likely you meant “”, which will give you the Java class that is the runtime representation of Any (java.lang.Object).


Thanks so much, invalidating and restarting worked. I had restarted and updated but not invalidated mhmm.

As for the i get a NPE when i use that but Any::class.javaClass does not.


I'm glad it worked out. The NPE is strange though, could you please paste the stack trace for that? The simple "println(" works for me.



fun getResource(prefix: String, name: String) : InputStream {

class java.lang.Object
class java.lang.Class
class kotlin.jvm.internal.ClassReference
Exception in thread “main” java.lang.IllegalStateException:…eAsStream("$prefix$name") must not be null
at com.iamshb.hexinterpret.MainKt.getResource(Main.kt:37)
at com.iamshb.hexinterpret.MainKt.parse(Main.kt:23)
at com.iamshb.hexinterpret.MainKt.main(Main.kt:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at com.intellij.rt.execution.application.AppMain.main(

i tried  every combination of the prints to get the resource as a stream and only the last one work.ed the stack trace were all pretty much the same


I see. This happens because java.lang.Object (which represents Any at runtime) is a core JRE class and is loaded by the bootstrap class loader. Class#getClassLoader returns null in that case, as specified in the javadoc. I recommend you to take the class loader which loaded any of the classes in your application instead of the construct that you're using because it's rather confusing and may change unexpectedly when the app is run in another environment (where the Kotlin runtime would be loaded with a different class loader). So I would just use "" where SomeClass is any class in your code.


*nod* easy enought. Originally when i started this project there were no classes. I wanted to use the MainKt class (that java sees) to load it however in the context of kotlin it didn't seem to be avaialbe (in m14 at least)

Normally in java I would use what ever class contaned the main(String…) method but this was not present in kotlin.

that said perhaps to support purely functional programming kotlin could provide a substiute in some way.


You can just declare a local class Dummy and get its class loader :)


ah yes very true, i often forget about local classes...