* test(go): pin JVM class files as unsupported Go images
The regression fails on main: readGoBinaryImage(javaClassFile()) reports
"Universal/fat Mach-O containers require selecting a thin slice" for a
JVM class file whose bytes 4..7 are minor/major version, not nfat_arch.
* fix(go): classify JVM class files instead of universal Mach-O
Route the four FAT magics through the shared readFatContainerHeader and
classifyFatContainerIdentity facts added for the same disambiguation in
the artifact and target lanes (921bb9575). Keep the thin-slice failure
only when the container identity is confirmed Mach-O; a JVM class file
now falls through to the generic only-ELF/PE/thin-Mach-O failure.
* test(go): pin universal Mach-O thin-slice failure with FAT fixtures
Cover the kept behavior with the repository's own fatImage/machoImage
builders (narrow and FAT64 tables) so the regression also proves real
universal containers keep the slice-selection failure.
* test(go): cover little-endian FAT magics in the universal container control
* fix(go): require positive universal Mach-O identity
Require positive Mach-O identity before reporting a universal thin-slice remedy; malformed FAT-shaped bytes are not proof. Add the JVM constant-pool CPU lookalike to the existing fixture control.
Source inspection and git diff --check; tests/builds/typechecks/CI reruns skipped at explicit user request.
* fix(go): retain malformed FAT header diagnostics
Preserve the owning FAT header parser reason for malformed headers while requiring positive Mach-O proof before the universal-slice remedy.
Source inspection and git diff --check only. Tests, builds and typechecks skipped by explicit user request. GitHub review writes paused globally.
---------
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
/** Build a valid minimal JVM class file, optionally with an unused UTF-8 constant. */
|
|
export const javaClassFile = (extraUtf8Bytes = 0, fatCpuLookalike = false): Buffer => {
|
|
const utf8 = (value: string): Buffer => {
|
|
const bytes = Buffer.from(value, "utf8");
|
|
const entry = Buffer.alloc(3 + bytes.length);
|
|
entry[0] = 1;
|
|
entry.writeUInt16BE(bytes.length, 1);
|
|
bytes.copy(entry, 3);
|
|
return entry;
|
|
};
|
|
const constants = [
|
|
Buffer.from([7, 0, 2]),
|
|
utf8("Hello"),
|
|
Buffer.from([7, 0, 4]),
|
|
utf8("java/lang/Object"),
|
|
...(fatCpuLookalike ? [utf8("x"), Buffer.from([3, 0, 0, 0, 7])] : []),
|
|
...(extraUtf8Bytes === 0 ? [] : [utf8("x".repeat(extraUtf8Bytes))]),
|
|
];
|
|
const headerAndPool = Buffer.alloc(10);
|
|
headerAndPool.writeUInt32BE(0xcafebabe, 0);
|
|
headerAndPool.writeUInt16BE(0, 4);
|
|
headerAndPool.writeUInt16BE(65, 6);
|
|
headerAndPool.writeUInt16BE(constants.length + 1, 8);
|
|
const classBody = Buffer.alloc(14);
|
|
[0x21, 1, 3, 0, 0, 0, 0].forEach((value, index) =>
|
|
classBody.writeUInt16BE(value, index * 2),
|
|
);
|
|
return Buffer.concat([headerAndPool, ...constants, classBody]);
|
|
};
|