IntelliJ 2016.3 not supporting java 8 methods during compile for debug

I upgraded to IntelliJ 2016.3 community edition, and I installed the scala-plugin.

IntelliJ was configured with Java 8 and scala-sdk-2.11.6

 

While trying to execute a debug session, IntelliJ was compiling all of the code in the project in order to debug.

It was unable to actually execute the debug session, because during the compile, it complained that in a given scala source file the "getOrDefault" method didn't exist for java.util.Map[String, java.lang.Float]

That is, in this scala source file, there is an import:

import collection.{JavaConversions, mutable}

and a variable is defined as:

private val myMap: java.util.Map[String, java.lang.Float]

and then used as follows

thresh = myMap.getOrDefault(c, defaultValue).asInstanceOf[Float]

Although the intellisense indicates that "getOrDefault" is a valid method on myMap, the scala-plugin will not compile it, claiming in an error message that the "getOrDefault" method is not valid for a java.lang.Map.

I tried various things to fix this problem, but none of them worked.

Compiling the project with maven works fine.

I ended up regressing to IntelliJ version 2016.2.5 and the problem is no longer present.



4 comments
Comment actions Permalink

Can you share the whole file or try to isolate this error? I couldn't reproduce it from your description.

0
Comment actions Permalink

Here's a snippet that exhibits the problem on my machine:

package com.abcxyz

import collection.JavaConversions._

class DebugProblemExample(
private val myMap: java.util.Map[String, java.lang.Float]) {

def performAssignment() {
val exampleValue = myMap.getOrDefault("example", 1.asInstanceOf[Float]).asInstanceOf[Float]
}
}

The error is:

Error:(9, 28) value getOrDefault is not a member of java.util.Map[String,Float]
val exampleValue = myMap.getOrDefault("example", 1.asInstanceOf[Float]).asInstanceOf[Float]

 

0
Comment actions Permalink

You need to configure jdk 1.8 for Scala Compile Server:



I'll add an autodetection of such cases.

0
Comment actions Permalink

That was it :)  Thanks!

0

Please sign in to leave a comment.