I have a testcase (TESTNG) looking like this:
public class Example4 {
@Test
public void testCallToReadMethods() throws IOException {
NullReader nullReader = new NullReader(10);
nullReader.read();
char[] chars ={ 'a', 'b', 'c', 'd', 'e' };
nullReader.read(chars);
nullReader.close();
}
}
It calls methods in apache commons-io:
https://commons.apache.org/proper/commons-io/javadocs/api-release/index.html
Apache Commons IO 2.6
API<https://commons.apache.org/proper/commons-io/javadocs/api-release/index.html>
This package provides a component for monitoring file system events (directory
and file create, update and delete events).
commons.apache.org
This is my simple aspect:
public aspect TypePatternsAspect {
pointcut read(): call(* org.apache.commons.io.input.NullReader.read(..));
before() : read() {
String callingClass =
thisJoinPoint.getStaticPart().getSourceLocation().getWithinType().getName();
System.out.println("Caller "+callingClass);
}
}
I can see that print is done 3 times:
Caller examples.Example4
Caller examples.Example4
Caller org.apache.commons.io.input.NullReader
Questions:
1. Does this mean that one of these reader methods call another read()
within NullReader?
2. Looking at the log below I wonder:
a) Why is AspectJ Weaver called twice?
b) What does this warning mean:
[AppClassLoader@18b4aac2] warning at
examples\C:\Users\eraonel\git\java-runtime-stats\collector\src\test\java\examples\TypePatternsAspect.aj:5::0
does not match because declaring type is java.io.Reader, if match desired use
target(org.apache.commons.io.input.NullReader) [Xlint:unmatchedSuperTypeInCall]
see also: org\testng\shaded\com\google\gson\stream\JsonReader.java:1295::0
How can I get rid of this warning?
br,
//mike
[AppClassLoader@18b4aac2] info AspectJ Weaver Version 1.9.2 built on Wednesday
Oct 24, 2018 at 15:43:33 GMT
[AppClassLoader@18b4aac2] info register classloader
sun.misc.Launcher$AppClassLoader@18b4aac2
[AppClassLoader@18b4aac2] info using configuration
/C:/Users/eraonel/git/java-runtime-stats/collector/target/test-classes/META-INF/aop3.xml
[AppClassLoader@18b4aac2] info register aspect examples.IllegalAccessAspect
[AppClassLoader@18b4aac2] info register aspect
examples.DeprecatedMethodAccessAspect
[AppClassLoader@18b4aac2] info register aspect examples.TypePatternsAspect
[RemoteTestNG] detected TestNG version 6.14.6
[ExtClassLoader@fad74ee] info AspectJ Weaver Version 1.9.2 built on Wednesday
Oct 24, 2018 at 15:43:33 GMT
[ExtClassLoader@fad74ee] info register classloader
sun.misc.Launcher$ExtClassLoader@fad74ee
[ExtClassLoader@fad74ee] info no configuration found. Disabling weaver for
class loader sun.misc.Launcher$ExtClassLoader@fad74ee
[AppClassLoader@18b4aac2] info processing reweavable type examples.Example4:
examples\Example4.java
[AppClassLoader@18b4aac2] info successfully verified type
examples.TypePatternsAspect exists. Originates from
examples\C:\Users\eraonel\git\java-runtime-stats\collector\src\test\java\examples\TypePatternsAspect.aj
[AppClassLoader@18b4aac2] weaveinfo Join point 'method-call(int
org.apache.commons.io.input.NullReader.read())' in Type 'examples.Example4'
(Example4.java:13) advised by before advice from 'examples.TypePatternsAspect'
(TypePatternsAspect.aj:7)
[AppClassLoader@18b4aac2] weaveinfo Join point 'method-call(int
org.apache.commons.io.input.NullReader.read(char[]))' in Type
'examples.Example4' (Example4.java:15) advised by before advice from
'examples.TypePatternsAspect' (TypePatternsAspect.aj:7)
[AppClassLoader@18b4aac2] warning at
examples\C:\Users\eraonel\git\java-runtime-stats\collector\src\test\java\examples\TypePatternsAspect.aj:5::0
does not match because declaring type is java.io.Reader, if match desired use
target(org.apache.commons.io.input.NullReader) [Xlint:unmatchedSuperTypeInCall]
see also: org\testng\shaded\com\google\gson\stream\JsonReader.java:1295::0
[AppClassLoader@18b4aac2] weaveinfo Join point 'method-call(int
org.apache.commons.io.input.NullReader.read(char[], int, int))' in Type
'org.apache.commons.io.input.NullReader' (NullReader.java:194) advised by
before advice from 'examples.TypePatternsAspect' (TypePatternsAspect.aj:7)
[AppClassLoader@18b4aac2] info processing reweavable type
examples.TypePatternsAspect: examples\TypePatternsAspect.aj
Called org.apache.commons.io.input.NullReader@4281a26f
Called org.apache.commons.io.input.NullReader@4281a26f
Called org.apache.commons.io.input.NullReader@4281a26f
[AppClassLoader@18b4aac2] warning at
examples\C:\Users\eraonel\git\java-runtime-stats\collector\src\test\java\examples\TypePatternsAspect.aj:5::0
does not match because declaring type is java.io.Reader, if match desired use
target(org.apache.commons.io.input.NullReader) [Xlint:unmatchedSuperTypeInCall]
see also: org\testng\reporters\FileStringBuffer.java:94::0
_______________________________________________
aspectj-users mailing list
[email protected]
To change your delivery options, retrieve your password, or unsubscribe from
this list, visit
https://www.eclipse.org/mailman/listinfo/aspectj-users