Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure identical Strings are shared #10409

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ public int compare(Object a, Object b) {
if (cons != null) {
for (var v : cons.getParameters()) {
if (tu.isSameType(eu.getTypeElement("java.lang.String").asType(), v.asType())) {
w.append(" var ").append(v.getSimpleName()).append(" = in.readUTF();\n");
w.append(" var ")
.append(v.getSimpleName())
.append(" = (java.lang.String) in.readObject();\n");
} else if (!v.asType().getKind().isPrimitive()) {
var type = tu.erasure(v.asType());
var elem = (TypeElement) tu.asElement(type);
Expand Down Expand Up @@ -241,7 +243,7 @@ public int compare(Object a, Object b) {
if (cons != null) {
for (var v : cons.getParameters()) {
if (tu.isSameType(eu.getTypeElement("java.lang.String").asType(), v.asType())) {
w.append(" out.writeUTF(obj.").append(v.getSimpleName()).append("());\n");
w.append(" out.writeObject(obj.").append(v.getSimpleName()).append("());\n");
} else if (!v.asType().getKind().isPrimitive()) {
var type = tu.erasure(v.asType());
var elem = (TypeElement) tu.asElement(type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.slf4j.Logger;

final class PerGenerator {
static final byte[] HEADER = new byte[] {0x0a, 0x0d, 0x13, 0x0f};
static final byte[] HEADER = new byte[] {0x0a, 0x0d, 0x13, 0x13};
private final OutputStream main;
private final Map<Object, WriteResult> knownObjects = new IdentityHashMap<>();
private int countReferences = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,11 @@ private InputCache(
}

final Object resolveObject(Object res) {
if (readResolve != null) {
return readResolve.apply(res);
} else {
return res;
var v = (readResolve != null) ? readResolve.apply(res) : res;
if (v instanceof String s) {
v = s.intern();
}
return v;
}

final Object getObjectAt(int at) {
Expand Down
Loading