Skip to content
Merged
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
4 changes: 4 additions & 0 deletions .agents/languages/java.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ Load this file when changing anything under `java/` or when Java drives a cross-
at least the requested capacity. Callers must reject invalid or overflowed requests before the
call, but must not recheck the allocator postcondition afterward; fix a violating allocator at
the allocator implementation.
- Fory JSON floating-point parsing may materialize uncommon numeric tokens for JDK conversion
when that improves measured performance. Preserve direct compact-decimal paths and JSON grammar
validation; use `Float.parseFloat` for float fallbacks to avoid double rounding. Do not restore
expensive decimal-boundary construction merely to eliminate temporary allocations.
- In JDK 25 Fory JSON C2-sensitive code, preserve measured, naturally large hot-method boundaries.
A method that exceeds HotSpot's 325-byte hot-inline limit through real representation, scalar,
array, collection, or generated-schema work is an independent subtree owner. Generated group
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1620,10 +1620,10 @@ public float[] readLatin1(Latin1JsonReader reader) {
finishPrimitiveArray(reader, 0, Float.BYTES);
return new float[0];
}
// The primitive token reader already rejects null; probing it again rescans every element.
float[] values = new float[8];
int size = 0;
do {
rejectNull(reader);
if ((size & ARRAY_BATCH_MASK) == ARRAY_BATCH_MASK) {
reader.reserveGraphMemory(ARRAY_BATCH_SIZE * Float.BYTES);
}
Expand All @@ -1633,7 +1633,7 @@ public float[] readLatin1(Latin1JsonReader reader) {
values[size++] = reader.readNextFloatValue();
} while (reader.consumeNextCommaOrEndArray());
finishPrimitiveArray(reader, size, Float.BYTES);
return Arrays.copyOf(values, size);
return size == values.length ? values : Arrays.copyOf(values, size);
}

@Override
Expand All @@ -1650,7 +1650,6 @@ public float[] readUtf16(Utf16JsonReader reader) {
float[] values = new float[8];
int size = 0;
do {
rejectNull(reader);
if ((size & ARRAY_BATCH_MASK) == ARRAY_BATCH_MASK) {
reader.reserveGraphMemory(ARRAY_BATCH_SIZE * Float.BYTES);
}
Expand All @@ -1660,7 +1659,7 @@ public float[] readUtf16(Utf16JsonReader reader) {
values[size++] = reader.readNextFloatValue();
} while (reader.consumeNextCommaOrEndArray());
finishPrimitiveArray(reader, size, Float.BYTES);
return Arrays.copyOf(values, size);
return size == values.length ? values : Arrays.copyOf(values, size);
}

@Override
Expand All @@ -1677,7 +1676,6 @@ public float[] readUtf8(Utf8JsonReader reader) {
float[] values = new float[8];
int size = 0;
do {
rejectNull(reader);
if ((size & ARRAY_BATCH_MASK) == ARRAY_BATCH_MASK) {
reader.reserveGraphMemory(ARRAY_BATCH_SIZE * Float.BYTES);
}
Expand All @@ -1687,7 +1685,7 @@ public float[] readUtf8(Utf8JsonReader reader) {
values[size++] = reader.readNextFloatValue();
} while (reader.consumeNextCommaOrEndArray());
finishPrimitiveArray(reader, size, Float.BYTES);
return Arrays.copyOf(values, size);
return size == values.length ? values : Arrays.copyOf(values, size);
}
}

Expand Down Expand Up @@ -1742,7 +1740,6 @@ public double[] readLatin1(Latin1JsonReader reader) {
double[] values = new double[8];
int size = 0;
do {
rejectNull(reader);
if ((size & ARRAY_BATCH_MASK) == ARRAY_BATCH_MASK) {
reader.reserveGraphMemory(ARRAY_BATCH_SIZE * Double.BYTES);
}
Expand All @@ -1752,7 +1749,7 @@ public double[] readLatin1(Latin1JsonReader reader) {
values[size++] = reader.readNextDoubleValue();
} while (reader.consumeNextCommaOrEndArray());
finishPrimitiveArray(reader, size, Double.BYTES);
return Arrays.copyOf(values, size);
return size == values.length ? values : Arrays.copyOf(values, size);
}

@Override
Expand All @@ -1769,7 +1766,6 @@ public double[] readUtf16(Utf16JsonReader reader) {
double[] values = new double[8];
int size = 0;
do {
rejectNull(reader);
if ((size & ARRAY_BATCH_MASK) == ARRAY_BATCH_MASK) {
reader.reserveGraphMemory(ARRAY_BATCH_SIZE * Double.BYTES);
}
Expand All @@ -1779,7 +1775,7 @@ public double[] readUtf16(Utf16JsonReader reader) {
values[size++] = reader.readNextDoubleValue();
} while (reader.consumeNextCommaOrEndArray());
finishPrimitiveArray(reader, size, Double.BYTES);
return Arrays.copyOf(values, size);
return size == values.length ? values : Arrays.copyOf(values, size);
}

@Override
Expand All @@ -1796,7 +1792,6 @@ public double[] readUtf8(Utf8JsonReader reader) {
double[] values = new double[8];
int size = 0;
do {
rejectNull(reader);
if ((size & ARRAY_BATCH_MASK) == ARRAY_BATCH_MASK) {
reader.reserveGraphMemory(ARRAY_BATCH_SIZE * Double.BYTES);
}
Expand All @@ -1806,7 +1801,7 @@ public double[] readUtf8(Utf8JsonReader reader) {
values[size++] = reader.readNextDoubleValue();
} while (reader.consumeNextCommaOrEndArray());
finishPrimitiveArray(reader, size, Double.BYTES);
return Arrays.copyOf(values, size);
return size == values.length ? values : Arrays.copyOf(values, size);
}
}

Expand Down
Loading
Loading