From bc2440ea16f4601312a013e8cdb22ef7407a9f4d Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 24 Mar 2010 13:58:45 +0000 Subject: [PATCH] updated for JDK 1.5+ --- .../aop/aspectj/AbstractAspectJAdvice.java | 9 ++++----- .../aspectj/AspectJAfterReturningAdvice.java | 18 ++++-------------- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/org.springframework.aop/src/main/java/org/springframework/aop/aspectj/AbstractAspectJAdvice.java b/org.springframework.aop/src/main/java/org/springframework/aop/aspectj/AbstractAspectJAdvice.java index d25616741b6..e4a55a067d8 100644 --- a/org.springframework.aop/src/main/java/org/springframework/aop/aspectj/AbstractAspectJAdvice.java +++ b/org.springframework.aop/src/main/java/org/springframework/aop/aspectj/AbstractAspectJAdvice.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package org.springframework.aop.aspectj; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.lang.reflect.Type; import java.util.HashMap; import java.util.Map; @@ -139,9 +140,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence private boolean argumentsIntrospected = false; - // The actual type is java.lang.reflect.Type, - // but for JDK 1.4 compatibility we use Object as the static type. - private Object discoveredReturningGenericType; + private Type discoveredReturningGenericType; // Note: Unlike return type, no such generic information is needed for the throwing type, // since Java doesn't allow exception types to be parameterized. @@ -295,7 +294,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence return this.discoveredReturningType; } - protected Object getDiscoveredReturningGenericType() { + protected Type getDiscoveredReturningGenericType() { return this.discoveredReturningGenericType; } diff --git a/org.springframework.aop/src/main/java/org/springframework/aop/aspectj/AspectJAfterReturningAdvice.java b/org.springframework.aop/src/main/java/org/springframework/aop/aspectj/AspectJAfterReturningAdvice.java index 84bc701dd9c..2f9396c2304 100644 --- a/org.springframework.aop/src/main/java/org/springframework/aop/aspectj/AspectJAfterReturningAdvice.java +++ b/org.springframework.aop/src/main/java/org/springframework/aop/aspectj/AspectJAfterReturningAdvice.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -69,21 +69,11 @@ public class AspectJAfterReturningAdvice extends AbstractAspectJAdvice implement */ private boolean shouldInvokeOnReturnValueOf(Method method, Object returnValue) { Class type = getDiscoveredReturningType(); - Object genericType = getDiscoveredReturningGenericType(); + Type genericType = getDiscoveredReturningGenericType(); // If we aren't dealing with a raw type, check if generic parameters are assignable. return (ClassUtils.isAssignableValue(type, returnValue) && - (genericType == null || genericType == type || GenericTypeMatcher.isAssignable(genericType, method))); - } - - - /** - * Inner class to avoid a static JDK 1.5 dependency for generic type matching. - */ - private static class GenericTypeMatcher { - - public static boolean isAssignable(Object genericType, Method method) { - return TypeUtils.isAssignable((Type) genericType, method.getGenericReturnType()); - } + (genericType == null || genericType == type || + TypeUtils.isAssignable(genericType, method.getGenericReturnType()))); } }