Prior to this commit, the getValue(Annotation, String) method in AnnotationUtils failed to retrieve the value of the desired annotation attribute if the annotation itself was not public -- for example if the annotation was declared as package private. This commit addresses this issue by ensuring that getValue(Annotation, String) uses reflection to make the desired annotation attribute method accessible before attempting to invoke it to retrieve the value. Issue: SPR-11104master
parent
45afd4fbe2
commit
b830d7362d
4 changed files with 101 additions and 15 deletions
@ -0,0 +1,28 @@ |
||||
/* |
||||
* Copyright 2002-2013 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. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.core.annotation.subpackage; |
||||
|
||||
/** |
||||
* Class annotated with a non-public (i.e., package private) custom annotation. |
||||
* |
||||
* @author Sam Brannen |
||||
* @since 4.0 |
||||
*/ |
||||
@NonPublicAnnotation(42) |
||||
public class NonPublicAnnotatedClass { |
||||
|
||||
} |
@ -0,0 +1,32 @@ |
||||
/* |
||||
* Copyright 2002-2013 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. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.core.annotation.subpackage; |
||||
|
||||
import java.lang.annotation.Retention; |
||||
import java.lang.annotation.RetentionPolicy; |
||||
|
||||
/** |
||||
* Non-public (i.e., package private) custom annotation. |
||||
* |
||||
* @author Sam Brannen |
||||
* @since 4.0 |
||||
*/ |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@interface NonPublicAnnotation { |
||||
|
||||
int value() default -1; |
||||
} |
Loading…
Reference in new issue