[hg] main-silver: #227826: Add a message description to a potent...

  • From:
  • To:
  • Subject: [hg] main-silver: #227826: Add a message description to a potent...
  • Date: Thu, 06 Jun 2013 08:52:00 -0700

changeset 2763fd64943f in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/2763fd64943f
description:
        #227826: Add a message description to a potential runtime exception 
thrown from ConstantPool, so that we'll be able to resolve further issues 
more easily.

diffstat:

 
debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/AST2Bytecode.java
 |   2 +-
 
debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ConstantPool.java
 |  18 +++++++--
 2 files changed, 15 insertions(+), 5 deletions(-)

diffs (68 lines):

diff --git 
a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/AST2Bytecode.java
 
b/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/AST2Bytecode.java
--- 
a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/AST2Bytecode.java
+++ 
b/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/AST2Bytecode.java
@@ -111,7 +111,7 @@
         int to = indexes[indexesIndex + 1];
         ConstantPool constantPool;
         if (constantPoolBytes != null) {
-            constantPool = ConstantPool.parse(constantPoolBytes);
+            constantPool = ConstantPool.parse(constantPoolBytes, 
ci.getFileObject().toString());
         } else {
             constantPool = null;
         }
diff --git 
a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ConstantPool.java
 
b/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ConstantPool.java
--- 
a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ConstantPool.java
+++ 
b/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ConstantPool.java
@@ -74,9 +74,11 @@
     private static final byte TAG_INVOKEDYNAMIC = 18; 
 
     private final List<ConstantPool.Entry> entries;
+    private final String description;
 
-    private ConstantPool(List<ConstantPool.Entry> entries) {
+    private ConstantPool(List<ConstantPool.Entry> entries, String 
description) {
         this.entries = entries;
+        this.description = description;
     }
 
     public ConstantPool.Entry getEntry(int index) {
@@ -89,8 +91,12 @@
      * @throws IndexOutOfBoundsException when the constant pool size is 
smaller than index.
      */
     public String getMethodName(int index) {
-        EntryFieldMethodRef methodRef = (EntryFieldMethodRef) 
entries.get(index);
+        try {
+        EntryFieldMethodRef methodRef = (EntryFieldMethodRef) 
entries.get(index); if (description != null) throw new 
NullPointerException("JUST a TEST");
         return ((EntryUTF8) entries.get(((EntryNameType) 
entries.get(methodRef.nameAndTypeIndex)).getNameIndex())).getUTF8();
+        } catch (RuntimeException re) {
+            throw Exceptions.attachMessage(re, description);
+        }
     }
 
     /**
@@ -99,11 +105,15 @@
      * @throws IndexOutOfBoundsException when the constant pool size is 
smaller than index.
      */
     public String getMethodDescriptor(int index) {
+        try {
         EntryFieldMethodRef methodRef = (EntryFieldMethodRef) 
entries.get(index);
         return ((EntryUTF8) entries.get(((EntryNameType) 
entries.get(methodRef.nameAndTypeIndex)).getDescriptorIndex())).getUTF8();
+        } catch (RuntimeException re) {
+            throw Exceptions.attachMessage(re, description);
+        }
     }
 
-    public static ConstantPool parse(byte[] bytes) {
+    public static ConstantPool parse(byte[] bytes, String description) {
         List<ConstantPool.Entry> entries = new 
ArrayList<ConstantPool.Entry>();
         DataInputStream in = new DataInputStream(new 
ByteArrayInputStream(bytes));
         entries.add(new EntryNULL());
@@ -170,7 +180,7 @@
             // Should not occur
             Exceptions.printStackTrace(ioex);
         }
-        return new ConstantPool(entries);
+        return new ConstantPool(entries, description);
     }
 
 

[hg] main-silver: #227826: Add a message description to a potent...

mentlicher 06/06/2013

Project Features

About this Project

Debugger was started in November 2009, is owned by tpavek, and has 29 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20140418.2d69abc). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close