mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
java: correct character escaping in decompiler
This commit is contained in:
@@ -707,7 +707,7 @@ public class StubBuildingVisitor<T> extends ClassVisitor {
|
||||
}
|
||||
|
||||
if (value instanceof Character) {
|
||||
return "'" + value.toString() + "'";
|
||||
return "'" + StringUtil.escapeCharCharacters(value.toString()) + "'";
|
||||
}
|
||||
|
||||
if (value instanceof Long) {
|
||||
@@ -720,7 +720,8 @@ public class StubBuildingVisitor<T> extends ClassVisitor {
|
||||
if (value.equals(1)) return "true";
|
||||
}
|
||||
if ("char".equals(type)) {
|
||||
return "'" + ((char)((Integer)value).intValue()) + "'";
|
||||
char ch = (char)((Integer)value).intValue();
|
||||
return "'" + StringUtil.escapeCharCharacters(String.valueOf(ch)) + "'";
|
||||
}
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ class Primitives {
|
||||
public static final boolean TRUE = true;
|
||||
public static final boolean FALSE = false;
|
||||
public static final byte BYTE = 1;
|
||||
public static final char CHAR = 'c';
|
||||
public static final char CHAR = '\'';
|
||||
public static final short SHORT = 42;
|
||||
public static final int INT = 42;
|
||||
public static final long LONG = 42L;
|
||||
@@ -22,7 +22,7 @@ class Primitives {
|
||||
public static boolean FALSE() { /* compiled code */ }
|
||||
|
||||
@pkg.ByteAnno(1)
|
||||
@pkg.CharAnno('c')
|
||||
@pkg.CharAnno('\\')
|
||||
@pkg.ShortAnno(42)
|
||||
@pkg.IntAnno(42)
|
||||
@pkg.LongAnno(42L)
|
||||
|
||||
Binary file not shown.
@@ -8,12 +8,12 @@ class Primitives {
|
||||
@BooleanAnno(false) public static boolean FALSE() { return FALSE; }
|
||||
|
||||
public static final byte BYTE = 1;
|
||||
public static final char CHAR = 'c';
|
||||
public static final char CHAR = '\'';
|
||||
public static final short SHORT = 42;
|
||||
public static final int INT = 42;
|
||||
public static final long LONG = 42L;
|
||||
|
||||
@ByteAnno(1) @CharAnno('c') @ShortAnno(42) @IntAnno(42) @LongAnno(42L)
|
||||
@ByteAnno(1) @CharAnno('\\') @ShortAnno(42) @IntAnno(42) @LongAnno(42L)
|
||||
public static void m() { }
|
||||
}
|
||||
|
||||
|
||||
@@ -536,10 +536,16 @@ public class StringUtil extends StringUtilRt {
|
||||
@NotNull
|
||||
public static String escapeStringCharacters(@NotNull String s) {
|
||||
StringBuilder buffer = new StringBuilder(s.length());
|
||||
escapeStringCharacters(s.length(), s, buffer);
|
||||
escapeStringCharacters(s.length(), s, "\"", buffer);
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String escapeCharCharacters(@NotNull String s) {
|
||||
StringBuilder buffer = new StringBuilder(s.length());
|
||||
escapeStringCharacters(s.length(), s, "\'", buffer);
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String unescapeStringCharacters(@NotNull String s) {
|
||||
|
||||
Reference in New Issue
Block a user