changeset 30:9092900a27ad

CODETOOLS-7902316 jdis ignores exception_table entries and uses a wrong format for iinc_w instruction
author lkuskov
date Mon, 24 Sep 2018 13:04:04 -0700
parents b95278aa8bf4
children 5d0dc302199d
files src/org/openjdk/asmtools/jdis/CodeData.java src/org/openjdk/asmtools/jdis/TrapData.java
diffstat 2 files changed, 20 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/org/openjdk/asmtools/jdis/CodeData.java	Thu May 17 13:34:08 2018 -0700
+++ b/src/org/openjdk/asmtools/jdis/CodeData.java	Mon Sep 24 13:04:04 2018 -0700
@@ -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 @@
     }
 
     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 @@
         }
     }
 
-    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 @@
         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 @@
                     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 @@
 
         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 @@
             }
             pc = pc + printInstr(pc);
             out.println(";");
-            iatt = iattrs.get(new Integer(pc));
+            iatt = iattrs.get(pc);
             if (iatt != null) {
                 iatt.printEnds();
             }
--- a/src/org/openjdk/asmtools/jdis/TrapData.java	Thu May 17 13:34:08 2018 -0700
+++ b/src/org/openjdk/asmtools/jdis/TrapData.java	Mon Sep 24 13:04:04 2018 -0700
@@ -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.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