this has no effect as far as i can see, you have a set reference that has no type safe protection. The compiler sees (Set vals) and thinks it can put anything in it, which it can. As at runtime the jvm sees TreeSet as at runtime TreeSet<String> does not exist only TreeSet exists on the heap.
Remember this type of type safety is compile only, but you have undone the compile time safety by making the ref like that.
this will give you compile time safety:
Set<String> vals = new TreeSet<String>();
type safey with generics is quite complicated , with the above and using legacy code you can run into problems.