5 Replies Latest reply on Jan 24, 2005 10:30 AM by Shigeru Chiba

    Limitations

    carsten r Newbie

      Hi,

      i have a question about the limitations mentioned in the tutorial on
      the javassist webpage.
      1) as javassist doesnt support synchronized statments, does this
      mean that this could cause also problems when im copying a
      method that is synchronized or contains such a block?
      2) to the statement: "Compiler may confuse if methods defined in a class
      have the same name but take different parameter lists"
      Does this mean the generated byte code may be unsattled? Or will be
      no code generated in this case?

      sincerely
      sirrurg

        • 1. Re: Limitations
          Shigeru Chiba Expert

          Hi,

          1) The limitation is not applied to copied bytecode.
          The tutorial says that the compiler does not understand
          synchronized. However, the upcoming release 3.0
          supports a synchronized statement. So please download
          CVS HEAD or wait for several days. We are going to release
          3.0 soon.

          2) For example,

          class A {}
          class B extends A {}
          class C extends C {}

          class X {
          void foo(A a) { .. }
          void foo(B b) { .. }
          }

          If the compiled expression is x.foo(new C()), where x is an instance of X, the compiler may produce a call to foo(A) although the compiler can correctly compile foo((B)new C()).

          This description will be also included in the tutorial coming
          with the next release.

          • 2. Re: Limitations
            carsten r Newbie

            1) Ok ... in this case i can surely wait, as i m just going to copy methods
            and not trying to create new ones.

            2) Thx for the example. How is the behaviour if i m performing "wrapping"
            like in
            "Java programming dynamics, Part 4: Class transformation with
            Javassist"
            by Dennis M. Sosnoski, IBM developerWorks, September 16, 2003.

            So just by copy methods, rename one and add a call like:

             ....
             newname($$);
             ....
            

            Do i also have this "drawbacks" if i m handling it this way?

            Sincerely
            Sirrurg

            P.S.: I hope this question dont become to annoying to you[/url]

            • 3. Re: Limitations
              Shigeru Chiba Expert

              Although $proceed does not imply this problem,

              newname($$);

              would do. I agree this is a bug, which should be fixed
              soon.

              • 4. Re: Limitations
                carsten r Newbie

                So to avoid this problem, i could work around by producing sth like

                ...
                newname((Type1)$1, (Type2)$2, ...)
                ...
                


                Or wouldnt this help anyway?!?

                • 5. Re: Limitations
                  Shigeru Chiba Expert

                  Yes, that's a perfect solution.
                  (sorry, it's annonying...)