Create an Object from an Array Class



I am using reflection to getmethod(methodName, Class parameters) and
invoke(object, obj[] parameters) methods from some Objects.

My problem is:

Say: I want to invoke a method that takes String[] object as parameter
(I was able to getmethod correctly). When I try to create an object
(to pass as args to invoke):

Object someObject= (Object) String[].class.newInstance();

(Note that the object is not always an instance of String[]... it
could be an instance of SomeOtherClass[])

I do get the following exception:

java.lang.InstantiationException: [Ljava.lang.String;

My question is:

Does the "[L" at the beginning and the ";" at the end have a meaning?
How can I solve this problem?

I am using IntelliJ 6.0.5.

Thanks in advance.

.



Relevant Pages

  • Re: java - invoke
    ... You have stumbled on one of the most subtle features of Java called ... You create call lists of parameters on the fly and invoke methods. ... It is a tool to allow java code to use arbitrary class files handed to ... You can usually get what you want without resorting to reflection ...
    (comp.lang.java.help)
  • Re: How to query n web services
    ... When I added web references, I wrote 10 different web references name. ... and then invoke service01.someMethod... ... The subset is given by strings. ... Using Reflection, you can use a string to create an instance of an object and then invoke methods on that instance. ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • Re: How can I detect the presense of an optional assembly and call a method within it?
    ... Basically you will need to use Reflection. ... allows you to dynamically create instances at runtime and invoke method. ... > 1- Read a configuration file where the client provides the assembly name ... > (DLL) and the ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How would you invoke arrayList.get() through reflection in 1.4 ??
    ... Sébastien de Mapias wrote: ... It seems to be pretty hard to invoke the List getmethod through ... I didn't manage to have my code working with my 1.4 ... That is *much* easier than using reflection. ...
    (comp.lang.java.programmer)
  • TransparentProxy and Reflection
    ... I'm using reflection to instantiate classes and then to invoke methods ... know the type at compile time, ...
    (microsoft.public.dotnet.framework)