You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Main.java 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*******************************************************************************
  2. * Copyright (c) 2005 Contributors.
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Eclipse Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://eclipse.org/legal/epl-v10.html
  8. *
  9. * Contributors:
  10. * Matthew Webster initial implementation
  11. *******************************************************************************/
  12. import java.lang.reflect.Method;
  13. import java.lang.reflect.Modifier;
  14. public class Main {
  15. public void test1 () {
  16. System.out.println("Main.test1");
  17. }
  18. public void test2 () {
  19. System.out.println("Main.test2");
  20. }
  21. public void invokeDeclaredMethods () throws Exception {
  22. Method[] methods = getClass().getDeclaredMethods();
  23. for (int i = 0; i < methods.length; i++) {
  24. Method method = methods[i];
  25. int modifiers = method.getModifiers();
  26. if (!Modifier.isStatic(modifiers) && !method.getName().equals("invokeDeclaredMethods")) {
  27. method.invoke(this,new Object[] {});
  28. }
  29. }
  30. }
  31. public static void main (String[] args) throws Exception {
  32. System.out.println("Main.main");
  33. new Main().test1();
  34. new Main().test2();
  35. }
  36. }