Re: Re: What's wrong?

?? 娑???濡? <[email protected]> Fri, 02 May 2003 14:02:47 +0000
Newsgroups gmane.comp.java.aspectwerkz
Message-ID <[email protected]>
Hi Jonas:
We now take a holiday in China.So I decide to write a 
AdviseConstructorTransformer for 
aspectwerk.
When I'm looking into the source code of AdviseMemberMethodTransformer, I 
found every time AdviseMemberMethodTransformer create a new JoinPointField 
,it just add this JoinPointField to first constructor:

                addJoinPointField(cpg, cg, mg, methodSequence, 
isThreadSafe);

                methods[idxInit] = createJoinPointField(
                        cpg, cg,
                        methods[idxInit],
                        methods[i],
                        factory,
                        methodLookupId,
                        methodSequence,
                        isThreadSafe).getMethod();


So I suspect If I have two or more Constructor in one class, Code use 
second constructor will throw a NullPointerException(because joinPointField 
was not added to all constructors).

package examples.logging;

/**
 *
 */
public class Target {

    public Target() {
    }
    
    public Target(String name) {
    }
    /**
     * @attributes:method log
     */
    public void toLog1() {
        System.out.println("\tinvoking toLog1");
    }

    /**
     * @attributes:method log
     */
    public void toLog2(java.lang.String arg) {
        System.out.println("\tinvoking toLog2");
    }

    /**
     * @attributes:method log
     */
    public String toLog3() {
        System.out.println("\tinvoking toLog3");
        return "result";
    }

    public static void main(String[] args) {
        Target target = new Target("dummy");
        target.toLog1();
        target.toLog2("parameter");
        target.toLog3();
    }
}
So I change logging sample code to test it.
I add a new Constructor Target(String name)to it,and use this new 
constructor in main method,here is the result.
    [exec] parsing source files...
    [exec] meta-data for classes in 
C:\eclipse\workspace\aspectwerkz/src/samples
 have been generated to C:\eclipse\workspace\aspectwerkz/_metaData

    [exec] java.lang.NullPointerException
    [exec]      at examples.logging.Target.toLog1(Target.java)
    [exec]      at examples.logging.Target.main(Target.java:37)
    [exec] Exception in thread "main"
Do I miss something? or Is it a bug?

Best Regards
Shiyiying

_________________________________________________________________
免费下载 MSN Explorer:   http://explorer.msn.com/lccn/  



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf