| Summary: | AspectJ should by default ignore methods with a "synthetic" modifier label or the method modifier pattern should support it. | ||
|---|---|---|---|
| Product: | [Tools] AspectJ | Reporter: | William Louth <william.louth> |
| Component: | LTWeaving | Assignee: | aspectj inbox <aspectj-inbox> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | aclement |
| Version: | unspecified | ||
| Target Milestone: | 1.6.12 | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
Fixed. You can now exclude them with 'synthetic' as a modifier. Whether to weave them at all is a bigger discussion. This will also only work on Java 1.5 built code - because at the 1.4 level synthetic was not stored as a bit in the modifiers flag it was an attribute on the method. I don't plan (until there is a need) to do the necessary mucking about to allow for the attribute form of synthetic. Hope this change is good enough for you for now. |
It looks like ModifiersPattern class needs to be updated to support exclusion of synthetic methods in pointcuts though I would question why by default AspectJ allows such methods to be instrumented in the first place. It would probably be better to disable this and have an X flag to enable it in the exclusion set. If not can we have the code below updated to allow "synthetic" to be specified in particular "!synthetic" in a point cut. Today it does not work because of a parser exception caused by it not being in the map below. static { modifierFlags = new HashMap<String, Integer>(); int flag = 1; while (flag <= Modifier.STRICT) { String flagName = Modifier.toString(flag); modifierFlags.put(flagName, new Integer(flag)); flag = flag << 1; } } public static final int STRICT = 0x00000800; // Bits not (yet) exposed in the public API either because they // have different meanings for fields and methods and there is no // way to distinguish between the two in this class, or because // they are not Java programming language keywords static final int BRIDGE = 0x00000040; static final int VARARGS = 0x00000080; static final int SYNTHETIC = 0x00001000; static final int ANNOTATION= 0x00002000; static final int ENUM = 0x00004000; static boolean isSynthetic(int mod) { return (mod & SYNTHETIC) != 0; }