Re: multi-constructors bug?

Jonas BonĂ©r <[email protected]> Fri, 02 May 2003 17:04:30 +0200
Newsgroups gmane.comp.java.aspectwerkz
Message-ID <[email protected]>
Regarding the multi-constructors bug see previous mail.

[email protected] wrote:
> 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 initialize JoinPointField in 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 Constructors in one class, Code use 
> second constructor will throw a NullPointerException(because 
> joinPointField was initialized in 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


-- 
Jonas
http://freeroller.net/page/jboner





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