5 Replies Latest reply on Feb 5, 2004 8:11 AM by bill.burke

    Some fixes and a caller side point cut question

    rythos

       

      "rythos" wrote:
      "rythos" wrote:
      The version of JBoss AOP I downloaded had a few bugs in it that appeared to need fixing. I don't know anything about how to report these, so I'll put them here.

      AspectXmlLoader.java line 370
      "group.trim().equals("")" changed to "attr.trim().equals("")"

      The following method was added to MethodHashing.java
       public static long constructorHash(CtConstructor cons)
       throws Exception
       {
       CtClass[] parameterTypes = cons.getParameterTypes();
       String consDesc = cons.getName()+"(";
       for(int j = 0; j < parameterTypes.length; j++)
       {
       consDesc += getTypeString(parameterTypes[j]);
       }
       consDesc += ")V";
      
       long hash = 0;
       ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream(512);
       MessageDigest messagedigest = MessageDigest.getInstance("SHA");
       DataOutputStream dataoutputstream = new DataOutputStream(new DigestOutputStream(bytearrayoutputstream, messagedigest));
       dataoutputstream.writeUTF(consDesc);
       dataoutputstream.flush();
       byte abyte0[] = messagedigest.digest();
       for(int j = 0; j < Math.min(8, abyte0.length); j++)
       {
       hash += (long)(abyte0[j] & 0xff) << j * 8;
       }
       return hash;
       }


      Around line 57 in CallerExprEditor.java add the following:
      long callingHash = 0;
       CtBehavior ctb = call.where();
       if( ctb instanceof CtMethod ) callingHash = MethodHashing.methodHash( ( CtMethod ) ctb );
       else callingHash = MethodHashing.constructorHash( ( CtConstructor ) ctb );


      And comment out this line:
      // long callingHash = MethodHashing.methodHash((CtMethod) call.where());


      I hope these are useful. Caused me some issues, let me tell you!

      My question is regarding the caller pointcut. I'm trying to get static information on which class and method did the calling, as well as which class and method is being called. I can't seem to find anything that works for me. In the caller-pointcut I have attributes of class="aspect.Run" and calledClass=".*", so I want it to catch every method call that aspect.Run makes.

      Thanks,
      Craig


        • 1. Re: Some fixes and a caller side point cut question
          rythos

           

          "rythos" wrote:
          "rythos" wrote:
          Here I am, replying to myself. :)

          A similar problem as the one at the top of my last message.

          AspectXmlLoader.java line 262
          "group.trim().equals("")" --> "attr.trim().equals("")"

          Are these actually bugs? Is there something that I'm missing here, and completely screwing up by "fixing" these? Is everyone that reads these as clueless on some of this stuph as I am, or are my questions not worth answering they are so trivial? :)

          Thanks,
          Craig


          • 2. Re: Some fixes and a caller side point cut question
            bill.burke

            your fixes are not correct. This is iterating over Method calls, not Constructor calls. What are you actually seeing as the problem?

            Bill

            • 3. Re: Some fixes and a caller side point cut question
              rythos

              I can't remember what problems I was having with CallerExprEditor. It gave me a ClassCastException near the beginning I think, because it was passed in a CtConstructor and you cast it to a CtMethod. The alternate solution was to return if you get a CtConstructor.

              (I imagine you discuss the other problem in a thread above, I'll go there.)

              • 4. Re: Some fixes and a caller side point cut question
                rythos

                You didn't discuss the other problem above. My bad :)

                There are about 3 places in AspectXmlLoader.java (one is line 262, others are unfortunately listed at home, not where I am) where it says group.trim().equal(""), and although I could definitely be wrong, I think it means attr.trim().equals(""). I believe there was an NPE at that point with the code as it was.

                If you have another solution, I'm all for it. There have been several times when I thought I found bugs, when really, no, I was just wrong :)

                • 5. Re: Some fixes and a caller side point cut question
                  bill.burke

                  I fixed these problems within our source control system.

                  You can access our control system here:

                  http://sourceforge.net/cvs/?group_id=22866

                  After you checkout:

                  $ cd jboss-head/aop

                  $ build.sh (or build.bat if you're on Windows)

                  $build.sh dist will build a distribution with javadoc, all jars and such.

                  Bill