@@ -1535,31 +1535,31 @@ AspectJ APIs refer to parameter names as argument names.
1535
1535
Spring AOP uses the following `ParameterNameDiscoverer` implementations to determine
1536
1536
parameter names. Each discoverer will be given a chance to discover parameter names, and
1537
1537
the first successful discoverer wins. If none of the registered discoverers is capable
1538
- of determining parameter names, an `IllegalArgumentException` is thrown.
1538
+ of determining parameter names, an exception will be thrown.
1539
1539
1540
-
1541
- `KotlinReflectionParameterNameDiscoverer` :: Uses Kotlin reflection APIs if such APIs are
1542
- present on the classpath.
1543
- `StandardReflectionParameterNameDiscoverer` :: Uses the `java.lang.reflect.Parameter` API
1544
- available since Java 8. Requires that code be compiled with the `-parameters` flag for
1545
- `javac`. Recommended approach on Java 8+.
1546
- `LocalVariableTableParameterNameDiscoverer` :: Analyzes the local variable table available
1547
- in the byte code to determine parameter names from debug information. Requires that
1548
- code be compiled with debug symbols (`-g:vars` at a minimum). Deprecated as of Spring
1549
- Framework 6.0 for removal in Spring Framework 6.1 in favor of compiling code with
1550
- `-parameters`. Not supported in a GraalVM native image.
1551
- `AspectJAdviceParameterNameDiscoverer` :: Uses parameter names that have been explicitly
1540
+ `AspectJAnnotationParameterNameDiscoverer` :: Uses parameter names that have been explicitly
1552
1541
specified by the user via the `argNames` attribute in the corresponding advice or
1553
- pointcut annotation. See the following section for details.
1542
+ pointcut annotation. See <<aop-ataspectj-advice-params-names-explicit>> for details.
1543
+ `KotlinReflectionParameterNameDiscoverer` :: Uses Kotlin reflection APIs to determine
1544
+ parameter names. This discoverer is only used if such APIs are present on the classpath.
1545
+ `StandardReflectionParameterNameDiscoverer` :: Uses the standard `java.lang.reflect.Parameter`
1546
+ API to determine parameter names. Requires that code be compiled with the `-parameters`
1547
+ flag for `javac`. Recommended approach on Java 8+.
1548
+ `LocalVariableTableParameterNameDiscoverer` :: Analyzes the local variable table available
1549
+ in the byte code of the advice class to determine parameter names from debug information.
1550
+ Requires that code be compiled with debug symbols (`-g:vars` at a minimum). Deprecated
1551
+ as of Spring Framework 6.0 for removal in Spring Framework 6.1 in favor of compiling
1552
+ code with `-parameters`. Not supported in a GraalVM native image.
1553
+ `AspectJAdviceParameterNameDiscoverer` :: Deduces parameter names from the pointcut
1554
+ expression, `returning`, and `throwing` clauses. See the
1555
+ {api-spring-framework}/aop/aspectj/AspectJAdviceParameterNameDiscoverer.html[javadoc]
1556
+ for details on the algorithm used.
1554
1557
1555
1558
[[aop-ataspectj-advice-params-names-explicit]]
1556
1559
===== Explicit Argument Names
1557
1560
1558
1561
@AspectJ advice and pointcut annotations have an optional `argNames` attribute that you
1559
- can use to specify the argument names of the annotated method. Note, however, that
1560
- explicit `argNames` will only be used by Spring as a fallback if none of the other
1561
- `ParameterNameDiscoverer` implementations is able to determine parameter names (see the
1562
- previous section for details).
1562
+ can use to specify the argument names of the annotated method.
1563
1563
1564
1564
[TIP]
1565
1565
====
@@ -1579,26 +1579,28 @@ The following example shows how to use the `argNames` attribute:
1579
1579
----
1580
1580
@Before(
1581
1581
value = "com.xyz.Pointcuts.publicMethod() && target(bean) && @annotation(auditable)", // <1>
1582
- argNames = "bean,auditable")
1582
+ argNames = "bean,auditable") // <2>
1583
1583
public void audit(Object bean, Auditable auditable) {
1584
1584
AuditCode code = auditable.value();
1585
1585
// ... use code and bean
1586
1586
}
1587
1587
----
1588
1588
<1> References the `publicMethod` named pointcut defined in <<aop-pointcuts-combining>>.
1589
+ <2> Declares `bean` and `auditable` as the argument names.
1589
1590
1590
1591
[source,kotlin,indent=0,subs="verbatim",role="secondary"]
1591
1592
.Kotlin
1592
1593
----
1593
1594
@Before(
1594
1595
value = "com.xyz.Pointcuts.publicMethod() && target(bean) && @annotation(auditable)", // <1>
1595
- argNames = "bean,auditable")
1596
+ argNames = "bean,auditable") // <2>
1596
1597
fun audit(bean: Any, auditable: Auditable) {
1597
1598
val code = auditable.value()
1598
1599
// ... use code and bean
1599
1600
}
1600
1601
----
1601
1602
<1> References the `publicMethod` named pointcut defined in <<aop-pointcuts-combining>>.
1603
+ <2> Declares `bean` and `auditable` as the argument names.
1602
1604
1603
1605
If the first parameter is of type `JoinPoint`, `ProceedingJoinPoint`, or
1604
1606
`JoinPoint.StaticPart`, you can omit the name of the parameter from the value of the
@@ -1610,32 +1612,34 @@ point object, the `argNames` attribute does not need to include it:
1610
1612
----
1611
1613
@Before(
1612
1614
value = "com.xyz.Pointcuts.publicMethod() && target(bean) && @annotation(auditable)", // <1>
1613
- argNames = "bean,auditable")
1615
+ argNames = "bean,auditable") // <2>
1614
1616
public void audit(JoinPoint jp, Object bean, Auditable auditable) {
1615
1617
AuditCode code = auditable.value();
1616
1618
// ... use code, bean, and jp
1617
1619
}
1618
1620
----
1619
1621
<1> References the `publicMethod` named pointcut defined in <<aop-pointcuts-combining>>.
1622
+ <2> Declares `bean` and `auditable` as the argument names.
1620
1623
1621
1624
[source,kotlin,indent=0,subs="verbatim",role="secondary"]
1622
1625
.Kotlin
1623
1626
----
1624
1627
@Before(
1625
1628
value = "com.xyz.Pointcuts.publicMethod() && target(bean) && @annotation(auditable)", // <1>
1626
- argNames = "bean,auditable")
1629
+ argNames = "bean,auditable") // <2>
1627
1630
fun audit(jp: JoinPoint, bean: Any, auditable: Auditable) {
1628
1631
val code = auditable.value()
1629
1632
// ... use code, bean, and jp
1630
1633
}
1631
1634
----
1632
1635
<1> References the `publicMethod` named pointcut defined in <<aop-pointcuts-combining>>.
1636
+ <2> Declares `bean` and `auditable` as the argument names.
1633
1637
1634
- The special treatment given to the first parameter of the `JoinPoint`,
1635
- `ProceedingJoinPoint`, and `JoinPoint.StaticPart` types is particularly convenient for
1636
- advice instances that do not collect any other join point context. In such situations,
1637
- you may omit the `argNames` attribute. For example, the following advice does not need to
1638
- declare the `argNames` attribute:
1638
+ The special treatment given to the first parameter of type `JoinPoint`,
1639
+ `ProceedingJoinPoint`, or `JoinPoint.StaticPart` is particularly convenient for advice
1640
+ methods that do not collect any other join point context. In such situations, you may
1641
+ omit the `argNames` attribute. For example, the following advice does not need to declare
1642
+ the `argNames` attribute:
1639
1643
1640
1644
[source,java,indent=0,subs="verbatim",role="primary"]
1641
1645
.Java
0 commit comments