Skip to content

Commit

Permalink
Fix internal error on Java compilation (#4668)
Browse files Browse the repository at this point in the history
  • Loading branch information
SeekingBlues committed Jan 31, 2023
1 parent a16cb5a commit 86317c7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 3 additions & 4 deletions lib/compilers/java.ts
Expand Up @@ -105,12 +105,11 @@ export class JavaCompiler extends BaseCompiler {
}),
);

const merged = {asm: [] as ParsedAsmResultLine[][]};
const merged: ParsedAsmResult = {asm: []};
for (const result of results) {
const asmBackup = merged.asm;
Object.assign(merged, result);
merged.asm = asmBackup;
merged.asm.push(result.asm);
merged.asm = [...asmBackup, ...result.asm];
}

result.asm = merged.asm;
Expand Down Expand Up @@ -241,7 +240,7 @@ export class JavaCompiler extends BaseCompiler {
}

// result.asm is an array of javap stdouts
const parseds = result.asm.map(asm => this.parseAsmForClass(asm));
const parseds = result.asm.map(asm => this.parseAsmForClass(asm.text));
// Sort class file outputs according to first source line they reference
parseds.sort((o1, o2) => o1.firstSourceLine - o2.firstSourceLine);

Expand Down
4 changes: 3 additions & 1 deletion test/java-tests.js
Expand Up @@ -113,7 +113,9 @@ describe('javap parsing', () => {
function testJava(baseFolder, ...classNames) {
const compiler = new JavaCompiler(info, env);

const asm = classNames.map(className => fs.readFileSync(`${baseFolder}/${className}.asm`).toString());
const asm = classNames.map(className => {
return {text: fs.readFileSync(`${baseFolder}/${className}.asm`).toString()};
});

const output = utils.splitLines(fs.readFileSync(`${baseFolder}/output.asm`).toString());
const expectedSegments = output.map(line => {
Expand Down

0 comments on commit 86317c7

Please sign in to comment.