/**
   * Checks whether a to-be-created accessor doesn't conflict with the current classmodel.
   *
   * @param method virtual to-be-created accessor
   * @param errors list of error messages that is populated
   */
  private void checkVirtualAccessor(BinMethod method, List errors) {
    for (final Iterator i = hostingClass.getTypeRef().getAllSubclasses().iterator();
        i.hasNext(); ) {
      BinCIType subtype = ((BinTypeRef) i.next()).getBinCIType();
      BinMethod[] methods = subtype.getDeclaredMethods();
      for (int pos = 0, max = methods.length; pos < max; pos++) {
        BinMethod current = methods[pos];

        // FIXME: or vice-versa: method.isApplicable(current)?
        if (current.isApplicable(method)
            && method.isAccessible(hostingClass, subtype)
            && !current.isAbstract()) {
          CollectionUtil.addNew(errors, "Conflicts with the existing method '" + current + "'");
        }
      } // end for methods
    } // end for subtypes

    for (final Iterator i = hostingClass.getTypeRef().getAllSupertypes().iterator();
        i.hasNext(); ) {
      BinCIType supertype = ((BinTypeRef) i.next()).getBinCIType();
      BinMethod[] methods = supertype.getDeclaredMethods();
      for (int pos = 0, max = methods.length; pos < max; pos++) {
        BinMethod current = methods[pos];

        // FIXME: or vice-versa: method.isApplicable(current)?
        if (current.isApplicable(method)
            && current.isAccessible(supertype, hostingClass)
            && !current.isAbstract()) {
          CollectionUtil.addNew(errors, "Conflicts with the existing method '" + current + "'");
        }
      } // end for methods
    }
  }
  public void test() {
    String qName = "Test2";

    BinTypeRef ref = project.getTypeRefForName(qName);
    assertNotNull(ref);
    BinCIType type = ref.getBinCIType();

    BinMethod[] methods = type.getDeclaredMethods();
    for (int i = 0; i < methods.length; i++) {

      if (methods[i].getName().equals("main")) {
        MethodVisitor visitor = new MethodVisitor();
        methods[i].accept(visitor);

        for (int j = 0; j < visitor.METHODS.size(); j++) {

          if (((String) visitor.METHODS.get(j)).equals("target2")) {
            String retType = (String) visitor.RETTYPES.get(j);

            //            System.out.println(retType);

            assertTrue("Return type must be String, found: " + retType, retType.equals("String"));
          } else if (((String) visitor.METHODS.get(j)).equals("target")) {
            String retType = (String) visitor.RETTYPES.get(j);

            //            System.out.println(retType);

            assertTrue("Return type must be Integer, found: " + retType, retType.equals("Integer"));
          }
        }
      }
    }
  }