private void loadPropertyAnnotation ( CodeBuilder b , StorableProperty property , StorablePropertyAnnotation annotation ) { /* Example UserInfo.class.getMethod("setFirstName", new Class[] {String.class}) .getAnnotation(LengthConstraint.class) */ String methodName = annotation . getAnnotatedMethod ( ) . getName ( ) ; boolean isAccessor = ! methodName . startsWith ( "set" ) ; b . loadConstant ( TypeDesc . forClass ( property . getEnclosingType ( ) ) ) ; b . loadConstant ( methodName ) ; if ( isAccessor ) { // Accessor method has no parameters. b . loadNull ( ) ; } else { // Mutator method has one parameter. b . loadConstant ( 1 ) ; b . newObject ( TypeDesc . forClass ( Class [ ] . class ) ) ; b . dup ( ) ; b . loadConstant ( 0 ) ; b . loadConstant ( TypeDesc . forClass ( property . getType ( ) ) ) ; b . storeToArray ( TypeDesc . forClass ( Class [ ] . class ) ) ; } b . invokeVirtual ( Class . class . getName ( ) , "getMethod" , TypeDesc . forClass ( Method . class ) , new TypeDesc [ ] { TypeDesc . STRING , TypeDesc . forClass ( Class [ ] . class ) } ) ; b . loadConstant ( TypeDesc . forClass ( annotation . getAnnotationType ( ) ) ) ; b . invokeVirtual ( Method . class . getName ( ) , "getAnnotation" , TypeDesc . forClass ( Annotation . class ) , new TypeDesc [ ] { TypeDesc . forClass ( Class . class ) } ) ; b . checkCast ( TypeDesc . forClass ( annotation . getAnnotationType ( ) ) ) ; }
Generates code that loads a property annotation to the stack .