Collection.toArray() should be passed an array of the proper type

MSAL

Using Collection.toArray() without parameters returns an Object[], which requires casting. It is more efficient and clearer to use Collection.toArray(new T[0]) instead. The parameterless form can cause a ClassCastException at runtime when the returned Object[] is cast to a more specific array type.

org.openrewrite.staticanalysis.CollectionToArrayShouldHaveProperType
mod run . --recipe=org.openrewrite.staticanalysis.CollectionToArrayShouldHaveProperType

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.