public void addPush ( String k ) { int length = k . length ( ) ; int limit = itsConstantPool . getUtfEncodingLimit ( k , 0 , length ) ; if ( limit == length ) { addLoadConstant ( k ) ; return ; } // Split string into picies fitting the UTF limit and generate code for // StringBuilder sb = new StringBuilder(length); // sb.append(loadConstant(piece_1)); // ... // sb.append(loadConstant(piece_N)); // sb.toString(); final String SB = "java/lang/StringBuilder" ; add ( ByteCode . NEW , SB ) ; add ( ByteCode . DUP ) ; addPush ( length ) ; addInvoke ( ByteCode . INVOKESPECIAL , SB , "<init>" , "(I)V" ) ; int cursor = 0 ; for ( ; ; ) { add ( ByteCode . DUP ) ; String s = k . substring ( cursor , limit ) ; addLoadConstant ( s ) ; addInvoke ( ByteCode . INVOKEVIRTUAL , SB , "append" , "(Ljava/lang/String;)Ljava/lang/StringBuilder;" ) ; add ( ByteCode . POP ) ; if ( limit == length ) { break ; } cursor = limit ; limit = itsConstantPool . getUtfEncodingLimit ( k , limit , length ) ; } addInvoke ( ByteCode . INVOKEVIRTUAL , SB , "toString" , "()Ljava/lang/String;" ) ; }
Generate the code to leave on stack the given string even if the string encoding exeeds the class file limit for single string constant