In Scala, how to override a method that takes a java.util.Map

interop, java, scala

Solution

This is going to make it work

override def foo(var1:java.util.Map[_,_]){ }

Problem

The Java class I am trying to subclass has a method like: ``` public abstract void foo(Map var1); ``` I can't figure out how to override that method. The Java class I am subclassing from does not use generics. In Scala I tried: ``` override def foo(var1:java.util.Map[Int,Int]){ } ``` But the compiler gives me the error message that it overrides nothing.. The heart of the problem is that Scala expects type parameters on the Map, however the Java class doesn't use them.

Original source