Compiler crash with mixed src


#1

1) create Crash.kt

package net.unitcraft.game

class Crash


2) create Crash.java

package net.unitcraft.game;

class JCrash {}


3) compile

Error:Kotlin: [Internal Error] java.lang.IllegalStateException: Requested net.unitcraft.game.Crash, got net.unitcraft.game.JCrash
  at org.jetbrains.jet.lang.resolve.java.JavaClassFinderImpl.findClass(JavaClassFinderImpl.java:87)
  at org.jetbrains.jet.lang.resolve.java.lazy.LazyPackage-resolvers-d8aa14c2.findClassInJava(resolvers.kt:87)
  at org.jetbrains.jet.lang.resolve.java.lazy.LazyPackage-resolvers-d8aa14c2.findJavaClass(resolvers.kt:67)
  at org.jetbrains.jet.lang.resolve.java.lazy.LazyJavaPackageFragmentProvider$_packageFragments$1.invoke(LazyJavaPackageFragmentProvider.kt:61)
  at org.jetbrains.jet.lang.resolve.java.lazy.LazyJavaPackageFragmentProvider$_packageFragments$1.invoke(LazyJavaPackageFragmentProvider.kt)
  at org.jetbrains.jet.storage.LockBasedStorageManager$MapBasedMemoizedFunction.invoke(LockBasedStorageManager.java:375)
  at org.jetbrains.jet.lang.resolve.java.lazy.LazyJavaPackageFragmentProvider.getPackageFragment(LazyJavaPackageFragmentProvider.kt:94)
  at org.jetbrains.jet.lang.resolve.java.lazy.LazyJavaPackageFragmentProvider.getPackageFragments(LazyJavaPackageFragmentProvider.kt:97)
  at org.jetbrains.jet.lang.descriptors.impl.CompositePackageFragmentProvider.getPackageFragments(CompositePackageFragmentProvider.java:43)
  at org.jetbrains.jet.lang.descriptors.ModuleDescriptorImpl.getPackage(ModuleDescriptorImpl.java:99)
  at org.jetbrains.jet.lang.descriptors.impl.SubpackagesScope.getPackage(SubpackagesScope.java:50)
  at org.jetbrains.jet.lang.resolve.scopes.JetScopeSelectorUtil$2.get(JetScopeSelectorUtil.java:84)
  at org.jetbrains.jet.lang.resolve.scopes.JetScopeSelectorUtil$2.get(JetScopeSelectorUtil.java:80)
  at org.jetbrains.jet.lang.resolve.scopes.JetScopeSelectorUtil.getFirstMatch(JetScopeSelectorUtil.java:131)
  at org.jetbrains.jet.lang.resolve.scopes.ChainedScope.getPackage(ChainedScope.java:52)
  at org.jetbrains.jet.lang.resolve.DeclarationResolver.checkRedeclarationsInPackages(DeclarationResolver.java:298)
  at org.jetbrains.jet.lang.resolve.DeclarationResolver.process(DeclarationResolver.java:93)
  at org.jetbrains.jet.lang.resolve.TopDownAnalyzer.doProcess(TopDownAnalyzer.java:154)
  at org.jetbrains.jet.lang.resolve.TopDownAnalyzer.analyzeFiles(TopDownAnalyzer.java:270)
  at org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(AnalyzerFacadeForJVM.java:163)
  at org.jetbrains.jet.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$2.invoke(KotlinToJVMBytecodeCompiler.java:292)
  at org.jetbrains.jet.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$2.invoke(KotlinToJVMBytecodeCompiler.java:285)
  at org.jetbrains.jet.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.java:223)
  at org.jetbrains.jet.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.java:284)
  at org.jetbrains.jet.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules(KotlinToJVMBytecodeCompiler.java:122)
  at org.jetbrains.jet.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.java:143)
  at org.jetbrains.jet.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.java:53)
  at org.jetbrains.jet.cli.common.CLICompiler.exec(CLICompiler.java:139)
  at org.jetbrains.jet.cli.common.CLICompiler.exec(CLICompiler.java:125)
  at org.jetbrains.jet.cli.common.CLICompiler.exec(CLICompiler.java:57)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:483)
  at org.jetbrains.jet.compiler.runner.CompilerRunnerUtil.invokeExecMethod(CompilerRunnerUtil.java:129)
  at org.jetbrains.jet.compiler.runner.KotlinCompilerRunner.execCompiler(KotlinCompilerRunner.java:112)
  at org.jetbrains.jet.compiler.runner.KotlinCompilerRunner.access$000(KotlinCompilerRunner.java:40)
  at org.jetbrains.jet.compiler.runner.KotlinCompilerRunner$1.fun(KotlinCompilerRunner.java:95)
  at org.jetbrains.jet.compiler.runner.KotlinCompilerRunner$1.fun(KotlinCompilerRunner.java:92)
  at org.jetbrains.jet.compiler.runner.CompilerRunnerUtil.outputCompilerMessagesAndHandleExitCode(CompilerRunnerUtil.java:138)
  at org.jetbrains.jet.compiler.runner.KotlinCompilerRunner.runCompiler(KotlinCompilerRunner.java:92)
  at org.jetbrains.jet.compiler.runner.KotlinCompilerRunner.runK2JvmCompiler(KotlinCompilerRunner.java:58)
  at org.jetbrains.jet.jps.build.KotlinBuilder.build(KotlinBuilder.java:209)
  at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1142)
  at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:828)
  at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:896)
  at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:791)
  at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:614)
  at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:359)
  at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:191)
  at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:129)
  at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:229)
  at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:113)
  at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler$1.run(BuildMain.java:157)
  at org.jetbrains.jps.service.impl.SharedThreadPoolImpl$1.run(SharedThreadPoolImpl.java:41)
  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
  at java.util.concurrent.FutureTask.run(FutureTask.java:266)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
  at java.lang.Thread.run(Thread.java:745)
Error:Kotlin: Compiler terminated with exit code: 2


#2

This is a bug. Could you report it to your tracker? As workaround you can rename Crash.java file or Crash class written on Kotlin.


#3

This is a bug indeed: Kotlin does not play well with Java classes whose names do not match the file name (your JCrash class)