CODETOOLS-7902316 jdis ignores exception_table entries and uses a wrong format for iinc_w instruction

This commit is contained in:
lkuskov 2018-09-24 13:04:04 -07:00
parent 03e78467ae
commit 6050467685
2 changed files with 20 additions and 14 deletions

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -156,7 +156,7 @@ public class CodeData {
} }
protected iAtt get_iAtt(int pc) { protected iAtt get_iAtt(int pc) {
Integer PC = new Integer(pc); Integer PC = pc;
iAtt res = iattrs.get(PC); iAtt res = iattrs.get(PC);
if (res == null) { if (res == null) {
res = new iAtt(this); res = new iAtt(this);
@ -365,7 +365,7 @@ public class CodeData {
} }
} }
private void loadLocVarTable() throws IOException { private void loadLocVarTable() {
for (LocVarData entry : loc_var_tb) { for (LocVarData entry : loc_var_tb) {
get_iAtt(entry.start_pc).add_var(entry); get_iAtt(entry.start_pc).add_var(entry);
get_iAtt(entry.start_pc + entry.length).add_endvar(entry); get_iAtt(entry.start_pc + entry.length).add_endvar(entry);
@ -388,7 +388,7 @@ public class CodeData {
cls.pool.PrintConstant(out, cpx); cls.pool.PrintConstant(out, cpx);
} }
private int printInstr(int pc) throws IOException { private int printInstr(int pc) {
boolean pr_cpx = meth.options.contains(Options.PR.CPX); boolean pr_cpx = meth.options.contains(Options.PR.CPX);
int opc = getUbyte(pc); int opc = getUbyte(pc);
int opc2; int opc2;
@ -422,7 +422,7 @@ public class CodeData {
mnem = opcode2.parsekey(); mnem = opcode2.parsekey();
} }
out.print(mnem + " " + getUShort(pc + 2)); out.print(mnem + " " + getUShort(pc + 2));
if (opcode2 == Opcode.opc_iinc) { if (opcode2 == Opcode.opc_iinc_w) {
out.print(", " + getShort(pc + 4)); out.print(", " + getShort(pc + 4));
return 6; return 6;
} }
@ -654,7 +654,7 @@ public class CodeData {
out.println("{"); out.println("{");
iAtt iatt = iattrs.get(new Integer(0)); iAtt iatt = iattrs.get(0);
for (int pc = 0; pc < code.length;) { for (int pc = 0; pc < code.length;) {
if (iatt != null) { if (iatt != null) {
iatt.printBegins(); // equ. print("\t"); iatt.printBegins(); // equ. print("\t");
@ -673,7 +673,7 @@ public class CodeData {
} }
pc = pc + printInstr(pc); pc = pc + printInstr(pc);
out.println(";"); out.println(";");
iatt = iattrs.get(new Integer(pc)); iatt = iattrs.get(pc);
if (iatt != null) { if (iatt != null) {
iatt.printEnds(); iatt.printEnds();
} }

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -26,19 +26,25 @@ import java.io.DataInputStream;
import java.io.IOException; import java.io.IOException;
/** /**
* * Exception table entry (JVMS 4.7.3 The Code Attribute) describes one exception handler
* in the code array {@link CodeData}.
*/ */
class TrapData { class TrapData {
short start_pc, end_pc, handler_pc, catch_cpx;
int num; int num;
// exception_table
int start_pc, // u2
end_pc, // u2
handler_pc, // u2
catch_cpx; // u2
public TrapData(DataInputStream in, int num) throws IOException { public TrapData(DataInputStream in, int num) throws IOException {
this.num = num; this.num = num;
start_pc = in.readShort(); start_pc = in.readUnsignedShort();
end_pc = in.readShort(); end_pc = in.readUnsignedShort();
handler_pc = in.readShort(); handler_pc = in.readUnsignedShort();
catch_cpx = in.readShort(); catch_cpx = in.readUnsignedShort();
} }
/* returns recommended identifier /* returns recommended identifier