Community
Participate
Working Groups
I have a "declare warning" declaration that warns on usage of any method that returns an array of any POJO type, this should point to the methods that in reality return an array, but i see warnings at points other than these array returning methods, and also those that have void in their signature. In the attached files i get a warning at statements like: > PrinterWorld p = new PrinterWorld();[in main()method] > System.out.println("Hello World!"); > return new Integer(3); and these being the first/only lines in their respective methods.
Created attachment 14156 [details] Contains all the classes to reproduce this bug
With the fix for bug 37020, the declare warning statements at least now report the correct lines (the previous behaviour was to report the line number of the first bytecodes in the body of the method), giving the output below: C:\temp\de\rohith\HelloWorld.java:4 [warning] *[] returning method called public static void main(String[] args) { ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method-execution(void de.rohith.HelloWorld.main(java.lang.String[])) see also: C:\temp\de\rohith\HelloWorldAspect.java:17 C:\temp\de\rohith\PrinterWorld.java:7 [warning] *[] returning method called public void print() { ^^^^^^^^^^^^^^^^^^^^^ method-execution(void de.rohith.PrinterWorld.print()) see also: C:\temp\de\rohith\HelloWorldAspect.java:17 C:\temp\de\rohith\PrinterWorld.java:11 [warning] *[] returning method called public Integer returnInt() { ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method-execution(java.lang.Integer de.rohith.PrinterWorld.returnInt()) see also: C:\temp\de\rohith\HelloWorldAspect.java:17 C:\temp\de\rohith\PrinterWorld.java:15 [warning] *[] returning method called public Integer[] returnArrayWithCloning() { ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method-execution(java.lang.Integer[] de.rohith.PrinterWorld.returnArrayW ithCloning()) see also: C:\temp\de\rohith\HelloWorldAspect.java:17 C:\temp\de\rohith\PrinterWorld.java:22 [warning] *[] returning method called public Integer[] returnArrayWithoutCloning() { ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method-execution(java.lang.Integer[] de.rohith.PrinterWorld.returnArrayW ithoutCloning()) see also: C:\temp\de\rohith\HelloWorldAspect.java:17 5 warnings There remains the issue that the pattern (*[]) seems to be matching any type, not any array type. I will look at this tomorrow.
Fixed in tree. Will close bug report once this fix is available in a public build. The bug involved the processing of a "*" pattern when postfixed with one or more array dimensions. Type patterns other than "*[]" were unaffected by this bug.
Fix now available from the AspectJ download page.
Fix released as part of AspectJ 1.2.1