public static void throwConcatException ( CodeBuilder b , Class type , String ... messages ) { if ( messages == null || messages . length == 0 ) { throwException ( b , type , null ) ; return ; } if ( messages . length == 1 ) { throwException ( b , type , messages [ 0 ] ) ; return ; } TypeDesc desc = TypeDesc . forClass ( type ) ; b . newObject ( desc ) ; b . dup ( ) ; TypeDesc [ ] params = new TypeDesc [ ] { TypeDesc . STRING } ; for ( int i = 0 ; i < messages . length ; i ++ ) { b . loadConstant ( String . valueOf ( messages [ i ] ) ) ; if ( i > 0 ) { b . invokeVirtual ( TypeDesc . STRING , "concat" , TypeDesc . STRING , params ) ; } } b . invokeConstructor ( desc , params ) ; b . throwObject ( ) ; }
Generate code to throw an exception with a message concatenated at runtime .