I'm not sure what you would like to do with an abstract static method in java, but the only potential use case I've seen described in the past (I wish I remembered by whom...) is calling a method directly on a generic type parameter.
i.e. if java allowed something like this...
// this is not valid java...
// let's pretend we can define a static method in an interface
interface Foo {
static String Foo();
}
// a class that implements our interface
class FooImpl implements Foo {
public static String Foo() {return "foo";}
}
...we could use it on a generic parameter, to call Foo() directly on the type
static <T extends Foo> String Test() {
return T.Foo(); // even if our hypothetical static interface
// was a valid thing, this would probably still fail
// due to type erasure
}
This would make somewhat more sense in C# because:
- Reified generics mean the type does not get erased
- in C# operators are static methods and you can define your own operators
Basically this means in a "pretend C#" with static interfaces, you could use something corresponding to the above "pretend java" code to write a generic method that works on any type that defines a specific operator (e.g. everything that has a "+" operator).
Now, back to scala. How does scala address this scenario?
In part it doesn't. Scala has no static methods: an object is a singleton (i.e. a class with only one instance) but still a class with normal, instance methods, i.e. on objects you're still calling methods on the only instance, not directly on the type (even operators are methods in scala).
So in scala we would write:
trait Foo { def Foo:String }
object FooImpl extends Foo { def Foo = "foo" }
def Test(f: Foo) = f.Foo
...and call our method with
scala> Test(FooImpl)
res0: String = foo
// note that FooImpl is still an instance (the only one) of FooImpl and not
// the type itself
You can do some tricks with implicits to avoid passing the only instance as a parameter:
implicit def aFoo = FooImpl
def Test2(implicit f: Foo) = f.Foo
now this works:
scala> Test2
res1: String = foo
With more advanced tricks with implicits, scala also defines Numeric, that allows you to use operators on any numeric value, even though they don't implements a common interface out of the box.