コード例 #1
0
 @Test(expected = NoSuchElementException.class)
 public void testHierarchyEnds() throws Exception {
   Iterator<TypeDefinition> iterator = describe(Object.class).iterator();
   assertThat(iterator.hasNext(), is(true));
   assertThat(iterator.next(), is((TypeDefinition) TypeDescription.OBJECT));
   assertThat(iterator.hasNext(), is(false));
   iterator.next();
 }
コード例 #2
0
 @Test
 public void testHierarchyIteration() throws Exception {
   Iterator<TypeDefinition> iterator = describe(Traversal.class).iterator();
   assertThat(iterator.hasNext(), is(true));
   assertThat(
       iterator.next(), is((TypeDefinition) new TypeDescription.ForLoadedType(Traversal.class)));
   assertThat(iterator.hasNext(), is(true));
   assertThat(iterator.next(), is((TypeDefinition) TypeDescription.OBJECT));
   assertThat(iterator.hasNext(), is(false));
 }
コード例 #3
0
ファイル: Transformer.java プロジェクト: miludedeng/byteman
  /**
   * constructor allowing this transformer to be provided with access to the JVM's instrumentation
   * implementation
   *
   * @param inst the instrumentation object used to interface to the JVM
   * @param scriptPaths list of file paths for each input script
   * @param scriptTexts the text of each input script
   * @param isRedefine true if class redefinition is allowed false if not
   * @throws Exception if a script is in error
   */
  public Transformer(
      Instrumentation inst, List<String> scriptPaths, List<String> scriptTexts, boolean isRedefine)
      throws Exception {
    this.inst = inst;
    this.isRedefine = isRedefine;
    scriptRepository = new ScriptRepository(skipOverrideRules);
    loadCache = new LoadCache(inst);
    helperManager = new HelperManager(inst);

    Iterator<String> scriptsIter = scriptTexts.iterator();
    Iterator<String> filesIter = scriptPaths.iterator();
    while (scriptsIter.hasNext()) {
      String scriptText = scriptsIter.next();
      String file = filesIter.next();
      List<RuleScript> ruleScripts = scriptRepository.processScripts(scriptText, file);
      for (RuleScript ruleScript : ruleScripts) {
        String name = ruleScript.getName();
        RuleScript previous = scriptRepository.scriptForRuleName(name);
        if (previous == null) {
          scriptRepository.addScript(ruleScript);
        } else {
          StringBuffer buffer = new StringBuffer();
          buffer.append("Transformer : duplicate script name ");
          buffer.append(name);
          buffer.append("in file ");
          buffer.append(ruleScript.getFile());
          buffer.append("  line ");
          buffer.append(ruleScript.getLine());
          buffer.append("\n previously defined in file ");
          buffer.append(previous.getFile());
          buffer.append("  line ");
          buffer.append(previous.getLine());
          Exception ex = new Exception(buffer.toString());
          throw ex;
        }
      }
    }
  }