### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/internal/core/util/Disassembler.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Disassembler.java,v retrieving revision 1.98 diff -u -r1.98 Disassembler.java --- model/org/eclipse/jdt/internal/core/util/Disassembler.java 28 Nov 2008 10:58:08 -0000 1.98 +++ model/org/eclipse/jdt/internal/core/util/Disassembler.java 12 Aug 2009 16:35:40 -0000 @@ -158,107 +158,64 @@ }); } public static String escapeString(String s) { - StringBuffer buffer = new StringBuffer(); - for (int i = 0, max = s.length(); i < max; i++) { - char c = s.charAt(i); - switch(c) { - case '\b' : - buffer.append("\\b"); //$NON-NLS-1$ - break; - case '\t' : - buffer.append("\\t"); //$NON-NLS-1$ - break; - case '\n' : - buffer.append("\\n"); //$NON-NLS-1$ - break; - case '\f' : - buffer.append("\\f"); //$NON-NLS-1$ - break; - case '\r' : - buffer.append("\\r"); //$NON-NLS-1$ - break; - case '\0' : - buffer.append("\\0"); //$NON-NLS-1$ - break; - case '\1' : - buffer.append("\\1"); //$NON-NLS-1$ - break; - case '\2' : - buffer.append("\\2"); //$NON-NLS-1$ - break; - case '\3' : - buffer.append("\\3"); //$NON-NLS-1$ - break; - case '\4' : - buffer.append("\\4"); //$NON-NLS-1$ - break; - case '\5' : - buffer.append("\\5"); //$NON-NLS-1$ - break; - case '\6' : - buffer.append("\\6"); //$NON-NLS-1$ - break; - case '\7' : - buffer.append("\\7"); //$NON-NLS-1$ - break; - default: - buffer.append(c); - } - } - return buffer.toString(); + return decodeStringValue(s); } static String decodeStringValue(char[] chars) { StringBuffer buffer = new StringBuffer(); for (int i = 0, max = chars.length; i < max; i++) { char c = chars[i]; - switch(c) { - case '\b' : - buffer.append("\\b"); //$NON-NLS-1$ - break; - case '\t' : - buffer.append("\\t"); //$NON-NLS-1$ - break; - case '\n' : - buffer.append("\\n"); //$NON-NLS-1$ - break; - case '\f' : - buffer.append("\\f"); //$NON-NLS-1$ - break; - case '\r' : - buffer.append("\\r"); //$NON-NLS-1$ - break; - case '\0' : - buffer.append("\\0"); //$NON-NLS-1$ - break; - case '\1' : - buffer.append("\\1"); //$NON-NLS-1$ - break; - case '\2' : - buffer.append("\\2"); //$NON-NLS-1$ - break; - case '\3' : - buffer.append("\\3"); //$NON-NLS-1$ - break; - case '\4' : - buffer.append("\\4"); //$NON-NLS-1$ - break; - case '\5' : - buffer.append("\\5"); //$NON-NLS-1$ - break; - case '\6' : - buffer.append("\\6"); //$NON-NLS-1$ - break; - case '\7' : - buffer.append("\\7"); //$NON-NLS-1$ - break; - default: - buffer.append(c); - } + escapeChar(buffer, c); } return buffer.toString(); } + private static void escapeChar(StringBuffer buffer, char c) { + switch(c) { + case '\b' : + buffer.append("\\b"); //$NON-NLS-1$ + break; + case '\t' : + buffer.append("\\t"); //$NON-NLS-1$ + break; + case '\n' : + buffer.append("\\n"); //$NON-NLS-1$ + break; + case '\f' : + buffer.append("\\f"); //$NON-NLS-1$ + break; + case '\r' : + buffer.append("\\r"); //$NON-NLS-1$ + break; + case '\0' : + buffer.append("\\0"); //$NON-NLS-1$ + break; + case '\1' : + buffer.append("\\1"); //$NON-NLS-1$ + break; + case '\2' : + buffer.append("\\2"); //$NON-NLS-1$ + break; + case '\3' : + buffer.append("\\3"); //$NON-NLS-1$ + break; + case '\4' : + buffer.append("\\4"); //$NON-NLS-1$ + break; + case '\5' : + buffer.append("\\5"); //$NON-NLS-1$ + break; + case '\6' : + buffer.append("\\6"); //$NON-NLS-1$ + break; + case '\7' : + buffer.append("\\7"); //$NON-NLS-1$ + break; + default: + buffer.append(c); + } + } + static String decodeStringValue(String s) { return decodeStringValue(s.toCharArray()); } @@ -337,22 +294,26 @@ value = Double.toString(constantPoolEntry.getDoubleValue()); break; case IConstantPoolConstant.CONSTANT_Integer: + StringBuffer temp = new StringBuffer(); switch(annotationComponentValue.getTag()) { case IAnnotationComponentValue.CHAR_TAG : - value = "'" + (char) constantPoolEntry.getIntegerValue() + "'"; //$NON-NLS-1$//$NON-NLS-2$ + temp.append('\''); + escapeChar(temp, (char) constantPoolEntry.getIntegerValue()); + temp.append('\''); break; case IAnnotationComponentValue.BOOLEAN_TAG : - value = constantPoolEntry.getIntegerValue() == 1 ? "true" : "false";//$NON-NLS-1$//$NON-NLS-2$ + temp.append(constantPoolEntry.getIntegerValue() == 1 ? "true" : "false");//$NON-NLS-1$//$NON-NLS-2$ break; case IAnnotationComponentValue.BYTE_TAG : - value = "(byte) " + constantPoolEntry.getIntegerValue(); //$NON-NLS-1$ + temp.append("(byte) ").append(constantPoolEntry.getIntegerValue()); //$NON-NLS-1$ break; case IAnnotationComponentValue.SHORT_TAG : - value = "(short) " + constantPoolEntry.getIntegerValue(); //$NON-NLS-1$ + temp.append("(short) ").append(constantPoolEntry.getIntegerValue()); //$NON-NLS-1$ break; case IAnnotationComponentValue.INTEGER_TAG : - value = "(int) " + constantPoolEntry.getIntegerValue(); //$NON-NLS-1$ + temp.append("(int) ").append(constantPoolEntry.getIntegerValue()); //$NON-NLS-1$ } + value = String.valueOf(temp); break; case IConstantPoolConstant.CONSTANT_Utf8: value = "\"" + decodeStringValue(constantPoolEntry.getUtf8Value()) + "\"";//$NON-NLS-1$//$NON-NLS-2$ @@ -1836,22 +1797,26 @@ value = Double.toString(constantPoolEntry.getDoubleValue()); break; case IConstantPoolConstant.CONSTANT_Integer: + StringBuffer temp = new StringBuffer(); switch(annotationComponentValue.getTag()) { case IAnnotationComponentValue.CHAR_TAG : - value = "'" + (char) constantPoolEntry.getIntegerValue() + "'"; //$NON-NLS-1$//$NON-NLS-2$ + temp.append('\''); + escapeChar(temp, (char) constantPoolEntry.getIntegerValue()); + temp.append('\''); break; case IAnnotationComponentValue.BOOLEAN_TAG : - value = constantPoolEntry.getIntegerValue() == 1 ? "true" : "false";//$NON-NLS-1$//$NON-NLS-2$ + temp.append(constantPoolEntry.getIntegerValue() == 1 ? "true" : "false");//$NON-NLS-1$//$NON-NLS-2$ break; case IAnnotationComponentValue.BYTE_TAG : - value = "(byte) " + constantPoolEntry.getIntegerValue(); //$NON-NLS-1$ + temp.append("(byte) ").append(constantPoolEntry.getIntegerValue()); //$NON-NLS-1$ break; case IAnnotationComponentValue.SHORT_TAG : - value = "(short) " + constantPoolEntry.getIntegerValue(); //$NON-NLS-1$ + temp.append("(short) ").append(constantPoolEntry.getIntegerValue()); //$NON-NLS-1$ break; case IAnnotationComponentValue.INTEGER_TAG : - value = "(int) " + constantPoolEntry.getIntegerValue(); //$NON-NLS-1$ + temp.append("(int) ").append(constantPoolEntry.getIntegerValue()); //$NON-NLS-1$ } + value = String.valueOf(temp); break; case IConstantPoolConstant.CONSTANT_Utf8: value = "\"" + decodeStringValue(constantPoolEntry.getUtf8Value()) + "\"";//$NON-NLS-1$//$NON-NLS-2$