mardi 19 mai 2015

Why can't I use Java's getDeclaredMethod() in Processing?

I want to create a simple method queue in Processing and I'm trying to do it with Java's native reflection. Why does getDeclaredMethod() not work in this sample? Is there a way to make it work? Regardless of the variations on it that I have tried, it always returns NoSuchMethodException...

import java.lang.reflect.Method;

void draw() {
  Testclass t = new Testclass();
  Class myClass = t.getClass();
  println("Class: " + myClass);

  // This doesn't work...
  Method m = myClass.getDeclaredMethod("doSomething");

  // This works just fine...
  println(myClass.getDeclaredMethods());

  exit();
}



// Some fake class...
class Testclass {
  Testclass() {
  }

  public void doSomething() {
    println("hi");
  }
}





Aucun commentaire:

Enregistrer un commentaire