IllegalStateException: Type parameter descriptor in not initialized


#1

After Andrew O'Malley helped me out in compiling and running my project, I have now gone on to add some features to my web service. To test out Kotlin I've created a little uploader resource that looks like this:

[Path("/test")]
public class UploadResource {
    val LOG: Logger? = LoggerFactory.getLogger(this.javaClass)
    val fileUploader = FileUploader()

  [POST]
  [Consumes(MediaType.MULTIPART_FORM_DATA)]
  [Produces(MediaType.APPLICATION_JSON)]
  public fun upload(formDataMultiPart: FormDataMultiPart): Response? {
  val files: MutableList<FormDataBodyPart>? = formDataMultiPart.getFields(“files”)
  if (files == null)
           return Response.status(400)?.build()

  &nbsp;&nbsp;val message = StringBuilder()
  &nbsp;&nbsp;for (file in files) {

           val contentDisposition = file.getContentDisposition()

           val fileName = contentDisposition.getFileName()
  }

  &nbsp;&nbsp;return Response.status(200)?.entity("Everything is ok")?.build()

  }
}


However, I get a very cryptic error at the line val fileName = contentDisposition.getFileName(). As soon as I type the ‘.’ after contentDisposition, I get the IllegalStateException mentioned in the title:

Kotlin: [Internal Error] java.lang.IllegalStateException: Type parameter descriptor in not initialized: T declared in com.sun.jersey.core.header.ContentDisposition.ContentDispositionBuilder
     at org.jetbrains.jet.lang.descriptors.impl.TypeParameterDescriptorImpl.checkInitialized(TypeParameterDescriptorImpl.java:101)
     at org.jetbrains.jet.lang.descriptors.impl.TypeParameterDescriptorImpl.getUpperBoundsAsType(TypeParameterDescriptorImpl.java:158)
     at org.jetbrains.jet.lang.types.SubstitutionUtils.makeStarProjection(SubstitutionUtils.java:120)
     at org.jetbrains.jet.lang.resolve.java.JavaTypeTransformer$3.visitClassType(JavaTypeTransformer.java:168)
     at org.jetbrains.jet.lang.resolve.java.JavaTypeTransformer$3.visitClassType(JavaTypeTransformer.java:113)
     at com.intellij.psi.PsiClassType.accept(PsiClassType.java:218)
     at org.jetbrains.jet.lang.resolve.java.JavaTypeTransformer.transformToType(JavaTypeTransformer.java:113)
     at org.jetbrains.jet.lang.resolve.java.resolver.JavaSignatureResolver.initializeTypeParameter(JavaSignatureResolver.java:296)
     at org.jetbrains.jet.lang.resolve.java.resolver.JavaSignatureResolver.initializeTypeParameters(JavaSignatureResolver.java:321)
     at org.jetbrains.jet.lang.resolve.java.resolver.JavaClassResolver.doCreateClassDescriptor(JavaClassResolver.java:261)
     at org.jetbrains.jet.lang.resolve.java.resolver.JavaClassResolver.createJavaClassDescriptor(JavaClassResolver.java:226)
     at org.jetbrains.jet.lang.resolve.java.resolver.JavaClassResolver.doResolveClass(JavaClassResolver.java:193)
     at org.jetbrains.jet.lang.resolve.java.resolver.JavaClassResolver.resolveClass(JavaClassResolver.java:177)
     at org.jetbrains.jet.lang.resolve.java.resolver.JavaClassResolver.resolveClass(JavaClassResolver.java:140)
     at org.jetbrains.jet.lang.resolve.java.resolver.JavaInnerClassResolver.resolveInnerClass(JavaInnerClassResolver.java:76)
     at org.jetbrains.jet.lang.resolve.java.resolver.JavaInnerClassResolver.resolveInnerClasses(JavaInnerClassResolver.java:62)
     at org.jetbrains.jet.lang.resolve.java.resolver.JavaInnerClassResolver.resolveInnerClasses(JavaInnerClassResolver.java:51)
     at org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver.resolveInnerClasses(JavaDescriptorResolver.java:269)
     at org.jetbrains.jet.lang.resolve.java.scope.JavaClassMembersScope.computeInnerClasses(JavaClassMembersScope.java:74)
     at org.jetbrains.jet.lang.resolve.java.scope.JavaBaseScope.getInnerClasses(JavaBaseScope.java:173)
     at org.jetbrains.jet.lang.resolve.java.scope.JavaClassMembersScope.getInnerClassesMap(JavaClassMembersScope.java:62)
     at org.jetbrains.jet.lang.resolve.java.scope.JavaClassMembersScope.getClassifier(JavaClassMembersScope.java:88)
     at org.jetbrains.jet.lang.resolve.calls.tasks.CallableDescriptorCollectors$FunctionCollector.addConstructors(CallableDescriptorCollectors.java:70)
     at org.jetbrains.jet.lang.resolve.calls.tasks.CallableDescriptorCollectors$FunctionCollector.getMembersByName(CallableDescriptorCollectors.java:59)
     at org.jetbrains.jet.lang.resolve.calls.tasks.TaskPrioritizer.doComputeTasks(TaskPrioritizer.java:158)
     at org.jetbrains.jet.lang.resolve.calls.tasks.TaskPrioritizer.computePrioritizedTasks(TaskPrioritizer.java:130)
     at org.jetbrains.jet.lang.resolve.calls.CallResolver.resolveFunctionCall(CallResolver.java:156)
     at org.jetbrains.jet.lang.resolve.calls.CallExpressionResolver.getResolvedCallForFunction(CallExpressionResolver.java:199)
     at org.jetbrains.jet.lang.resolve.calls.CallExpressionResolver.getCallExpressionTypeInfoWithoutFinalTypeCheck(CallExpressionResolver.java:311)
     at org.jetbrains.jet.lang.resolve.calls.CallExpressionResolver.getSelectorReturnTypeInfo(CallExpressionResolver.java:370)
     at org.jetbrains.jet.lang.resolve.calls.CallExpressionResolver.getQualifiedExpressionTypeInfo(CallExpressionResolver.java:417)
     at org.jetbrains.jet.lang.types.expressions.BasicExpressionTypingVisitor.visitQualifiedExpression(BasicExpressionTypingVisitor.java:719)
     at org.jetbrains.jet.lang.types.expressions.BasicExpressionTypingVisitor.visitQualifiedExpression(BasicExpressionTypingVisitor.java:74)
     at org.jetbrains.jet.lang.psi.JetVisitor.visitDotQualifiedExpression(JetVisitor.java:257)
     at org.jetbrains.jet.lang.psi.JetDotQualifiedExpression.accept(JetDotQualifiedExpression.java:34)
     at org.jetbrains.jet.lang.types.expressions.ExpressionTypingVisitorDispatcher.visitJetElement(ExpressionTypingVisitorDispatcher.java:220)
     at org.jetbrains.jet.lang.types.expressions.ExpressionTypingVisitorDispatcher.visitJetElement(ExpressionTypingVisitorDispatcher.java:33)
     at org.jetbrains.jet.lang.psi.JetVisitor.visitExpression(JetVisitor.java:149)
     at org.jetbrains.jet.lang.psi.JetVisitor.visitQualifiedExpression(JetVisitor.java:249)
     at org.jetbrains.jet.lang.psi.JetVisitor.visitDotQualifiedExpression(JetVisitor.java:257)
     at org.jetbrains.jet.lang.psi.JetDotQualifiedExpression.accept(JetDotQualifiedExpression.java:34)
     at org.jetbrains.jet.lang.types.expressions.ExpressionTypingVisitorDispatcher.getTypeInfo(ExpressionTypingVisitorDispatcher.java:115)
     at org.jetbrains.jet.lang.types.expressions.ExpressionTypingVisitorDispatcher.getTypeInfo(ExpressionTypingVisitorDispatcher.java:85)
     at org.jetbrains.jet.lang.types.expressions.ExpressionTypingServices.getTypeInfo(ExpressionTypingServices.java:135)
     at org.jetbrains.jet.lang.types.expressions.ExpressionTypingServices.getType(ExpressionTypingServices.java:140)
     at org.jetbrains.jet.lang.types.expressions.ExpressionTypingServices.safeGetType(ExpressionTypingServices.java:123)
     at org.jetbrains.jet.lang.resolve.DescriptorResolver.resolveInitializerType(DescriptorResolver.java:1092)
     at org.jetbrains.jet.lang.resolve.DescriptorResolver.getVariableType(DescriptorResolver.java:1027)
     at org.jetbrains.jet.lang.resolve.DescriptorResolver.resolveLocalVariableDescriptor(DescriptorResolver.java:752)
     at org.jetbrains.jet.lang.types.expressions.ExpressionTypingVisitorForStatements.visitProperty(ExpressionTypingVisitorForStatements.java:121)
     at org.jetbrains.jet.lang.types.expressions.ExpressionTypingVisitorForStatements.visitProperty(ExpressionTypingVisitorForStatements.java:51)
     at org.jetbrains.jet.lang.psi.JetProperty.accept(JetProperty.java:58)
     at org.jetbrains.jet.lang.types.expressions.ExpressionTypingVisitorDispatcher.getTypeInfo(ExpressionTypingVisitorDispatcher.java:115)
     at org.jetbrains.jet.lang.types.expressions.ExpressionTypingVisitorDispatcher.getTypeInfo(ExpressionTypingVisitorDispatcher.java:93)
     at org.jetbrains.jet.lang.types.expressions.ExpressionTypingServices.getBlockReturnedTypeWithWritableScope(ExpressionTypingServices.java:331)
     at org.jetbrains.jet.lang.types.expressions.ExpressionTypingServices.getBlockReturnedType(ExpressionTypingServices.java:215)
     at org.jetbrains.jet.lang.types.expressions.BasicExpressionTypingVisitor.visitBlockExpression(BasicExpressionTypingVisitor.java:570)
     at org.jetbrains.jet.lang.types.expressions.ExpressionTypingVisitorForStatements.visitBlockExpression(ExpressionTypingVisitorForStatements.java:353)
     at org.jetbrains.jet.lang.types.expressions.ExpressionTypingVisitorForStatements.visitBlockExpression(ExpressionTypingVisitorForStatements.java:51)
     at org.jetbrains.jet.lang.psi.JetBlockExpression.accept(JetBlockExpression.java:47)
     at org.jetbrains.jet.lang.types.expressions.ExpressionTypingVisitorDispatcher.getTypeInfo(ExpressionTypingVisitorDispatcher.java:115)
     at org.jetbrains.jet.lang.types.expressions.ExpressionTypingVisitorDispatcher.getTypeInfo(ExpressionTypingVisitorDispatcher.java:93)
     at org.jetbrains.jet.lang.types.expressions.ExpressionTypingServices.getBlockReturnedTypeWithWritableScope(ExpressionTypingServices.java:331)
     at org.jetbrains.jet.lang.types.expressions.ControlStructureTypingVisitor.visitForExpression(ControlStructureTypingVisitor.java:305)
     at org.jetbrains.jet.lang.types.expressions.ExpressionTypingVisitorForStatements.visitForExpression(ExpressionTypingVisitorForStatements.java:338)
     at org.jetbrains.jet.lang.types.expressions.ExpressionTypingVisitorForStatements.visitForExpression(ExpressionTypingVisitorForStatements.java:51)
     at org.jetbrains.jet.lang.psi.JetForExpression.accept(JetForExpression.java:36)
     at org.jetbrains.jet.lang.types.expressions.ExpressionTypingVisitorDispatcher.getTypeInfo(ExpressionTypingVisitorDispatcher.java:115)
     at org.jetbrains.jet.lang.types.expressions.ExpressionTypingVisitorDispatcher.getTypeInfo(ExpressionTypingVisitorDispatcher.java:93)
     at org.jetbrains.jet.lang.types.expressions.ExpressionTypingServices.getBlockReturnedTypeWithWritableScope(ExpressionTypingServices.java:353)
     at org.jetbrains.jet.lang.types.expressions.ExpressionTypingServices.getBlockReturnedType(ExpressionTypingServices.java:215)
     at org.jetbrains.jet.lang.types.expressions.BasicExpressionTypingVisitor.visitBlockExpression(BasicExpressionTypingVisitor.java:570)
     at org.jetbrains.jet.lang.types.expressions.BasicExpressionTypingVisitor.visitBlockExpression(BasicExpressionTypingVisitor.java:566)
     at org.jetbrains.jet.lang.types.expressions.BasicExpressionTypingVisitor.visitBlockExpression(BasicExpressionTypingVisitor.java:74)
     at org.jetbrains.jet.lang.psi.JetBlockExpression.accept(JetBlockExpression.java:47)
     at org.jetbrains.jet.lang.types.expressions.ExpressionTypingVisitorDispatcher.visitJetElement(ExpressionTypingVisitorDispatcher.java:220)
     at org.jetbrains.jet.lang.types.expressions.ExpressionTypingVisitorDispatcher.visitJetElement(ExpressionTypingVisitorDispatcher.java:33)
     at org.jetbrains.jet.lang.psi.JetVisitor.visitExpression(JetVisitor.java:149)
     at org.jetbrains.jet.lang.psi.JetVisitor.visitBlockExpression(JetVisitor.java:273)
     at org.jetbrains.jet.lang.psi.JetBlockExpression.accept(JetBlockExpression.java:47)
     at org.jetbrains.jet.lang.types.expressions.ExpressionTypingVisitorDispatcher.getTypeInfo(ExpressionTypingVisitorDispatcher.java:115)
     at org.jetbrains.jet.lang.types.expressions.ExpressionTypingVisitorDispatcher.getTypeInfo(ExpressionTypingVisitorDispatcher.java:85)
     at org.jetbrains.jet.lang.types.expressions.ExpressionTypingVisitorDispatcher.getTypeInfo(ExpressionTypingVisitorDispatcher.java:91)
     at org.jetbrains.jet.lang.types.expressions.ExpressionTypingServices.checkFunctionReturnType(ExpressionTypingServices.java:190)
     at org.jetbrains.jet.lang.types.expressions.ExpressionTypingServices.checkFunctionReturnType(ExpressionTypingServices.java:168)
     at org.jetbrains.jet.lang.resolve.BodyResolver.resolveFunctionBody(BodyResolver.java:640)
     at org.jetbrains.jet.lang.resolve.BodyResolver.resolveFunctionBodies(BodyResolver.java:624)
     at org.jetbrains.jet.lang.resolve.BodyResolver.resolveBehaviorDeclarationBodies(BodyResolver.java:134)
     at org.jetbrains.jet.lang.resolve.BodyResolver.resolveBodies(BodyResolver.java:144)
     at org.jetbrains.jet.lang.resolve.TopDownAnalyzer.doProcess(TopDownAnalyzer.java:133)
     at org.jetbrains.jet.lang.resolve.TopDownAnalyzer.analyzeFiles(TopDownAnalyzer.java:260)
     at org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(AnalyzerFacadeForJVM.java:198)
     at org.jetbrains.jet.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$1.invoke(KotlinToJVMBytecodeCompiler.java:318)
     at org.jetbrains.jet.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$1.invoke(KotlinToJVMBytecodeCompiler.java:313)
     at org.jetbrains.jet.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.java:235)
     at org.jetbrains.jet.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.java:312)
     at org.jetbrains.jet.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyzeAndGenerate(KotlinToJVMBytecodeCompiler.java:292)
     at org.jetbrains.jet.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyzeAndGenerate(KotlinToJVMBytecodeCompiler.java:273)
     at org.jetbrains.jet.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModule(KotlinToJVMBytecodeCompiler.java:107)
     at org.jetbrains.jet.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules(KotlinToJVMBytecodeCompiler.java:128)
     at org.jetbrains.jet.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.java:141)
     at org.jetbrains.jet.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.java:52)
     at org.jetbrains.jet.cli.common.CLICompiler.exec(CLICompiler.java:128)
     at org.jetbrains.jet.cli.common.CLICompiler.exec(CLICompiler.java:114)
     at org.jetbrains.jet.cli.jvm.K2JVMCompiler.exec(K2JVMCompiler.java:185)
     at org.jetbrains.jet.cli.jvm.K2JVMCompiler.exec(K2JVMCompiler.java:52)
     at org.jetbrains.jet.cli.common.CLICompiler.exec(CLICompiler.java:42)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
     at java.lang.reflect.Method.invoke(Method.java:606)
     at org.jetbrains.jet.compiler.runner.CompilerRunnerUtil.invokeExecMethod(CompilerRunnerUtil.java:116)
     at org.jetbrains.jet.compiler.runner.KotlinCompilerRunner.execInProcess(KotlinCompilerRunner.java:78)
     at org.jetbrains.jet.compiler.runner.KotlinCompilerRunner.access$000(KotlinCompilerRunner.java:40)
     at org.jetbrains.jet.compiler.runner.KotlinCompilerRunner$1.fun(KotlinCompilerRunner.java:63)
     at org.jetbrains.jet.compiler.runner.KotlinCompilerRunner$1.fun(KotlinCompilerRunner.java:60)
     at org.jetbrains.jet.compiler.runner.CompilerRunnerUtil.outputCompilerMessagesAndHandleExitCode(CompilerRunnerUtil.java:125)
     at org.jetbrains.jet.compiler.runner.KotlinCompilerRunner.runInProcess(KotlinCompilerRunner.java:60)
     at org.jetbrains.jet.compiler.runner.KotlinCompilerRunner.runCompiler(KotlinCompilerRunner.java:52)
     at org.jetbrains.jet.jps.build.KotlinBuilder.build(KotlinBuilder.java:113)
     at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:998)
     at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:739)
     at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:770)
     at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:702)
     at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:523)
     at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:314)
     at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:179)
     at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:129)
     at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:220)
     at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:112)
     at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler$1.run(BuildMain.java:132)
     at org.jetbrains.jps.service.impl.SharedThreadPoolImpl$1.run(SharedThreadPoolImpl.java:41)
     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
     at java.util.concurrent.FutureTask.run(FutureTask.java:166)
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
     at java.lang.Thread.run(Thread.java:724)

I am not able to call any method from the contentDisposition instance, even though this is a completely valid and legal action in Java. What did I do wrong?


#2

Please report this bug to the tracker