Java Code Examples for java.lang.Class#getMethod()

The following examples show how to use java.lang.Class#getMethod() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BadClassFiles.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void assertBadParameters(Class<?> cls) throws NoSuchMethodException {
    try {
        System.err.println("Trying " + cls);
        final Method method = cls.getMethod("m", int.class, int.class);
        final Parameter[] params = method.getParameters();
        System.err.println("Name " + params[0].getName());
        System.err.println("Did not see expected exception");
        errors++;
    } catch(MalformedParametersException e) {
        System.err.println("Expected exception seen");
    }
}
 
Example 2
Source File: BadClassFiles.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void assertBadParameters(Class<?> cls) throws NoSuchMethodException {
    try {
        System.err.println("Trying " + cls);
        final Method method = cls.getMethod("m", int.class, int.class);
        final Parameter[] params = method.getParameters();
        System.err.println("Name " + params[0].getName());
        System.err.println("Did not see expected exception");
        errors++;
    } catch(MalformedParametersException e) {
        System.err.println("Expected exception seen");
    }
}
 
Example 3
Source File: BadClassFiles.java    From native-obfuscator with GNU General Public License v3.0 5 votes vote down vote up
public void assertBadParameters(Class<?> cls) throws NoSuchMethodException {
    try {
        System.err.println("Trying " + cls);
        final Method method = cls.getMethod("m", int.class, int.class);
        final Parameter[] params = method.getParameters();
        System.err.println("Name " + params[0].getName());
        System.err.println("Did not see expected exception");
        errors++;
    } catch(MalformedParametersException e) {
        System.err.println("Expected exception seen");
    }
}
 
Example 4
Source File: BadClassFiles.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void assertBadParameters(Class<?> cls) throws NoSuchMethodException {
    try {
        System.err.println("Trying " + cls);
        final Method method = cls.getMethod("m", int.class, int.class);
        final Parameter[] params = method.getParameters();
        System.err.println("Name " + params[0].getName());
        System.err.println("Did not see expected exception");
        errors++;
    } catch(MalformedParametersException e) {
        System.err.println("Expected exception seen");
    }
}
 
Example 5
Source File: BadClassFiles.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void assertBadParameters(Class<?> cls) throws NoSuchMethodException {
    try {
        System.err.println("Trying " + cls);
        final Method method = cls.getMethod("m", int.class, int.class);
        final Parameter[] params = method.getParameters();
        System.err.println("Name " + params[0].getName());
        System.err.println("Did not see expected exception");
        errors++;
    } catch(MalformedParametersException e) {
        System.err.println("Expected exception seen");
    }
}
 
Example 6
Source File: BadClassFiles.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void assertBadParameters(Class<?> cls) throws NoSuchMethodException {
    try {
        System.err.println("Trying " + cls);
        final Method method = cls.getMethod("m", int.class, int.class);
        final Parameter[] params = method.getParameters();
        System.err.println("Name " + params[0].getName());
        System.err.println("Did not see expected exception");
        errors++;
    } catch(MalformedParametersException e) {
        System.err.println("Expected exception seen");
    }
}
 
Example 7
Source File: BadClassFiles.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void assertBadParameters(Class<?> cls) throws NoSuchMethodException {
    try {
        System.err.println("Trying " + cls);
        final Method method = cls.getMethod("m", int.class, int.class);
        final Parameter[] params = method.getParameters();
        System.err.println("Name " + params[0].getName());
        System.err.println("Did not see expected exception");
        errors++;
    } catch(MalformedParametersException e) {
        System.err.println("Expected exception seen");
    }
}
 
Example 8
Source File: NoName.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void run() throws NoSuchMethodException {
    final Class<?> cls = noName;
    System.err.println("Trying " + cls);
    final Method method = cls.getMethod("m", int.class, int.class);
    final Parameter[] params = method.getParameters();
    System.err.println("Name " + params[0].getName());
    System.err.println("Name " + params[1].getName());
}
 
Example 9
Source File: BadClassFiles.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void assertBadParameters(Class<?> cls) throws NoSuchMethodException {
    try {
        System.err.println("Trying " + cls);
        final Method method = cls.getMethod("m", int.class, int.class);
        final Parameter[] params = method.getParameters();
        System.err.println("Name " + params[0].getName());
        System.err.println("Did not see expected exception");
        errors++;
    } catch(MalformedParametersException e) {
        System.err.println("Expected exception seen");
    }
}
 
Example 10
Source File: BadClassFiles.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void assertBadParameters(Class<?> cls) throws NoSuchMethodException {
    try {
        System.err.println("Trying " + cls);
        final Method method = cls.getMethod("m", int.class, int.class);
        final Parameter[] params = method.getParameters();
        System.err.println("Name " + params[0].getName());
        System.err.println("Did not see expected exception");
        errors++;
    } catch(MalformedParametersException e) {
        System.err.println("Expected exception seen");
    }
}
 
Example 11
Source File: BadClassFiles.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void assertBadParameters(Class<?> cls) throws NoSuchMethodException {
    try {
        System.err.println("Trying " + cls);
        final Method method = cls.getMethod("m", int.class, int.class);
        final Parameter[] params = method.getParameters();
        System.err.println("Name " + params[0].getName());
        System.err.println("Did not see expected exception");
        errors++;
    } catch(MalformedParametersException e) {
        System.err.println("Expected exception seen");
    }
}
 
Example 12
Source File: BadClassFiles.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void assertBadParameters(Class<?> cls) throws NoSuchMethodException {
    try {
        System.err.println("Trying " + cls);
        final Method method = cls.getMethod("m", int.class, int.class);
        final Parameter[] params = method.getParameters();
        System.err.println("Name " + params[0].getName());
        System.err.println("Did not see expected exception");
        errors++;
    } catch(MalformedParametersException e) {
        System.err.println("Expected exception seen");
    }
}
 
Example 13
Source File: BadClassFiles.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void assertBadParameters(Class<?> cls) throws NoSuchMethodException {
    try {
        System.err.println("Trying " + cls);
        final Method method = cls.getMethod("m", int.class, int.class);
        final Parameter[] params = method.getParameters();
        System.err.println("Name " + params[0].getName());
        System.err.println("Did not see expected exception");
        errors++;
    } catch(MalformedParametersException e) {
        System.err.println("Expected exception seen");
    }
}
 
Example 14
Source File: BadClassFiles.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void assertBadParameters(Class<?> cls) throws NoSuchMethodException {
    try {
        System.err.println("Trying " + cls);
        final Method method = cls.getMethod("m", int.class, int.class);
        final Parameter[] params = method.getParameters();
        System.err.println("Name " + params[0].getName());
        System.err.println("Did not see expected exception");
        errors++;
    } catch(MalformedParametersException e) {
        System.err.println("Expected exception seen");
    }
}
 
Example 15
Source File: BadClassFiles.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void assertBadParameters(Class<?> cls) throws NoSuchMethodException {
    try {
        System.err.println("Trying " + cls);
        final Method method = cls.getMethod("m", int.class, int.class);
        final Parameter[] params = method.getParameters();
        System.err.println("Name " + params[0].getName());
        System.err.println("Did not see expected exception");
        errors++;
    } catch(MalformedParametersException e) {
        System.err.println("Expected exception seen");
    }
}
 
Example 16
Source File: MoveFactory.java    From eb-java-scorekeep with Apache License 2.0 4 votes vote down vote up
public Move newMove(String sessionId, String gameId, String userId, String moveText) throws SessionNotFoundException, GameNotFoundException, StateNotFoundException, RulesException {
  String moveId = Identifiers.random();
  String stateId = Identifiers.random();
  Move move = new Move().setId(moveId)
                        .setSession(sessionId)
                        .setGame(gameId)
                        .setUser(userId)
                        .setMove(moveText);
  String newStateText = "";
  // load game state
  Game game = gameController.getGame(sessionId, gameId);
  List<String> states = game.getStates();
  State oldState = stateController.getState(sessionId, gameId, states.get(states.size() - 1));
  Set<String> oldTurn = oldState.getTurn();
  // check turn 
  // if ( oldTurn.contains(userId) {}
  // load game rules
  //   rules = rulesFactory.getRules(rulesId)
  // apply move
  //   String stateText = rules.move(oldState, move)
  Set<String> newTurn = game.getUsers();
  if (newTurn.size() != 1) {
    newTurn.remove(userId);
  }
  String rulesName = game.getRules();
  if ( !rulesName.matches("[a-zA-Z]{1,16}") ) {
    throw new RulesException(rulesName);
  }
  try {
    Class<?> rules = Class.forName("scorekeep." + rulesName);
    Method moveMethod = rules.getMethod("move", String.class, String.class);
    newStateText = (String) moveMethod.invoke(null, oldState.getState(), moveText);
  } catch ( ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { throw new RulesException(rulesName); }
  // save new game state
  State newState = new State(stateId, sessionId, gameId, newStateText, newTurn);
  // send notification on game end
  if ( newStateText.startsWith("A") || newStateText.startsWith("B")) {
    Thread comm = new Thread() {
      public void run() {
        Sns.sendNotification("Scorekeep game completed", "Winner: " + userId);
      }
    };
    comm.start();
  }
  // register state and move id to game
  gameController.setGameMove(sessionId, gameId, moveId);
  gameController.setGameState(sessionId, gameId, stateId);
  moveModel.saveMove(move);
  stateModel.saveState(newState);
  return move;
}