How to Create array without specifying datatype


#1

I have scenario where dynamically creating reflection class objects ., so in this case we want to create array which can be capable to handle reflection class objects .

I tried with val emptyArray = Array.empty[AnyVal] . and val emptyArray = Array.empty[Anyl] this basically are capable to handle datatype objects… but where i am forward looking to cast this objects to class object

any help would be appreciated wrt

  1. how to create empty array without specifying datatype

  2. how to create reflection class objects where objects being initialised in this manner
    this is for single object
    val scn = Class.forName(script1).newInstance.asInstanceOf[{ def call( env:String) : (customClass1,customClass2) }]

but not able to figure how to handle if i want to create array of scn


#2

You might want to explain what you need such Arrays for?

Short story is that reflection will look at actual object types on the JVM, and there, neither an Array without element type nor an Array[AnyVal] exist. Array.empty[AnyVal] really creates an Array[java.lang.Object] on the JVM. Note that java.lang.Object is the same as AnyRef.