import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType; 
import java.lang.annotation.Retention; 
import java.lang.annotation.RetentionPolicy; 
import java.lang.annotation.Target; 
import java.lang.reflect.AnnotatedTypeVariable; 
import java.lang.reflect.Method; 
import java.lang.reflect.TypeVariable; 

public class AnnotatedBoundTest {
	@Retention(RetentionPolicy.RUNTIME) 
	@Target(ElementType.TYPE_USE) 
	@interface A1 { 
	} 

	@Retention(RetentionPolicy.RUNTIME) 
	@Target(ElementType.TYPE_USE) 
	@interface A2 { 
	} 

	@Retention(RetentionPolicy.RUNTIME) 
	@Target(ElementType.TYPE_USE) 
	@interface A3 { 
	} 

	public class SomeClass<T> { 
		<@A1 S extends @A2 T> @A3 S myMethod() { return null;} 
	} 


	public static void main(String[] args) throws NoSuchMethodException { 
		Method myMethod = SomeClass.class.getDeclaredMethod("myMethod"); 
		Annotation[] annotations = ((TypeVariable) ((TypeVariable) myMethod.getGenericReturnType()).getBounds()[0]).getAnnotations(); 
		Annotation[] annotations2 = ((AnnotatedTypeVariable) myMethod.getAnnotatedReturnType()).getAnnotatedBounds()[0].getAnnotations(); 
		assert annotations.length == 1; 
		assert annotations2.length == 1; 
	} 
}
