From 6050467685973c43060c52e28a88c8784c7d8bf5 Mon Sep 17 00:00:00 2001 From: lkuskov Date: Mon, 24 Sep 2018 13:04:04 -0700 Subject: [PATCH] CODETOOLS-7902316 jdis ignores exception_table entries and uses a wrong format for iinc_w instruction --- src/org/openjdk/asmtools/jdis/CodeData.java | 14 +++++++------- src/org/openjdk/asmtools/jdis/TrapData.java | 20 +++++++++++++------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/org/openjdk/asmtools/jdis/CodeData.java b/src/org/openjdk/asmtools/jdis/CodeData.java index f7f3d60..7f55990 100644 --- a/src/org/openjdk/asmtools/jdis/CodeData.java +++ b/src/org/openjdk/asmtools/jdis/CodeData.java @@ -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. * * 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) { - Integer PC = new Integer(pc); + Integer PC = pc; iAtt res = iattrs.get(PC); if (res == null) { 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) { get_iAtt(entry.start_pc).add_var(entry); get_iAtt(entry.start_pc + entry.length).add_endvar(entry); @@ -388,7 +388,7 @@ public class CodeData { 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); int opc = getUbyte(pc); int opc2; @@ -422,7 +422,7 @@ public class CodeData { mnem = opcode2.parsekey(); } out.print(mnem + " " + getUShort(pc + 2)); - if (opcode2 == Opcode.opc_iinc) { + if (opcode2 == Opcode.opc_iinc_w) { out.print(", " + getShort(pc + 4)); return 6; } @@ -654,7 +654,7 @@ public class CodeData { out.println("{"); - iAtt iatt = iattrs.get(new Integer(0)); + iAtt iatt = iattrs.get(0); for (int pc = 0; pc < code.length;) { if (iatt != null) { iatt.printBegins(); // equ. print("\t"); @@ -673,7 +673,7 @@ public class CodeData { } pc = pc + printInstr(pc); out.println(";"); - iatt = iattrs.get(new Integer(pc)); + iatt = iattrs.get(pc); if (iatt != null) { iatt.printEnds(); } diff --git a/src/org/openjdk/asmtools/jdis/TrapData.java b/src/org/openjdk/asmtools/jdis/TrapData.java index 945ce97..fd3691e 100644 --- a/src/org/openjdk/asmtools/jdis/TrapData.java +++ b/src/org/openjdk/asmtools/jdis/TrapData.java @@ -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. * * 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; /** - * + * Exception table entry (JVMS 4.7.3 The Code Attribute) describes one exception handler + * in the code array {@link CodeData}. */ class TrapData { - short start_pc, end_pc, handler_pc, catch_cpx; 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 { this.num = num; - start_pc = in.readShort(); - end_pc = in.readShort(); - handler_pc = in.readShort(); - catch_cpx = in.readShort(); + start_pc = in.readUnsignedShort(); + end_pc = in.readUnsignedShort(); + handler_pc = in.readUnsignedShort(); + catch_cpx = in.readUnsignedShort(); } /* returns recommended identifier