Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] Aspect Weaver

All,

Per everyone's request, I have submitted a bug #46298 for tracking the
de-compiler issue with aspectj.  

In case you do not want login into the bug system, here is the test case and
the resulting output:

package com.regular;

public class ExceptionCatcher
{
	public ExceptionCatcher()
	{
		super();
	}
	
	public void catchException()
	{
		try
		{
			ExceptionThrower throwUp = new ExceptionThrower();
			throwUp.throwException();
		}
		catch(Exception e)
		{
			System.out.println("Inside my catch block");
		}
	}
	
	public static void main(String[] args)
	{
		ExceptionCatcher catcher = new ExceptionCatcher();
		catcher.catchException();	
	}
}

package com.aop;

import org.aspectj.lang.JoinPoint;

public aspect ExceptionHandler
{
	pointcut classList() : 
		within(com.regular..*);
	
	before(Throwable e) : 
		classList() 
		&& handler(*)
		&& args(e)
	{
		System.out.println("Starting before block");
		log(thisJoinPointStaticPart, e);
		System.out.println("End of before block");
	}
		
	private void log(JoinPoint.StaticPart jp, Throwable e)
	{
		System.out.println("Class Name: " +
jp.getSignature().getDeclaringType());
		System.out.println("Error Message" + e.getMessage() );
	}
}

Runing JAD:

jad ExceptionCatcher.class
Parsing ExceptionCatcher.class... Generating ExceptionCatcher.jad
Couldn't fully decompile method catchException
Couldn't resolve all exception handlers in method catchException

Now the JAD Output:

// Decompiled by Jad v1.5.7. Copyright 1997-99 Pavel Kouznetsov.
// Jad home page:
http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   ExceptionCatcher.java

package com.regular;

import com.aop.ExceptionHandler;
import com.capitalone.risk.aop.ITestInterface;
import com.capitalone.risk.aop.ITestInterfaceAspect;
import java.io.PrintStream;
import org.aspectj.runtime.reflect.Factory;

// Referenced classes of package com.regular:
//            ExceptionThrower

public class ExceptionCatcher
    implements com.aop.IntroductionPointCut.IPhilipsTarget
{

    public ExceptionCatcher()
    {
    }

    public void catchException()
    {
        if(this instanceof ITestInterface)
 
ITestInterfaceAspect.aspectOf().ajc$before$com_capitalone_risk_aop_ITestInte
rfaceAspect$113((ITestInterface)this);
        ExceptionThrower throwUp = new ExceptionThrower();
        throwUp.throwException();
        break MISSING_BLOCK_LABEL_77;
        Exception exception;
        exception;
 
ExceptionHandler.aspectOf().ajc$before$com_aop_ExceptionHandler$1f8(exceptio
n, ajc$tjp_0);
        Exception e = exception;
        System.out.println("Inside my catch block");
        break MISSING_BLOCK_LABEL_77;
        Throwable throwable;
        throwable;
        if(this instanceof ITestInterface)
 
ITestInterfaceAspect.aspectOf().ajc$after$com_capitalone_risk_aop_ITestInter
faceAspect$172((ITestInterface)this);
        throw throwable;
        if(this instanceof ITestInterface)
 
ITestInterfaceAspect.aspectOf().ajc$after$com_capitalone_risk_aop_ITestInter
faceAspect$172((ITestInterface)this);
        return;
    }

    public static void main(String args[])
    {
        ExceptionCatcher catcher = new ExceptionCatcher();
        catcher.catchException();
    }

    public static final org.aspectj.lang.JoinPoint.StaticPart ajc$tjp_0;

    static 
    {
        Factory factory = new Factory("ExceptionCatcher.java",
Class.forName("com.regular.ExceptionCatcher"));
        ajc$tjp_0 = factory.makeSJP("exception-handler",
factory.makeCatchClauseSig("0--com.regular.ExceptionCatcher-java.lang.Except
ion-<missing>-"), 33);
    }
}

The aspect class:

jad ExceptionHandler.class
Parsing ExceptionHandler.class... Generating ExceptionHandler.jad
Couldn't fully decompile method aspectOf

// Decompiled by Jad v1.5.7. Copyright 1997-99 Pavel Kouznetsov.
// Jad home page:
http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   ExceptionHandler.java

package com.aop;

import java.io.PrintStream;
import org.aspectj.lang.NoAspectBoundException;
import org.aspectj.lang.Signature;

public class ExceptionHandler
{

    public ExceptionHandler()
    {
    }

    public void ajc$before$com_aop_ExceptionHandler$1f8(Throwable e,
org.aspectj.lang.JoinPoint.StaticPart thisJoinPointStaticPart)
    {
        System.out.println("Starting before block");
        log(thisJoinPointStaticPart, e);
        System.out.println("End of before block");
    }

    private void log(org.aspectj.lang.JoinPoint.StaticPart jp, Throwable e)
    {
        System.out.println("Class Name: " +
jp.getSignature().getDeclaringType());
        System.out.println("Error Message" + e.getMessage());
    }

    public static ExceptionHandler aspectOf()
    {
        ajc$perSingletonInstance;
        JVM INSTR dup ;
        JVM INSTR ifnull 8;
           goto _L1 _L2
_L1:
        return;
_L2:
        throw new NoAspectBoundException();
    }

    public static boolean hasAspect()
    {
        return ajc$perSingletonInstance != null;
    }

    private static void ajc$postClinit()
    {
        ajc$perSingletonInstance = new ExceptionHandler();
    }

    public static final ExceptionHandler ajc$perSingletonInstance;

    static 
    {
        ajc$postClinit();
    }
}

Enjoy!

Ron

-----Original Message-----
From: Wes Isberg [mailto:wes@xxxxxxxxxxxxxx] 
Sent: Wednesday, November 05, 2003 4:22 PM
To: aspectj-users@xxxxxxxxxxx
Subject: Re: [aspectj-users] Aspect Weaver


Jim/Erik's paper describes how before advice on handler join points is
implemented.  It would be interesting to hear from the community
knowledgeable in decompilers how that could be implemented in a way that can
be decompiled to source form.  However, I don't know that this is the only
bytecode form generated by AspectJ that can't be decompiled back to Java
source.

But I hope the paper addresses most of the concerns driving people to want
to inspect woven source (which has long been deprecated as a way of
addressing questions about AspectJ).

http://dev.eclipse.org/mhonarc/lists/aspectj-dev/msg00663.html

Ron, I didn't find any bug on point.  I'd agree that we need a bug to track
the issue of generating woven source (i.e., implementing the former
-preprocess option), at least to consolidate discussion.

Wes

P.S. - We'd want to know if javap fails to dissassemble our code, but I'm
less convinced we'd work to support jad, et al.  Note there's a javap-like
disassembler accessible from LazyClassGen, but it's not generally promoted
for use outside the team.

---- Disassemble.java
import java.io.IOException;

import org.aspectj.util.LangUtil;
import org.aspectj.weaver.bcel.LazyClassGen;

public class Disassemble {
     public static void main(String[] args) throws IOException {
         if (LangUtil.isEmpty(args) || (2 != args.length)) {
             String usage = "java Disassemble {classpath} {classname}";
             System.err.println(usage);
             return;
         }
         LazyClassGen.disassemble(args[0], args[1], System.out);
     }
}

Nicholas Lesiecki wrote:

> The small test case and the decompiler output might be interesting to 
> look at. I'd suggest submitting this as a bug, but I'm not sure that 
> it's technically a bug with AspectJ. Perhaps someone on the AspectJ 
> team can comment on this issue?
> 
> Nick
> 
> 
> 
> On 11/4/03 9:32 AM, "DiFrango, Ron" <ron.difrango@xxxxxxxxxxxxxx> 
> wrote:
> 
> 
>>Nicholas/Trishan,
>>
>>While it might be possible to de-compile most aspectj weaved code, I 
>>have found instances where the de-compilers do not properly work.  The 
>>most common case where I see this not working is when you have handler 
>>advice. None of the de-comipiler I tried, and I tried everyone I could 
>>find, they produced the same output.  If you know of a de-compiler 
>>that works on this please let me know.
>>
>>If you want I can create a small test case to prove it out.  I also 
>>request this same thing as it is a nusance.  At the current time I can 
>>not find the archive on it, but I am certain I did report this.
>>
>>Thanks,
>>
>>Ron
>>
>>-----Original Message-----
>>From: Nicholas Lesiecki
>>To: aspectj-users@xxxxxxxxxxx
>>Sent: 11/4/03 12:15 AM
>>Subject: Re: [aspectj-users] Aspect Weaver
>>
>>Trishan,
>>
>>The standard solution is to use a decompiler. Several free and 
>>commercial ones are available.
>>
>>nick
>>
>>On 11/3/03 9:21 PM, "Trishan de Lanerolle" <tlanerolle@xxxxxxxxxxx>
>>wrote:
>>
>>
>>
>>Hi,
>>Thanks for the previous information on the use. One hurdle that we 
>>have come across is the changes made to version 1.1 from 1.0 where the 
>>byte code weaving was introduced.  We would like to see the weaved 
>>source code. We need to see the intermediate weaved code. Is there a 
>>command or option in 1.1.1 to do this. I am new to AspectJ and I 
>>appologise in advance if the answer is staring me in the face. If so 
>>this would eliminate a major hurdle. We are concerned about the code 
>>overhead the weaved code  adds on. Some of the project build time goes 
>>in to several hours and we hope that the introduced Aspects don't 
>>significantly add on to this.  We hope to test this out as well. Our 
>>architects want to see what effect the introduced point cuts and 
>>aspects have on the source code. Any advice would be appreciated. 
>>Thank you Trishan
>>
>>----------------------------------------------------------------------
>>--
>>------------
>>Trishan de Lanerolle
>>R&D Lead
>>AOP Research Group
>>SL ATC, Virtusa
>>www.virtusa.com <http://www.virtusa.com/>
>>tlanerolle@xxxxxxxxxxx
>>
>>The information transmitted is intended only for the person or entity 
>>to which it is addressed and may contain confidential and/or 
>>privileged material. If the reader of this message is not the intended 
>>recipient, you are hereby notified that your access is unauthorized, 
>>and any review, dissemination, distribution or copying of this message 
>>including any attachments is strictly prohibited. If you are not the 
>>intended recipient, please contact the sender and delete the material 
>>from any computer.
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>**********************************************************************
>>****
>>The information transmitted herewith is sensitive information intended
only
>>for use by the individual or entity to which it is addressed. If the
reader
>>of this message is not the intended recipient, you are hereby notified
that
>>any review, retransmission, dissemination, distribution, copying or other
>>use of, or taking of any action in reliance upon this information is
>>strictly prohibited. If you have received this communication in error,
>>please contact the sender and delete the material from your computer.
>>_______________________________________________
>>aspectj-users mailing list
>>aspectj-users@xxxxxxxxxxx
>>http://dev.eclipse.org/mailman/listinfo/aspectj-users
> 
> 
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx 
> http://dev.eclipse.org/mailman/listinfo/aspectj-users
> 

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users
 
**************************************************************************
The information transmitted herewith is sensitive information intended only
for use by the individual or entity to which it is addressed. If the reader
of this message is not the intended recipient, you are hereby notified that
any review, retransmission, dissemination, distribution, copying or other
use of, or taking of any action in reliance upon this information is
strictly prohibited. If you have received this communication in error,
please contact the sender and delete the material from your computer.


Back to the top