Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 811
Nicholas Marshall Avatar asked Dec 25 '12 04:12

Nicholas Marshall


1 Answers

This is going to make it work

override def foo(var1:java.util.Map[_,_]){ }
like image 75
pedrofurla Avatar answered Nov 10 '22 08:11

pedrofurla