11 Replies Latest reply on Mar 1, 2004 7:23 AM by julien1

    Debugging with Javassist

    hlship

      My users (of Tapestry and of HiveMind) are concerned with debugging when Javassist is added to the mix.

      They want the ability to step into and through generated methods.

      Is there a way this could be accomplished? Could the method body be written to a file, and the necessary classfile stuff be created to display the content from the file in the debugger?

        • 1. Re: Debugging with Javassist
          chiba

          As you might know, CtClass#writeFile() dumps
          the contents of the class file. If you want to
          do source-level debugging with the code generated
          by Javassist, I have to extend Javassist a bit.

          What kind of source-level debugging do your users
          want? Do they want to see inserted code or newly
          created class?

          • 2. Re: Debugging with Javassist
            hlship

            As an example, what would be nice if Javassist would write the code-markup text to a temporary file and add line number information for its code that pointed to that file, so that a debugger (such as Eclipse) could step through the "source".

            Currently, when users step into a method dynamically generated using Javassist, they get pretty much nothing ... there's no source to see!

            The advantage of Javassist, that the markup text you write is very close to Java language, should be exploited for this purpose.

            • 3. Re: Debugging with Javassist
              hlship

              Oh ... and both Tapestry and HiveMind don't modify existing sources, they always create new classes entirely (often as enhanced subclasses of existing, user-provided classes). I can see that trying to do what I suggest for full-bore AOP would be a great challenge, but for new classes created from "whole cloth", I think it is approachable (but should be an runtime selectable option).

              • 4. Re: Debugging with Javassist
                chiba

                OK, that's a good (and reasonable) suggestion.
                Although I would not be able to implement it
                very soon, I definitely put this to my Todo list.

                • 5. Re: Debugging with Javassist
                  bill.burke

                  We need some recruits for Javassist. With JDK 1.5 coming up you're gonna need it.

                  Bill

                  • 6. Re: Debugging with Javassist
                    chiba

                    For meta data and generics?
                    Yes.

                    • 7. Re: Debugging with Javassist
                      kevinconner

                      I'm in the middle of the annotation stuff for the meta data. There's not that much more to do but I've been finding it hard to fit it in over the last week.

                      • 8. Re: Debugging with Javassist
                        kevinconner

                        Sorry, forgot to add that I'm not looking at the compiler part yet, just the class info side of things.

                        • 9. Re: Debugging with Javassist
                          bill.burke

                          Kevin, chiba means for metadata and generics for JDK 1.5. FYI, all, Kevin is working on an doclet tag -> attribute compiler. TO put doclet tags into .class files. A.K.A jsr-175 for JDK 1.4 and lower.

                          • 10. Re: Debugging with Javassist
                            kevinconner

                            Hiya Bill.

                            Yep, I know. I was just letting him know that I am already working on some changes to javassist to support the metadata attributes in the class info stuff.

                            I was originally wrapping the javassist classes but decided that it made more sense to do it properly and add the support for this directly into the javassist code.

                            Kev

                            • 11. Re: Debugging with Javassist

                              Bill, Kevin, you may want to look at this project :

                              http://attrib4j.sourceforge.net/index.html