[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Cp-tools-discuss] gnu.bytecode
From: |
Per Bothner |
Subject: |
Re: [Cp-tools-discuss] gnu.bytecode |
Date: |
Tue, 18 Jan 2005 00:23:22 -0800 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20041020 |
Elliott Hughes wrote:
perhaps the right solution is to mask the invalid ones out *first*,
decode the acceptable ones, and then append the unknown ones. i didn't
think of that when i wrote my alternative, which is why i went for three
separate methods.
Please take a look at the attached patch. I haven't extensively
tested it - just compiled it, and run gnu.bytecode.dump once.
--
--Per Bothner
address@hidden http://per.bothner.com/
Index: Access.java
===================================================================
RCS file: /cvs/kawa/kawa/gnu/bytecode/Access.java,v
retrieving revision 1.11
diff -u -r1.11 Access.java
--- Access.java 16 Jan 2005 07:25:14 -0000 1.11
+++ Access.java 18 Jan 2005 08:20:44 -0000
@@ -27,6 +27,15 @@
static public final short ENUM = 0x4000;
// unassigned 0x8000
+ public static final short CLASS_MODIFIERS
+ = (short)(PUBLIC|FINAL|SUPER|INTERFACE|ABSTRACT|SYNTHETIC|ANNOTATION|ENUM);
+ public static final short FIELD_MODIFIERS
+ = (short)(PUBLIC|PRIVATE|PROTECTED|STATIC|FINAL
+ |VOLATILE|TRANSIENT|SYNTHETIC|ENUM);
+ public static final short METHOD_MODIFIERS
+ = (short)(PUBLIC|PRIVATE|PROTECTED|STATIC|FINAL|SYNCHRONIZED
+ |BRIDGE|VARARGS|NATIVE|ABSTRACT|STRICT|SYNTHETIC);
+
public static String toString(int flags)
{
return toString(flags, '\0');
@@ -37,6 +46,12 @@
*/
public static String toString(int flags, char kind)
{
+ short mask
+ = (kind == 'C' ? CLASS_MODIFIERS
+ : kind == 'F' ? FIELD_MODIFIERS
+ : METHOD_MODIFIERS);
+ short bad_flags = (short) (flags & ~mask);
+ flags &= mask;
StringBuffer buf = new StringBuffer();
if ((flags & PUBLIC) != 0) buf.append(" public");
if ((flags & PRIVATE) != 0) buf.append(" private");
@@ -56,8 +71,11 @@
if ((flags & ENUM) != 0) buf.append(" enum");
if ((flags & SYNTHETIC) != 0) buf.append(" synthetic");
if ((flags & ANNOTATION) != 0) buf.append(" annotation");
- // Only one unused bit left ...
- if ((flags & 0x8000) != 0) buf.append(" 0x8000");
+ if (bad_flags != 0)
+ {
+ buf.append(" unknown-flags:0x");
+ buf.append(Integer.toHexString(bad_flags));
+ }
return buf.toString();
}
}
- Re: [Cp-tools-discuss] gnu.bytecode, (continued)
- Re: [Cp-tools-discuss] gnu.bytecode, Per Bothner, 2005/01/16
- Re: [Cp-tools-discuss] gnu.bytecode, Elliott Hughes, 2005/01/16
- Re: [Cp-tools-discuss] gnu.bytecode, C. Brian Jones, 2005/01/16
- Re: [Cp-tools-discuss] gnu.bytecode, Per Bothner, 2005/01/16
- Re: [Cp-tools-discuss] gnu.bytecode, C. Brian Jones, 2005/01/17
- Re: [Cp-tools-discuss] gnu.bytecode, Per Bothner, 2005/01/17
- Re: [Cp-tools-discuss] gnu.bytecode, C. Brian Jones, 2005/01/18
- Re: [Cp-tools-discuss] gnu.bytecode, Per Bothner, 2005/01/18
- Re: [Cp-tools-discuss] gnu.bytecode, C. Brian Jones, 2005/01/19
- Re: [Cp-tools-discuss] gnu.bytecode, Per Bothner, 2005/01/20
- Re: [Cp-tools-discuss] gnu.bytecode,
Per Bothner <=
- Re: [Cp-tools-discuss] gnu.bytecode, Elliott Hughes, 2005/01/30
- Re: [Cp-tools-discuss] gnu.bytecode, Per Bothner, 2005/01/30
Re: [Cp-tools-discuss] gnu.bytecode, C. Brian Jones, 2005/01/29