5 Replies Latest reply on Jan 13, 2005 2:19 AM by panzer_kavalier

    How to modify this statement  with Javaassist?

    panzer_kavalier

      the original code:

      InputStream is = "".getClass().getResourceAsStream("/myfile");
      DataInputStream dis = new DataInputStream(is);

      or other form:
      DataInputStream dis = new DataInputStream(getClass().getResourceAsStream("/myfile");


      question:
      How can I use javaassist to modify the above bytecode to following form:

      InputStream is = MyUtil.getResourceAsStream("".getClass(), "/myfile");
      DataInputStream dis = new DataInputStream(is);

      or:
      DataInputStream dis = new DataInputStream(MyUtil.getResourceAsStream(getClass(), "/myfile");


      All in all, I want to know how can I use javasssist to change the bytecode (obj.getClass().getResourceAsStream("/file")) to
      the new bytecode : MyUtil.getResourceAsStream(obj.getClass(), "/file").


      Thanks a lot.