• Arnaud Mergey

    Arnaud Mergey - 2006-08-17

    I'have tested retroweaver and congratulation it is great !!!
    I'have a minor problem, retroweaver doesn't take care of getSimpleName java.lang.Class method.

    I propose this patch, is it correct ?

    add in com.rc.retroweaver.RetroWeaver

    else if (name.equals(GET_SIMPLE_NAME_METHOD)) {

    (private static final String GET_SIMPLE_NAME_NEW_SIGNATURE = "(Ljava/lang/Class;)Ljava/lang/String;";
    private static final String GET_SIMPLE_NAME_METHOD = "getSimpleName";)


    else if (name.equals(GET_ENUM_CONSTANTS_METHOD) && desc.equals(GET_ENUM_CONSTANTS_SIGNATURE)) {        super.visitMethodInsn(INVOKESTATIC,        CLASS_METHODS_CLASS,                name,                GET_ENUM_CONSTANTS_NEW_SIGNATURE);        return;

    and add in com.rc.retroweaver.ClassMethods

    * replacement for Class.getSimpleName()
    public static String getSimpleName(Class class_)
      if (class_.isArray())
        return getSimpleName(class_.getComponentType()) + "[]";
      String className = class_.getName();
      return className.substring(className.lastIndexOf(".") + 1);

    • Arnaud Mergey

      Arnaud Mergey - 2006-08-18

      A testcase

      public void testGetSimpleName() {
              Class cit =(new int[0]).getClass();
              Class cst =(new String[0]).getClass();
              Class cs =String.class;
              Class ct =ClassMethodsTest.class;
              assertEquals ("testGetSimpleName",cit.getSimpleName(),"int[]");
              assertEquals ("testGetSimpleName",cst.getSimpleName(),"String[]");
              assertEquals ("testGetSimpleName",cs.getSimpleName(),"String");
              assertEquals ("testGetSimpleName",ct.getSimpleName(),"ClassMethodsTest");

      • Toby Reyelts

        Toby Reyelts - 2006-08-18

        Hi Arnaud,

        We're working on releasing a new "Mirror API" for Retroweaver, which will allow people to extend Retroweaver though their own Mirror plugins.

        In this specific case, if you put your request for Class.getSimpleName() in the bug system as an RFE, we'll include it with the Mirror that we provide for Class.



Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks