At 06:16 PM 2/15/00 -0600, [EMAIL PROTECTED] wrote: >I'm currently writing a (for now) simple bytecode introspector to discover >methods and fields in a class without reflection. Matt, I am most interested in working together with you on your simple bytecode introspection. Simple bytecode introspection is critical. It is the basis of a bytecode verifier, for example. While you call it introspection, I call it pure reflection. Reflection comes in two flavors: pure and practical reflection. Practical reflection is the kind offered in java.lang and java.lang.reflect. It enables you to invoke methods and read/write fields of arbitrary classes. Pure reflection is a simple bytecode introspector. You can, for example, use JDK 1.02 to inspect classes from JDK 1.2.2. Likewise, you can use JDK 1.2.2 to inspect classes from JDK 1.02. Plus, you can build a simple bytecode introspector in C/C++ to discover fields and methods in a class file. I used pure reflection to generate a list of all native methods for JDK 1.1.6. It is implemented in my com.realignsoft.reflectionXX packages. It is available now, in both runtime and source version. See also Smart API - Release 1b. Most recently, I am having fun working with attributes and opcodes. For more information on pure reflection, see also the PureReflection and PureReflection III article on JOS Wiki. I recommend reading the O'Reilly book called "Java Virtual Machine". >I've been following the Java Class File specs, but I've encountered a >Constant_Info block with a tag of "0" (which isn't documented in the class >file specs). I've just assumed that this means an end-of-the-blocks, but >I've encountered it in one classfile where the count of the constant_info >block is one more than the location of the "0" block. What does a 0 tagged >block mean? Rest assured, no valid class file uses a "0" tag. "0" is an indication of an invalid tag. The first "feature" of codepool is that length is not the length of codepool in a class file. Instead, it is the length of codepool in Sun Microsystems' implementation of a virtual machine. The length stored in a class file is one too many; it's off by one. At runtime, an entry at index 0 is a special entry used by Sun Microsystems. Most likely, you have discovered another "feature" of the codepool. Each Constant.LONG and Constant.DOUBLE are counted as if they were two entries in codepool. Your code might be reading past the end of the codepool, giving you the invalid tag of "0". _______________________________________________ Kernel maillist - [EMAIL PROTECTED] http://jos.org/mailman/listinfo/kernel
Re: [JOS-Kernel] Bytecode Interpretation
Gilbert Carl Herschberger II Thu, 17 Feb 2000 06:14:36 -0800
- [JOS-Kernel] Bytecode Interpretation Matt . Albrecht
- [JOS-Kernel] Linked lists, timers and ot... Ranieri Argentini
- Re: [JOS-Kernel] Bytecode Interpretation Joakim Dahlstedt
- Re: [JOS-Kernel] Bytecode Interpretation Gilbert Carl Herschberger II
- Re: [JOS-Kernel] Bytecode Interpretation Corrado Santoro
- Re: [JOS-Kernel] Bytecode Interpretation Matt . Albrecht
