diff -r d462da465da6 -r 7d2f628f04f1 src/share/classes/com/sun/tools/javac/tree/Pretty.java --- a/src/share/classes/com/sun/tools/javac/tree/Pretty.java Thu Jan 10 14:09:33 2013 -0800 +++ b/src/share/classes/com/sun/tools/javac/tree/Pretty.java Thu Jan 10 15:48:46 2013 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -154,12 +154,13 @@ } //we need to (i) replace all line terminators with a space and (ii) remove //occurrences of 'missing' in the Pretty output (generated when types are missing) - String res = s.toString().replaceAll("\\s+", " ").replaceAll("/\\*missing\\*/", ""); + String res = s.toString().trim().replaceAll("\\s+", " ").replaceAll("/\\*missing\\*/", ""); if (res.length() < maxLength) { return res; } else { - int split = (maxLength - trimSequence.length()) * 2 / 3; - return res.substring(0, split) + trimSequence + res.substring(split); + int head = (maxLength - trimSequence.length()) * 2 / 3; + int tail = maxLength - trimSequence.length() - head; + return res.substring(0, head) + trimSequence + res.substring(res.length() - tail); } }