Use JSpecify annotations in org.aopalliance.*

See gh-28797
This commit is contained in:
Sébastien Deleuze 2025-01-06 14:28:06 +01:00
parent e2ea87fe4f
commit 5e9b07b56d
12 changed files with 21 additions and 26 deletions

View File

@ -1,4 +1,7 @@
/**
* The core AOP Alliance advice marker.
*/
@NullMarked
package org.aopalliance.aop;
import org.jspecify.annotations.NullMarked;

View File

@ -16,8 +16,6 @@
package org.aopalliance.intercept;
import javax.annotation.Nonnull;
/**
* Intercepts the construction of a new object.
*
@ -56,7 +54,6 @@ public interface ConstructorInterceptor extends Interceptor {
* @throws Throwable if the interceptors or the target object
* throws an exception
*/
@Nonnull
Object construct(ConstructorInvocation invocation) throws Throwable;
}

View File

@ -18,8 +18,6 @@ package org.aopalliance.intercept;
import java.lang.reflect.Constructor;
import javax.annotation.Nonnull;
/**
* Description of an invocation to a constructor, given to an
* interceptor upon constructor-call.
@ -38,7 +36,6 @@ public interface ConstructorInvocation extends Invocation {
* {@link Joinpoint#getStaticPart()} method (same result).
* @return the constructor being called
*/
@Nonnull
Constructor<?> getConstructor();
}

View File

@ -16,7 +16,7 @@
package org.aopalliance.intercept;
import javax.annotation.Nonnull;
import org.jspecify.annotations.Nullable;
/**
* This interface represents an invocation in the program.
@ -34,7 +34,6 @@ public interface Invocation extends Joinpoint {
* array to change the arguments.
* @return the argument of the invocation
*/
@Nonnull
Object[] getArguments();
@Nullable Object[] getArguments();
}

View File

@ -18,8 +18,7 @@ package org.aopalliance.intercept;
import java.lang.reflect.AccessibleObject;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.jspecify.annotations.Nullable;
/**
* This interface represents a generic runtime joinpoint (in the AOP
@ -49,23 +48,20 @@ public interface Joinpoint {
* @return see the children interfaces' proceed definition
* @throws Throwable if the joinpoint throws an exception
*/
@Nullable
Object proceed() throws Throwable;
@Nullable Object proceed() throws Throwable;
/**
* Return the object that holds the current joinpoint's static part.
* <p>For instance, the target object for an invocation.
* @return the object (can be null if the accessible object is static)
*/
@Nullable
Object getThis();
@Nullable Object getThis();
/**
* Return the static part of this joinpoint.
* <p>The static part is an accessible object on which a chain of
* interceptors is installed.
*/
@Nonnull
AccessibleObject getStaticPart();
}

View File

@ -16,8 +16,7 @@
package org.aopalliance.intercept;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.jspecify.annotations.Nullable;
/**
* Intercepts calls on an interface on its way to the target. These
@ -55,7 +54,6 @@ public interface MethodInterceptor extends Interceptor {
* @throws Throwable if the interceptors or the target object
* throws an exception
*/
@Nullable
Object invoke(@Nonnull MethodInvocation invocation) throws Throwable;
@Nullable Object invoke(MethodInvocation invocation) throws Throwable;
}

View File

@ -18,8 +18,6 @@ package org.aopalliance.intercept;
import java.lang.reflect.Method;
import javax.annotation.Nonnull;
/**
* Description of an invocation to a method, given to an interceptor
* upon method-call.
@ -38,7 +36,6 @@ public interface MethodInvocation extends Invocation {
* {@link Joinpoint#getStaticPart()} method (same result).
* @return the method being called
*/
@Nonnull
Method getMethod();
}

View File

@ -1,4 +1,7 @@
/**
* The AOP Alliance reflective interception abstraction.
*/
@NullMarked
package org.aopalliance.intercept;
import org.jspecify.annotations.NullMarked;

View File

@ -1,4 +1,7 @@
/**
* Spring's variant of the AOP Alliance interfaces.
*/
@NullMarked
package org.aopalliance;
import org.jspecify.annotations.NullMarked;

View File

@ -251,7 +251,7 @@ public class CustomizableTraceInterceptor extends AbstractTraceInterceptor {
* @see #setExceptionMessage
*/
@Override
protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable {
protected @Nullable Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable {
String name = ClassUtils.getQualifiedMethodName(invocation.getMethod());
StopWatch stopWatch = new StopWatch(name);
Object returnValue = null;

View File

@ -18,6 +18,7 @@ package org.springframework.aop.interceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.apache.commons.logging.Log;
import org.jspecify.annotations.Nullable;
import org.springframework.util.StopWatch;
@ -53,7 +54,7 @@ public class PerformanceMonitorInterceptor extends AbstractMonitoringInterceptor
@Override
protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable {
protected @Nullable Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable {
String name = createInvocationTraceName(invocation);
StopWatch stopWatch = new StopWatch(name);
stopWatch.start(name);

View File

@ -18,6 +18,7 @@ package org.springframework.aop.interceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.apache.commons.logging.Log;
import org.jspecify.annotations.Nullable;
import org.springframework.util.Assert;
@ -55,7 +56,7 @@ public class SimpleTraceInterceptor extends AbstractTraceInterceptor {
@Override
protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable {
protected @Nullable Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable {
String invocationDescription = getInvocationDescription(invocation);
writeToLog(logger, "Entering " + invocationDescription);
try {