How to get a class for list of objects of some type with Reflection to use it as a parameter when looking for a specific method
<p>
Hello, I have a class:</p>

<pre class="lang-java prettyprint-override"><code>package com.example.test;

public class Test {
    public static void doSomething(Object[] objects) {
        return;
    }
}
</code></pre>

<p>what I want to do is to get that class (and invoke later) with reflection. The problem is that I have the name of method and type of param given as Strings. Here is the code that I tried to solve this issue with:</p>

<pre class="lang-java prettyprint-override"><code>String methodName = "doSomething";
String paramType = "java.lang.Object";
try {
    Class&lt;?&gt; paramTypeClass = Class.forName(paramType);
    com.example.test.Test.class.getDeclaredMethod(methodName, paramTypeClass);
} catch (ClassNotFoundException | NoSuchMethodException e) {
    e.printStackTrace();
}
</code></pre>

<p>it throws a NoSuchMethodException:</p>

<blockquote>
  <p>java.lang.NoSuchMethodException: com.example.test.Test.doSomething(java.lang.Object)</p>
</blockquote>

<p>I also tried with paramType set to "java.lang.Object...", but it throws this on the 4th line of my code above:</p>

<blockquote>
  <p>java.lang.ClassNotFoundException: java/lang/Object///</p>
</blockquote>

<p>also with "java.lang.Object[]":</p>

<blockquote>
  <p>java.lang.ClassNotFoundException: java/lang/Object[]</p>
</blockquote>

<p>What should I put as the methodName, or how can I change my code in a different way to solve this problem?</p>