cp-tools-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Cp-tools-discuss] gnu.bytecode


From: Elliott Hughes
Subject: Re: [Cp-tools-discuss] gnu.bytecode
Date: Sun, 6 Feb 2005 18:29:52 -0800

c) Ensure API provides enough information to output all details of the class file without using a Writer which may not output in a format you
desire and tends to have special access to internal variables...
i think a better choice is to make the writer methods public and non-final. i fear the other way duplication lies.

I've done that, at least in the obvious places.  Suggestions for
improvements welcome.

in ClassTypeWriter, most of the methods are still final, even though they're now mostly public.

attached is a modified GjDump (i don't care about the name; it was just the first thing that came to mind) that works with the current gnu.bytecode. The main change is that it now uses Access.toString.

Attachment: GjDump.java
Description: Text document



you'll see that the code that attempts to comment slot accesses based on the debugging information is commented out because gnu.bytecode.Variable doesn't let me see the offset (i.e. which slot) and the range of bytecode indexes the Variable is in the slot.

the exception handler dumping code could be improved if gnu.bytecode.CodeAttr let us see the exception handler table other than by writing the Code attribute to a byte[] and re-parsing it ourselves. i guess the most useful for this application would be to refactor CodeAttr.print so that it invokes a method on ClassTypeWriter for each exception handler rather than doing the work itself.

if people are interested in having the result, i'm happy to write a patch that modifies ClassTypeWriter, CodeAttr, and Variable so that i can whittle away more of GjDump.

here's a reminder of what the output looks like (with the slot comments disabled):

.method nextElement
.modifiers  public
.signature ()Ljava/lang/Object;
.stack 3
.locals 1
.line 14
  0: aload_0
1: getfield #1=<Field gnu.bytecode.Variable.next gnu.bytecode.Variable>
  4: ifnonnull 17
.line 15
  7: new #2=<Class java.util.NoSuchElementException>
 10: dup
 11: ldc #3=<String "Variable enumeration">
13: invokespecial #4=<Method java.util.NoSuchElementException.<init> (java.lang.String)void>
 16: athrow
.line 16
 17: aload_0
18: getfield #1=<Field gnu.bytecode.Variable.next gnu.bytecode.Variable>
 21: areturn

--
Elliott Hughes, http://www.jessies.org/~enh/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]