RE: anything wrong?- beginner problem

"Zhang Weishan" <[email protected]> Sun, 4 May 2003 23:01:22 +0800
Newsgroups gmane.comp.java.aspectwerkz
Message-ID <[email protected]>
Hi Jonas,
   Thank you!
   I am hoping the next release comes out asap.
   Cheers,
   weishan


-----Original Message-----
From: Jonas Bon=E9r [mailto:[email protected]]=20
Sent: Sunday, May 04, 2003 10:52 PM
To: Zhang Weishan
Cc: [email protected]
Subject: Re: [aspectwerkz-developer] anything wrong?- beginner problem


Hi Weishan.

* I can't eliminate the case sensitivity, since methods in Java with=20
different cases are considered to be different methods.
E.g. void NewFile() is *not* the same method as void newFile().

* The problem with private methods is a known bug that *is* fixed and=20
will be patched in the next release. Sorry about that :-(

- Jonas

Zhang Weishan wrote:
> Hi Jonas,
>   Thank you!
>   Is it a bit more convenient to eliminate the case sensitive issue?=20
>   Sorry there was another error message and it seems that it could not =

> access private method:
>  =20
> C:\aspectwerkz>aspectwerkz -cp=20
> test/notepad.jar;lib/commons-collections-2.1.jar
> -Daspectwerkz.definition.file=3Dtest/samples.xml =
-Daspectwerkz.metadata.dir=3D./ Notepad
> --> Notepad::NewFile
> java.lang.IllegalAccessException: Class=20
> aspectwerkz.joinpoint.MemberMethodJoinPo
> int can not access a member of class Notepad with modifiers "private"
>         at =
sun.reflect.Reflection.ensureMemberAccess(Reflection.java:57)
>         at java.lang.reflect.Method.invoke(Method.java:317)
>         at =
aspectwerkz.joinpoint.MemberMethodJoinPoint.proceed(MemberMethodJoinP
> oint.java:92)
>         at LoggingAdvice.execute(loggingadvice.java:23)
>         at =
aspectwerkz.advice.MethodAdvice.doExecute(MethodAdvice.java:74)
>         at =
aspectwerkz.joinpoint.MemberMethodJoinPoint.proceed(MemberMethodJoinP
> oint.java:103)
>         at Notepad.NewFile(Notepad.java)
>         at Notepad.access$000(Notepad.java:63)
>         at Notepad$1.actionPerformed(Notepad.java:175)
>         at =
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:17
> 64)
> .....
>=20
> cheers,
> Weishan
>=20
>=20
>=20
>=20
> -----Original Message-----
> From: Jonas Bon=E9r [mailto:[email protected]]
> Sent: Saturday, May 03, 2003 9:05 PM
> To: Zhang Weishan
> Cc: [email protected]
> Subject: Re: [aspectwerkz-developer] anything wrong?- beginner problem
>=20
> Hi Weishan.
>=20
> Thanks a lot for helping me catch a nasty bug :-) :
>=20
> it is (in the 0.4 release) not possible to define a pointcut that=20
> picks
> out *both* static and member methods; creates errors like the one =
below.
> This has now been fixed and I will commit it to the CVS among with the =

> other stuff I am working on soon.
>=20
> Back to your example: the pointcut selection is *case-sensitive* so=20
> you
> have to use "N.*" if you want to advise the NewFile method.
> And until the bug is patched, don't mix static and member methods in =
the=20
> pointcuts.
>=20
> Sorry for this.
>=20
> - Jonas
>=20
>=20
>=20
> Zhang Weishan wrote:
>=20
>>Hi,
>>  There is method named NewFile(), and if you use ".*", an error is=20
>>throwed:
>>  C:\aspectwerkz>aspectwerkz -cp =
test/notepad.jar;lib/commons-collections-2.1.jar
>>-Daspectwerkz.definition.file=3Dtest/samples.xml =
-Daspectwerkz.metadata.dir=3D_metaD
>>ata Notepad
>>java.lang.Error: should be unreachable
>>        at =
aspectwerkz.MethodComparator.comparePrefixed(MethodComparator.java:14
>>4)
>>        at =
aspectwerkz.MethodComparator.compare(MethodComparator.java:68)
>>        at java.util.Arrays.mergeSort(Arrays.java:1237)
>>        at java.util.Arrays.mergeSort(Arrays.java:1244)
>>        at java.util.Arrays.mergeSort(Arrays.java:1245)
>>        at java.util.Arrays.sort(Arrays.java:1185)
>>        at java.util.Collections.sort(Collections.java:151)
>>        at =
aspectwerkz.AspectWerkz.createMethodRepository(AspectWerkz.java:437)
>>        at aspectwerkz.AspectWerkz.loadMethods(AspectWerkz.java:416)
>>        at aspectwerkz.AspectWerkz.initialize(AspectWerkz.java:386)
>>        at =
aspectwerkz.joinpoint.MethodJoinPoint.<init>(MethodJoinPoint.java:62)
>>
>>        at=20
>>aspectwerkz.joinpoint.StaticMethodJoinPoint.<init>(StaticMethodJoinPo
>>int.java:48)
>>        at Notepad.main(Notepad.java)
>>Exception in thread "main"
>>
>>Thanks,
>>Weishan
>>
>>
>>
>>
>>-----Original Message-----
>>From: Jonas Bon=E9r [mailto:[email protected]]
>>Sent: Saturday, May 03, 2003 6:43 PM
>>To: Zhang Weishan
>>Cc: [email protected]
>>Subject: Re: [aspectwerkz-developer] anything wrong?- beginner problem
>>
>>Hi.
>>
>>Which method/methods are you trying to advise?
>>
>>When I look at your Notepad.java I can't see any methods named=20
>>something
>>starting with the letter n. If you want to log all methods in the =
class=20
>>use: .*
>>
>>- Jonas
>>
>>Zhang Weishan wrote:
>>
>>
>>>Hello everyone,
>>>
>>> I tried to run the simple logging advice with a Notepad example, but =

>>>I
>>>was in trouble. All the used files, including the xml definition =
file,=20
>>>compiled and source logging advice, compiled and source Notepad =
reside=20
>>>in one directory named test. I jar the complied logging advice and=20
>>>Notepad into a notepad.jar.
>>>
>>> The logging advice which is almost the same as the original one, the
>>>only difference is that I removed the package declaration to make =
life=20
>>>easier.
>>>
>>> Here is the xml definition file which resides:
>>>
>>><aspectwerkz>
>>>
>>>   <advice name=3D"xmt"
>>>
>>>       advice=3D"LoggingAdvice"
>>>
>>>       deploymentModel=3D"perClass"/>
>>>
>>>
>>>
>>>   <aspect class=3D"Notepad">
>>>
>>>       <pointcut type=3D"method" pattern=3D"n.*">
>>>
>>>           <advice-ref name=3D"xmt"/>
>>>
>>>       </pointcut>
>>>
>>>   </aspect>
>>>
>>>
>>>
>>> Here is the command I used to invoke the framework.
>>>
>>>C:\aspectwerkz>aspectwerkz -cp
>>>test/notepad.jar;lib/commons-collections-2.1.jar
>>>
>>>-Daspectwerkz.definition.file=3Dtest/samples.xml
>>>-Daspectwerkz.metadata.dir=3D_metaD
>>>
>>>ata Notepad
>>>
>>>
>>>
>>>The notepad runs but there is no logging info displayed in the=20
>>>console.
>>>No matter what the method pattern, for example, set.*, n.*, it simply =

>>>did not work.
>>>
>>>
>>>
>>>Thanks,
>>>
>>>Weishan
>>>
>>>
>>>
>>
>>
>>
>=20
>=20


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





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