Menu

Bug found

joyo
2002-10-17
2003-08-09
  • joyo

    joyo - 2002-10-17

    DA,
    I have tried Jarg. This application was working on simple jar.
    But I have problem on progarm as follows:

    import java.lang.reflect.Method;
    public class Test  {
    public Test()  {
      Class[] cl = { };
      Method[] mt = this.getClass().getDeclaredMethods();
      Object[] param =  { };
      for (int im=0;im<mt.length;im++)  {
       try  {
        String name = mt[im].getName();
        if (name.startsWith("init_"))  {
         mt[im].invoke(this,param);
        }
       } catch (Exception e)  {
        e.printStackTrace();
       }
      }
    }
    private void init_Hello()  {
      System.out.println("Hello Init");
    }
    public static void main(String[] args)  {
      new Test();
    }
    }

    I made the jar of the progarm and ran the Jarg. The process seemed succesfully, but "Hello Init" was never printed when program executed afterward, bacause init_Hello method was removed by Jarg.

    I used -verboseufm option on Jarg and obviously method init_Hello was removed because init_Hello was reported as unused method.

    Perhaps Jarg has to be added with -normum option for no remove unused methods.

    TY,
    joy

     
    • Nobody/Anonymous

      since you used reflection, it is by definition passing java dependency checking, why do you use reflection?

       
    • Tim Tyler

      Tim Tyler - 2003-08-09

      Some other tools cope with reflection by allowing the user to offer a list of elements which should have not have their names modified by the compression stages.

       

Log in to post a comment.