Skip to content

Commit 87918fd

Browse files
Googlercopybara-github
authored andcommitted
[WASM] JsInterop - Handle data string encoding error on negative bytes, and correct issue with js prototype global naming.
To do this, introduce a new overload `StringUtils.escapeAsUtf8(byte)` which always masks the byte to between 0 and 255 after promoting the byte to an int. The call in BazelJ2wasmBundler already passes a byte which was previously being converted to an int between -128 to 127. PiperOrigin-RevId: 863278945
1 parent 60f9d6f commit 87918fd

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

transpiler/java/com/google/j2cl/common/StringUtils.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ public static String escapeAsUtf8(String string) {
112112
return escaped.toString();
113113
}
114114

115+
public static String escapeAsUtf8(byte b) {
116+
return escape(b & 0xFF, /* forUtf8= */ true);
117+
}
118+
115119
public static String escapeAsUtf8(int c) {
116120
return escape(c, /* forUtf8= */ true);
117121
}

transpiler/java/com/google/j2cl/transpiler/backend/wasm/WasmGenerationEnvironment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ public static boolean isJsExport(TypeDeclaration typeDeclaration) {
548548

549549
/** Returns the name of the global that stores the JS prototype for JsTypes. */
550550
public String getJsPrototypeGlobalName(TypeDeclaration typeDeclaration) {
551-
return getJsPrototypeGlobalName(typeDeclaration.getQualifiedSourceName());
551+
return getJsPrototypeGlobalName(typeDeclaration.getQualifiedJsName());
552552
}
553553

554554
/** Returns the name of the global that stores the JS prototype for JsTypes. */

0 commit comments

Comments
 (0)