Trick the reflector
<p>There is a piece of java code that I did not write and I can't change that uses the reflector to call a class' method. Something like this (I haven't seen the code):</p>

<pre><code>    ....
    params[0] = Something;
    ....
    Class c = Class.forName(Name);
    Method m = c.getDeclaredMethod(MethodName, pt);
    if (Modifier.isStatic(m.getModifiers()))
    {
        res = m.invoke(null, params);
    }
    else
    {
        obj = c.newInstance();
        res = m.invoke(obj, params);
    }
    ....
</code></pre>

<p>So far so good.</p>

<p>I control the class' name, the method's name and the parameters. I can send any combination of those, there is a catch though: The first parameter is hard-coded, so any parameter that I send is appended to the params array. So the method has to accept that parameter.</p>

<p>My question is: Is there a way to create a type and use it in there? Something like this:</p>

<pre><code>    public class PrintWrapper {
        public static void println(Somethingtype Something, String arg) {
            System.out.println(arg);
        }
    }
</code></pre>

<p>I tried using that as the Class name, but it didn't work, any idea? I need some sort of anonymous class or something.</p>

<p>And no, I can't change the source code or add a class to the system. The only things I control is the class' name, the method's name and the rest of the parameters.</p>
