Arrays in Java are not generic, so when you convert from a Java collection it will produce an Array[Object].
Looking at the documentation of toArray in java.util.Set we find two variations of the method
Object[] toArray()
Returns an array containing all of the elements in this set.
and
<T> T[] toArray(T[] a)
Returns an array containing all of the elements in this set; the runtime type of the returned array is that of the specified array.
You're currently using the first variation, but you can use the second one by passing an array of the correct type as argument.
This is a "workaround" used by Java in order to produce an array of the correct type.
Here's an example
import java.util.HashSet
import java.lang.reflect.Field
val set = new HashSet[Field]
val arr1 = set.toArray // Array[Object]
val arr2 = set.toArray(Array[Field]()) // Array[Field]
Another viable option is to convert your java.util.Set into a scala Set, which provides a "smarter" toArray method:
import java.util.HashSet
import java.lang.reflect.Field
import scala.collection.JavaConversions._
val set = new HashSet[Field]
val arr = set.toSet.toArray // Array[Field]
import java.lang.reflect.Field; def test(in: Set[Field]): Array[Field] = in.toArray