Buggy code:
public class Text extends Scrollable { char echoCharacter ; boolean ignoreChange ; String hiddenText ; int drawCount ; static final boolean IsGB18030 ; public static final int LIMIT ; public static final String DELIMITER ; public Text ( Composite parent , int style ) { } public void addModifyListener ( ModifyListener listener ) { } public void addSelectionListener ( SelectionListener listener ) { } public void addVerifyListener ( VerifyListener listener ) { } public void append ( String string ) { } static int checkStyle ( int style ) { } public void clearSelection ( ) { } public Point computeSize ( int wHint , int hHint , boolean changed ) { checkWidget ( ) ; int width = wHint ; int height = hHint ; if ( ( wHint == ( SWT . DEFAULT ) ) || ( hHint == ( SWT . DEFAULT ) ) ) { int ptr = OS . XmTextGetString ( handle ) ; if ( ptr == 0 ) return new Point ( 0 , 0 ) ; int size = OS . strlen ( ptr ) ; if ( size == 0 ) { if ( hHint == ( SWT . DEFAULT ) ) { if ( ( ( style ) & ( SWT . SINGLE ) ) != 0 ) { height = getLineHeight ( ) ; } else { height = DEFAULT_HEIGHT ; } } if ( wHint == ( SWT . DEFAULT ) ) { width = DEFAULT_WIDTH ; } } else { byte [ ] buffer = new byte [ size + 1 ] ; OS . memmove ( buffer , ptr , size ) ; boolean wrap = ( ( ( style ) & ( SWT . MULTI ) ) != 0 ) && ( ( ( style ) & ( SWT . WRAP ) ) != 0 ) ; if ( wrap && ( wHint != ( SWT . DEFAULT ) ) ) { String text = new String ( buffer ) ; String wrapped = display . wrapText ( text , font , wHint ) ; <START_BUG> buffer = wrapped . getBytes ( ) ; <END_BUG> } int xmString ; if ( ( ( style ) & ( SWT . SINGLE ) ) != 0 ) { xmString = OS . XmStringParseText ( buffer , 0 , XmFONTLIST_DEFAULT_TAG , XmCHARSET_TEXT , null , 0 , 0 ) ; } else { xmString = OS . XmStringGenerate ( buffer , XmFONTLIST_DEFAULT_TAG , XmCHARSET_TEXT , null ) ; } int fontList = font . handle ; if ( hHint == ( SWT . DEFAULT ) ) { if ( ( ( style ) & ( SWT . SINGLE ) ) != 0 ) { height = getLineHeight ( ) ; } else { height = OS . XmStringHeight ( fontList , xmString ) ; } } if ( wHint == ( SWT . DEFAULT ) ) width = OS . XmStringWidth ( fontList , xmString ) ; OS . XmStringFree ( xmString ) ; } OS . XtFree ( ptr ) ; } Rectangle trim = computeTrim ( 0 , 0 , width , height ) ; return new Point ( trim . width , trim . height ) ; } public Rectangle computeTrim ( int x , int y , int width , int height ) { } public void copy ( ) { } void createHandle ( int index ) { } ScrollBar createScrollBar ( int type ) { } void createWidget ( int index ) { } public void cut ( ) { } int defaultBackground ( ) { } Font defaultFont ( ) { } int defaultForeground ( ) { } public int getCaretLineNumber ( ) { } public Point getCaretLocation ( ) { } public int getCaretPosition ( ) { } public int getCharCount ( ) { } public boolean getDoubleClickEnabled ( ) { } public char getEchoChar ( ) { } public boolean getEditable ( ) { } public int getLineCount ( ) { } public String getLineDelimiter ( ) { } public int getLineHeight ( ) { } int getLineNumber ( int position ) { } int getNavigationType ( ) { } public int getOrientation ( ) { } public Point getSelection ( ) { } public int getSelectionCount ( ) { } public String getSelectionText ( ) { } public int getTabs ( ) { } public String getText ( ) { } public String getText ( int start , int end ) { } public int getTextLimit ( ) { } public int getTopIndex ( ) { } public int getTopPixel ( ) { } boolean hasIMSupport ( ) { } void hookEvents ( ) { } int inputContext ( ) { } public void insert ( String string ) { } void overrideTranslations ( ) { } public void paste ( ) { } void releaseWidget ( ) { } public void removeModifyListener ( ModifyListener listener ) { } public void removeSelectionListener ( SelectionListener listener ) { } public void removeVerifyListener ( VerifyListener listener ) { } boolean sendIMKeyEvent ( int type , XKeyEvent xEvent ) { } public void selectAll ( ) { } boolean setBounds ( int x , int y , int width , int height , boolean move , boolean resize ) { } public void setDoubleClickEnabled ( boolean doubleClick ) { } public void setEchoChar ( char echo ) { } public void setEditable ( boolean editable ) { } public void setOrientation ( int orientation ) { } public void setRedraw ( boolean redraw ) { } public void setSelection ( int start ) { } public void setSelection ( int start , int end ) { } public void setSelection ( Point selection ) { } public void setTabs ( int tabs ) { } public void setText ( String string ) { } public void setTextLimit ( int limit ) { }

Fix:
buffer = Converter . wcsToMbcs ( getCodePage ( ) , wrapped , true ) ;