Main Page | Namespace List | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

classfile.h

Go to the documentation of this file.
00001 #ifndef _classfile_h_included_
00002 #define _classfile_h_included_
00003 
00004 /*!
00005  * @file classfile.h
00006  *
00007  * @brief Definitions for <em>The Java Virtual Machine Specification,
00008  * version 2 Chapter 4, The Class File Format</em>.
00009  *
00010  * <em>The Class File Format</em>, from JDK 1.5 revision of this
00011  * section, entitled <b>ClassFileFormat-final.draft.pdf</b>,
00012  * has been used to define the contents of this file.  Originally,
00013  * the standard and well-published JDK 1.2 revision was used,
00014  * and there are a number of intermediate and semi-official
00015  * documents, but this seems to be the best and most accurate.
00016  *
00017  * ALL definitions that are not @e explicitly defined in this
00018  * document, yet are either conveniently placed here due to
00019  * intrinsic association with those that are in the document,
00020  * or those needed for late binding into the runtime structures
00021  * of this implementation, are prefixed with the string token
00022  * @b LOCAL_ for ease of identification.
00023  *
00024  * Any field of any data structure that is not documented will have
00025  * its definition in the JVM specfication itself.  The larger structures
00026  * tend to have at least some notes, but individual fields that are
00027  * fully described in the JVM spec are likely not to have redundant
00028  * commentary here.
00029  *
00030  * The JVM specification is available from Sun Microsystems' web site
00031  * at http://java.sun.com/docs/books/vmspec/index.html and
00032  * may be read online at
00033 http://java.sun.com/docs/books/vmspec/2nd-edition/html/VMSpecTOC.doc.html
00034  *
00035  * The Java 5 class file format is available as a PDF file separately at
00036 http://java.sun.com/docs/books/vmspec/2nd-edition/ClassFileFormat-final-draft.pdf
00037  * and was the basis for the ClassFile structure of this implementation.
00038  *
00039  *
00040  * @todo Need to verify which web document for the
00041  *       Java 5 class file definition is either "official",
00042  *       actually correct, or is the <em>de facto</em> standard.
00043  *
00044  *
00045  * @section Control
00046  *
00047  * \$URL: https://svn.apache.org/path/name/classfile.h $ \$Id: classfile.h 0 09/28/2005 dlydick $
00048  *
00049  * Copyright 2005 The Apache Software Foundation
00050  * or its licensors, as applicable.
00051  *
00052  * Licensed under the Apache License, Version 2.0 ("the License");
00053  * you may not use this file except in compliance with the License.
00054  * You may obtain a copy of the License at
00055  *
00056  *     http://www.apache.org/licenses/LICENSE-2.0
00057  *
00058  * Unless required by applicable law or agreed to in writing,
00059  * software distributed under the License is distributed on an
00060  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
00061  * either express or implied.
00062  *
00063  * See the License for the specific language governing permissions
00064  * and limitations under the License.
00065  *
00066  * @version \$LastChangedRevision: 0 $
00067  *
00068  * @date \$LastChangedDate: 09/28/2005 $
00069  *
00070  * @author \$LastChangedBy: dlydick $
00071  *         Original code contributed by Daniel Lydick on 09/28/2005.
00072  *
00073  * @section Reference
00074  *
00075  */
00076 
00077 ARCH_COPYRIGHT_APACHE(classfile, h, "$URL: https://svn.apache.org/path/name/classfile.h $ $Id: classfile.h 0 09/28/2005 dlydick $");
00078 
00079 
00080 /*!
00081  * @brief Attributes of a field, method, or class.
00082  *
00083  * See spec section 4.8.
00084  *
00085  * The definitions of @link #u1 u1@endlink and @link #u2 u2@endlink
00086  * and @link #u4 u4@endlink may be found in
00087  * @link jvm/src/jrtypes.h jrtypes.h@endlink to decouple these
00088  * primative types from class file specifics.  This is because
00089  * these three definitions are used all over the code
00090  * and not just in class file areas.
00091  *
00092  * @internal typedef placed here to avoid forward reference.
00093  *
00094  */
00095 typedef struct
00096 {
00097     u2 attribute_name_index;
00098     u4 attribute_length;
00099 
00100     u1 info[1]; /**< Spec pseudo-code: @c @b info[attribute_length]; */
00101 
00102 } attribute_info;
00103 
00104 
00105 /*!
00106  * @brief constant_pool entry.
00107  *
00108  * See spec section 4.5.
00109  *
00110  * @internal typedef placed here to avoid forward reference.
00111  *
00112  */
00113 typedef struct
00114 {
00115     u1 tag;
00116 
00117     u1 *info; /**< Spec pseudo-code says: @c @b info[]; */
00118 
00119 } cp_info;
00120 
00121 
00122 /*!
00123  * @name Byte aligned structure entries.
00124  *
00125  * @brief Frame @p @b cp_info and @p @b attribute_info entries for
00126  * correct byte alignment on real machine architectures that
00127  * require it.
00128  *
00129  * The following structure is used for aligning (cp_info) data
00130  * on 4-byte addresses with the exception of the one-byte @p @b tag
00131  * field.  The next one aligns (attribute_info) similarly.
00132  * Doing this suppresses problem w/ C/C++ compilers
00133  * where certain architectures yield a @b SIGSEGV on odd-aligned
00134  * 16-bit integer accesses or non-4-byte aligned 32-bit integer
00135  * accesses.  For 16-bit accesses, such operations as,
00136  *
00137  * @verbatim
00138   
00139        short x, *p; // (short)
00140        ...
00141        p = some_value();
00142        ...
00143        x = *p;
00144   
00145    and for 32-bit accesses,
00146   
00147        int x, *p; // (int), etc.
00148        ...
00149        p = some_value();
00150        ...
00151        x = *p;
00152   
00153    @endverbatim
00154  *
00155  * both produce a @b SIGSEGV when @b p is not aligned on an 2- or 4-byte
00156  * address, respectively.
00157  *
00158  * By introducing the command line option to force structure packing,
00159  * this situation can occur (e.g.: GCC @c @b -fpack-struct option,
00160  * which suppresses 4-byte structure alignment).  Unfortunately, this
00161  * option is needed in order to properly size the structures in this
00162  * header file. Yet, some standard library calls fail when compiled
00163  * like this (like @b fprintf(3) ), so choose judiciously.
00164  *
00165  */
00166 
00167 /*@{ */ /* Begin grouped definitions */
00168 
00169 #define CP_INFO_NUM_EMPTIES 3 /**< Size of padding for cp_info
00170                   * structures insize of cp_info_dup structure */
00171 
00172 /*!
00173  * @brief Pad cp_info structures for proper multi-byte field
00174  * address boundary alignment.
00175  * @see FILL_INFO_DUP0 et al.
00176  *
00177  */
00178 typedef struct
00179 {
00180     rbyte empty[CP_INFO_NUM_EMPTIES];
00181                  /**< Align @p @b tag u1 byte against
00182                       END of 4-byte  word */
00183 
00184     cp_info cp;  /**< Misalign cp_info (on odd address) so that
00185                   *   all items except @p @b tag are on even addresses.
00186                   *   This assumes they are all u2 or u4.
00187                   */
00188 } cp_info_dup;
00189 
00190 
00191 #define ATTRIBUTE_INFO_NUM_EMPTIES 2 /**< Size of padding for
00192                   * attribute_info structures insize of
00193                   * attribute_info_dup structure */
00194 /*!
00195  * @brief Pad attribute_info structures for proper multi-byte field
00196  * address boundary alignment.
00197  * @see FILL_INFO_DUP0 et al.
00198  *
00199  */
00200 typedef struct
00201 {
00202     rbyte empty[ATTRIBUTE_INFO_NUM_EMPTIES]; /**< Align
00203                   * @p @b attribute_name_index u2 jshort
00204                   * against END of 4-byte word
00205                   */
00206 
00207     attribute_info ai; /**< Misalign attribute_info (on non-4-byte
00208                   * address) so that @p @b attribute_length is on a
00209                   * 4-byte addresses.  Subsequent members may not 
00210                   * be  4-byte aligned, (per spec definitions),
00211                   * but those can be handled on a case-by-case basis.
00212                   * At least here, everything starts out on the correct
00213                   * alignment.
00214                   */
00215 
00216 } attribute_info_dup;
00217 
00218 /*@} */ /* End of grouped definitions */
00219 
00220 
00221 /*!
00222  * @brief Field table entry.
00223  *
00224  * See spec section 4.6
00225  *
00226  * @internal typedef placed here to avoid forward reference.
00227  *
00228  */
00229 typedef struct
00230 {
00231     u2 access_flags;  /**< Bitwise access flags, containing various of
00232                        * the @link #ACC_PUBLIC ACC_xxx@endlink
00233                        * definitions */
00234 
00235     u2 name_index;    /**< Index into constant_pool of UTF8 string
00236                        *   containing the name of this field */
00237 
00238     u2 descriptor_index; /**< Index into constant_pool of UTF8 string
00239                           * containing the descriptor of this field */
00240 
00241     u2 attributes_count; /**< Size of @p @b attributes */
00242 
00243     attribute_info_dup **attributes; /**< Field attributes array.
00244                        * The spec pseudo-code defines this as:
00245                     @c @b attributes_info @c @b fields[attributes_count]
00246                        * but it is implemented as a pointer to an array
00247                        * of pointers.  The length of this array is 
00248                        * @c @b attributes_count elements.
00249                        *
00250                        * Notice that the @c @b attribute_info
00251                        * structure is found with this
00252                        * @c @b attribute_info_dup structure.
00253                        * The purpose for this is proper byte alignment
00254                        * of multi-byte items such as 2- and 4-byte
00255                        * integers on machine architectures that demand
00256                        * it lest they complain with @b SIGSEGV and the
00257                        * like.
00258                        */
00259 
00260 
00261 
00262     /*!
00263      * @brief Local implementation late binding extensions for fields.
00264      *
00265      * Uses LOCAL_ as a prefix to signify an item that is @e not
00266      * part of the JVM spec itself, but an implementation detail.
00267      *
00268      * @internal An @p @b oiflagJVM boolean is not needed since
00269      * @p @b access_flags above contains this information
00270      * in the @link #ACC_STATIC ACC_STATIC@endlink bit.
00271      *
00272      */
00273     struct LOCAL_field_binding
00274     {
00275         jvm_field_index fluidxJVM; /**< JVM class table field
00276                        * lookup index of this field.  If this is a
00277                        * class static field, use this value to index
00278                        * the @link #rclass.class_static_field_lookup
00279                          rclass.class_static_field_lookup@endlink
00280                        * array for the @link #ClassFile.fields
00281                        * ClassFile.fields[]@endlink index and in the
00282                        * @link #rclass.class_static_field_data
00283                          rclass.class_static_field_data@endlink
00284                        * array for the data jvalue.
00285                        *
00286                        * If this is an object instance field, use this
00287                        * value to index the
00288                        * @link #rclass.object_instance_field_lookup
00289                          rclass.object_instance_field_lookup@endlink
00290                        * array for the @link #ClassFile.fields
00291                        * ClassFile.fields[]@endlink index and in the
00292                        * @link #robject.object_instance_field_data
00293                          robject.object_instance_field_data@endlink
00294                        * array for the data jvalue.
00295                        */
00296 
00297     } LOCAL_field_binding;
00298 
00299 } field_info;
00300 
00301 
00302 /*!
00303  * @brief Method table entry.
00304  *
00305  * See spec section 4.7
00306  *
00307  * @internal typedef placed here to avoid forward reference.
00308  *
00309  */
00310 typedef struct
00311 {
00312     u2 access_flags;  /**< Bitwise access flags, containing various of
00313                        * the @link #ACC_PUBLIC ACC_xxx@endlink
00314                        * definitions */
00315 
00316     u2 name_index;    /**< Index into constant_pool of UTF8 string
00317                        *   containing the name of this method */
00318 
00319     u2 descriptor_index; /**< Index into constant_pool of UTF8 string
00320                           * containing the descriptor of this method */
00321 
00322 
00323     u2 attributes_count; /**< Size of @p @b attributes */
00324 
00325     attribute_info_dup **attributes; /**< Method attributes array.
00326                        * The spec pseudo-code defines this as:
00327                     @c @b attributes_info @c @b fields[attributes_count]
00328                        * but it is implemented as a pointer to an array
00329                        * of pointers.  The length of this array is 
00330                        * @c @b attributes_count elements.
00331                        *
00332                        * Notice that the @c @b attribute_info
00333                        * structure is found with this
00334                        * @c @b attribute_info_dup structure.
00335                        * The purpose for this is proper byte alignment
00336                        * of multi-byte items such as 2- and 4-byte
00337                        * integers on machine architectures that demand
00338                        * it lest they complain with @b SIGSEGV and the
00339                        * like.
00340                        */
00341 
00342 
00343     /*** LOCAL IMPLEMENTATION LATE BINDING EXTENSIONS ***/
00344 
00345     /*!
00346      * @brief Local implementation late binding extensions for methods.
00347      *
00348      * Uses LOCAL_ as a prefix to signify an item that is @e not
00349      * part of the JVM spec itself, but an implementation detail.
00350      *
00351      */
00352     struct LOCAL_method_binding
00353     {
00354         jvm_attribute_index codeatridxJVM; /**< JVM method attribute
00355                        * table index of the code for this method.
00356                        * It is @e required to have a valid attribute
00357                        * index here.
00358                        */
00359 
00360         jvm_attribute_index excpatridxJVM; /**< JVM method attribute
00361                        * table index of the exceptions for this method
00362                        * A valid attribute index here is optional.
00363                        * Methods are not required to use exceptions.
00364                        */
00365 
00366         jvm_native_method_ordinal nmordJVM; /**< JVM local native
00367                        * method ordinal number of this method if it
00368                        * is a native method.  Not applicable otherwise.
00369                        * If the native method is @e not a local one,
00370                        * that is, not implemented within the core JVM
00371                        * code, then this value @e must be set to @link
00372                          #JVMCFG_JLOBJECT_NMO_NULL
00373                          JVMCFG_JLOBJECT_NMO_NULL@endlink
00374                        * (as known to the JVM core code), which is the
00375                        * same as
00376                        * @link #JLOBJECT_NMO_NULL
00377                          JLOBJECT_NMO_NULL@endlink
00378                        * (as known to the outside world throught the
00379                        * JNI interface).
00380                        */
00381 
00382     } LOCAL_method_binding;
00383 
00384 } method_info;
00385 
00386 
00387 /* At last:  The class file typedef itself! */
00388 
00389 /*!
00390  * @name JVM spec Section 4.2: The ClassFile structure.
00391  *
00392  *
00393  * <b>The following structure definition is NOT MEANT TO BE AN EXACT
00394  * REPRESENTATION OF THE DATA STRUCTURES SHOWN IN THE JAVA CLASS FILE
00395  * SPECIFICATION!</b>  That document contains numerous pseudo-code
00396  * representations of data structures.  Instead, this definition is
00397  * designed to be an actual real machine implementation of that
00398  * specification.
00399  *
00400  * Each of the variable-length structures from the spec are stored as
00401  * arrays of pointers to those structures, which are located in heap
00402  * allocated memory areas and their length, being always defined in
00403  * the spec as preceding the variable-length area, tells how many
00404  * elements are found in each array.  For example, @link
00405    #ClassFile.constant_pool_count ClassFile.constant_pool_count@endlink
00406  * and @link #ClassFile.constant_pool ClassFile.constant_pool@endlink.
00407  * Each element may, of course, be of variable size according to its
00408  * actual contents, and this will be reflected by the size of each heap
00409  * allocation.
00410  *
00411  * Furthermore, any variable or data type marked @b LOCAL_ in this
00412  * structure and its subsidiary components is a local implementation
00413  * extension that is no found in the specification, but is used by
00414  * the JVM runtime environment to facilitate processing, expecially to
00415  * expedite class linkages.  For example, CONSTANT_Class_info and
00416  * CONSTANT_Class_info.LOCAL_Class_binding.
00417  *
00418  */
00419 
00420 /*@{ */ /* Begin grouped definitions */
00421 
00422 /*!
00423  * @brief The @b ClassFile structure definition.
00424  *
00425  * See spec section 4.2.
00426  *
00427  */
00428 typedef struct
00429 {
00430     u4 magic;         /**< Magic number for this file type.
00431                        * It @e must contain the constant value
00432                        * @link #CLASSFILE_MAGIC CLASSFILE_MAGIC@endlink
00433                        */
00434 
00435     u2 minor_version; /**< Minor class file version number */
00436 
00437     u2 major_version; /**< Major class file version number */
00438 
00439     u2 constant_pool_count; /**< Size of @p @b constant_pool plus one
00440                        * (which represents the unrepresented
00441                        * @c @b java.lang.Object ).  Index zero
00442                        * of @p @b constant_pool is this unrepresented
00443                        * slot, and
00444                        * @c @b constant_pool[0] is a NULL
00445                        * pointer.
00446                        */
00447 
00448     cp_info_dup **constant_pool; /**< Constant pool array.  The spec
00449                        * pseudo-code defines this as:
00450        <b><code>cp_info constant_pool[constant_pool_count -1]</code></b>
00451                        * but it is implemented as a pointer to an array
00452                        * of pointers.  The length of this array is 
00453                        * <b><code>constant_pool_count - 1</code></b>
00454                        * elements.
00455                        *
00456                        * Notice that the @c @b cp_info structure
00457                        * is found with this @c @b cp_info_dup
00458                        * structure.  The purpose for this is proper
00459                        * byte alignment of multi-byte items such as
00460                        * 2- and 4-byte integers on machine architectures
00461                        * that demand it lest they complain with
00462                        * @b SIGSEGV and the like.
00463                        */
00464 
00465     u2 access_flags;  /**< Bitwise access flags, containing various of
00466                        * the @link #ACC_PUBLIC ACC_xxx@endlink
00467                        * definitions */
00468 
00469     u2 this_class;    /**< @b constant_pool index of the class of
00470                        * the @c @b this pointer, namely,
00471                        * what is the name of this selfsame class as
00472                        * found here in the class file. */
00473 
00474     u2 super_class;   /**< @p @b constant_pool index of the class of
00475                        * the @c @b super pointer, namely,
00476                        * what is the name of the super-class of this
00477                        * selfsame class as found here in the class
00478                        * file. */
00479 
00480     u2 interfaces_count; /**< Size of @p @b interfaces */
00481 
00482     u2 *interfaces;   /**< Interface array.  The spec
00483                        * pseudo-code defines this as:
00484                        * @c @b interfaces[interfaces_count]
00485                        * but it is implemented as an array of pointers.
00486                        * The length of this array is 
00487                        * @c @b interfaces_count elements.
00488                        */
00489 
00490     u2 fields_count;  /**< Size of @p @b fields */
00491 
00492     field_info **fields; /**< Fiels array.  The spec
00493                        * pseudo-code defines this as:
00494                        * @c @b fields[fields_count]
00495                        * but it is implemented as a pointer to an array
00496                        * of pointers.  The length of this array is 
00497                        * @c @b fields_count elements.
00498                        */
00499 
00500     u2 methods_count; /**< Size of @p @b methods */
00501 
00502     method_info **methods; /**< Methods array.  The spec
00503                        * pseudo-code defines this as:
00504                        * @c @b methods[methods_count]
00505                        * but it is implemented as a pointer to an array
00506                        * of pointers.  The length of this array is 
00507                        * @c @b methods_count elements.
00508                        */
00509 
00510     u2 attributes_count; /**< Size of @p @b attributes */
00511 
00512     attribute_info_dup **attributes; /**< Class file attributes array.
00513                        * The spec pseudo-code defines this as:
00514                     @c @b attributes_info @c @b fields[attributes_count]
00515                        * but it is implemented as a pointer to an array
00516                        * of pointers.  The length of this array is 
00517                        * @c @b attributes_count elements.
00518                        *
00519                        * Notice that the @c @b attribute_info
00520                        * structure is found with this
00521                        * @c @b attribute_info_dup structure.
00522                        * The purpose for this is proper byte alignment
00523                        * of multi-byte items such as 2- and 4-byte
00524                        * integers on machine architectures that demand
00525                        * it lest they complain with @b SIGSEGV and the
00526                        * like.
00527                        */
00528 
00529 } ClassFile;
00530 
00531 
00532 #define CLASSFILE_MAGIC 0xCAFEBABE /**< Magic number for class files */
00533 
00534 /*@} */ /* End of grouped definitions */
00535 
00536 
00537 /*!
00538  * @name List of all class file versions
00539  *
00540  */
00541 
00542 /*@{ */ /* Begin grouped definitions */
00543 
00544 #define VERSION_MAJOR_JDK1 45
00545 #define VERSION_MAJOR_JDK2 46
00546 #define VERSION_MAJOR_JDK3 47
00547 #define VERSION_MAJOR_JDK4 48
00548 #define VERSION_MAJOR_JDK5 49
00549 
00550 /*@} */ /* End of grouped definitions */
00551 
00552 /*!
00553  * @brief Default minor version number for primative pseudo-classes
00554  *
00555  */
00556 #define VERSION_MINOR_DEFAULT 0
00557 
00558 /*!
00559  * @name Define range of supported class file versions
00560  *
00561  */
00562 
00563 /*@{ */ /* Begin grouped definitions */
00564 
00565 #define VERSION_MAJOR_LOW  VERSION_MAJOR_JDK1
00566 #define VERSION_MINOR_LOW   0
00567 #define VERSION_MAJOR_HIGH VERSION_MAJOR_JDK5
00568 #define VERSION_MINOR_HIGH  0
00569 
00570 /*@} */ /* End of grouped definitions */
00571 
00572 
00573 
00574 /*!
00575  * @name Table 4.1: Access Flags for Classes
00576  *
00577  * The first definition of all such tokens is found here.  Throughout
00578  * the spec, many of these symbols will be @e redefined to be the
00579  * same value.  Such redefinitions are commented here in source, but
00580  * are not redefined <em>per se</em>.  There is no "grand union"
00581  * definition.
00582  *
00583  * For other @link #ACC_PUBLIC ACC_xxx@endlink definitions,
00584  * see also table 4.4, 4.5, 4.7, where more definitions are found.
00585  *
00586  */
00587 
00588 /*@{ */ /* Begin grouped definitions */
00589 
00590 
00591 #define LOCAL_ACC_EMPTY 0x0000 /**< Not defined, empty (not in spec) */
00592 
00593 #define ACC_PUBLIC    0x0001   /**< Declared @b public; may be accessed
00594                                     from outside its package. */
00595 
00596 #define ACC_FINAL     0x0010   /**< Declared @b final;no subclasses
00597                                     allowed */
00598 
00599 #define ACC_SUPER     0x0020   /**< Treat superclass methods specially
00600                                     when invoked by the
00601                                     @b INVOKESPECIAL instruction*/
00602 
00603 #define ACC_INTERFACE 0x0200   /**< Is an interface, not a class. */
00604 
00605 #define ACC_ABSTRACT  0x0400   /**< Declared @c @b abstract ; may not
00606                                     be instantiated. */
00607 
00608 #define ACC_SYNTHETIC 0x1000   /**< Declared @c @b synthetic ; not
00609                                     present in the source code. */
00610 
00611 #define ACC_ANNOTATION 0x2000  /**< Declared as an annotation type */
00612 
00613 #define ACC_ENUM      0x4000   /**< Declared as an enum type */
00614 
00615 /*@} */ /* End of grouped definitions */
00616 
00617 
00618 /*!
00619  * @brief Root Java language object name
00620  *
00621  */
00622 
00623 #define CONSTANT_UTF8_JAVA_LANG_OBJECT "java/lang/Object"
00624 
00625 
00626 /*!
00627  * @name Section 4.3:  The Internal Form of Fully Qualified Class \
00628 and Interface Names
00629  */
00630 
00631 /*@{ */ /* Begin grouped definitions */
00632 
00633 #define CLASSNAME_EXTERNAL_DELIMITER_CHAR   '.'
00634 #define CLASSNAME_EXTERNAL_DELIMITER_STRING "."
00635 
00636 #define CLASSNAME_INTERNAL_DELIMITER_CHAR   '/'
00637 #define CLASSNAME_INTERNAL_DELIMITER_STRING "/"
00638 
00639 /*@} */ /* End of grouped definitions */
00640 
00641 
00642 /*!
00643  * @name Section 4.4:  Descriptors-- Section 4.4.1:  Grammar Notation
00644  *
00645  */
00646 
00647 /*@{ */ /* Begin grouped definitions */
00648 
00649 #define GRAMMAR_PARM_OPEN  '(' /**< Open parenthesis for starting
00650                                     a param defn */
00651 #define GRAMMAR_PARM_CLOSE ')' /**< Open parenthesis for starting
00652                                     a param defn */
00653 
00654 /*@} */ /* End of grouped definitions */
00655 
00656 
00657 /*!
00658  * @name Section 4.4.2:  Field Descriptors
00659  *
00660  * Table 4.2:  BaseType Character Definitions
00661  *
00662  */
00663 
00664 /*@{ */ /* Begin grouped definitions */
00665 
00666 #define BASETYPE_CHAR_B  'B'   /**< Signed byte */
00667 #define BASETYPE_CHAR_C  'C'   /**< Unicode character */
00668 #define BASETYPE_CHAR_D  'D'   /**< Double-precision floating-point
00669                                     value */
00670 #define BASETYPE_CHAR_F  'F'   /**< Single-precision floating-point 
00671                                     value */
00672 #define BASETYPE_CHAR_I  'I'   /**< Integer */
00673 #define BASETYPE_CHAR_J  'J'   /**< Long integer */
00674 
00675 
00676 /*!
00677  * @internal @c @b L/class/name; includes
00678  *           @b _CHAR_ and @b _STRING_ forms
00679  */
00680 
00681 #define BASETYPE_CHAR_L   'L'  /**< an instance of class '/class/name'*/
00682 #define BASETYPE_STRING_L "L"  /**< null-terminated string form
00683                                     of BASETYPE_CHAR_L */
00684 
00685 #define BASETYPE_CHAR_L_TERM   ';' /**< terminator for instance of
00686                                         class */
00687 #define BASETYPE_STRING_L_TERM ";" /**< null-terminated string form
00688                                         of BASETYPE_CHAR_L_TERM */
00689 
00690 
00691 
00692 #define BASETYPE_CHAR_S       'S'   /**< Signed short */
00693 #define BASETYPE_CHAR_Z       'Z'   /**< Boolean, @b true or @b false */
00694 
00695 #define BASETYPE_CHAR_ARRAY   '['   /**< Reference to one array 
00696                                          dimension */
00697 #define BASETYPE_STRING_ARRAY "["   /**< null-terminated string form
00698                                          of BASETYPE_CHAR_ARRAY */
00699 
00700 #define LOCAL_BASETYPE_ERROR '?'    /**< Invalid basetype due to
00701                                          malformed @p @b tag or other
00702                                          error (not in spec) */
00703 
00704 /*@} */ /* End of grouped definitions */
00705 
00706 
00707 /*!
00708  * @name Section 4.4.3:  Method Descriptors
00709  */
00710 
00711 /*@{ */ /* Begin grouped definitions */
00712 
00713 #define METHOD_CHAR_VOID         'V'  /**< No return type, instead:
00714                                            (rvoid) fn(p1,p2,...) */
00715 #define METHOD_STRING_VOID       "V"  /**< null-terminated string form
00716                                            of METHOD_CHAR_VOID */
00717 
00718 #define METHOD_PARM_MAX          255  /**< Max length of method
00719                                            descriptor string */
00720 
00721 #define METHOD_CHAR_OPEN_PARM    '('  /**< Open parameter list */
00722 #define METHOD_STRING_OPEN_PARM  "("  /**< null-terminated string form
00723                                            of METHOD_CHAR_OPEN_PARM */
00724 
00725 #define METHOD_CHAR_CLOSE_PARM   ')'  /**< Open parameter list */
00726 #define METHOD_STRING_CLOSE_PARM ")"  /**< null-terminated string form
00727                                            of METHOD_CHAR_OPEN_PARM */
00728 
00729 /*@} */ /* End of grouped definitions */
00730 
00731 
00732 /*!
00733  * @name Section 4.4.4:  Signatures
00734  *
00735  */
00736 
00737 /*@{ */ /* Begin grouped definitions */
00738 
00739 #define BASETYPE_CHAR_T  'T'   /**< a type variable signature */
00740 
00741 /*@} */ /* End of grouped definitions */
00742 
00743 
00744 /*!
00745  * @name Section 4.5:  The Constant Pool
00746  *
00747  * typedef struct cp_info:  See fwd refs above typedef ClassFile
00748  *
00749  * See also table 4.3:  ConstantType Definitions
00750  *
00751  */
00752 
00753 /*@{ */ /* Begin grouped definitions */
00754 
00755 #define CONSTANT_CP_DEFAULT_INDEX    0 /**< References
00756                                         @c @b java.lang.Object */
00757 #define CONSTANT_CP_START_INDEX      1 /**< Ref first constant item */
00758 
00759 /*@} */ /* End of grouped definitions */
00760 
00761 /*!
00762  * @name Table 4.3:  ConstantType Definitions
00763  *
00764  */
00765 
00766 /*@{ */ /* Begin grouped definitions */
00767 
00768 #define CONSTANT_Class               7
00769 #define CONSTANT_Fieldref            9
00770 #define CONSTANT_Methodref          10
00771 #define CONSTANT_InterfaceMethodref 11
00772 #define CONSTANT_String              8
00773 #define CONSTANT_Integer             3
00774 #define CONSTANT_Float               4
00775 #define CONSTANT_Long                5
00776 #define CONSTANT_Double              6
00777 #define CONSTANT_NameAndType        12
00778 #define CONSTANT_Utf8                1
00779 
00780 /*@} */ /* End of grouped definitions */
00781 
00782 
00783 /*!
00784  * @name Section 4.5.1:  The CONSTANT_Class_info structure
00785  *
00786  */
00787 
00788 /*@{ */ /* Begin grouped definitions */
00789 
00790 typedef struct
00791 {
00792     u1 tag;
00793     u2 name_index;
00794 
00795 
00796     /*** LOCAL IMPLEMENTATION LATE BINDING EXTENSIONS ***/
00797 
00798     /*!
00799      * @brief Local implementation late binding extensions for
00800      * @link #CONSTANT_Class_info CONSTANT_Class_info@endlink.
00801      *
00802      * Uses LOCAL_ as a prefix to signify an item that is @e not
00803      * part of the JVM spec itself, but an implementation detail.
00804      *
00805      */
00806     struct LOCAL_Class_binding
00807     {
00808         jvm_class_index clsidxJVM; /**< JVM class table index of
00809                                         this class */
00810 
00811     } LOCAL_Class_binding;
00812 
00813 } CONSTANT_Class_info;
00814 
00815 
00816 #define CONSTANT_MAX_ARRAY_DIMS      255 /**< Highest number of array
00817                                               dimensions */
00818 
00819 #define LOCAL_CONSTANT_NO_ARRAY_DIMS   0 /**< Not stated in spec, but
00820                                               implied */
00821 
00822 /*@} */ /* End of grouped definitions */
00823 
00824 
00825 /*!
00826  * @name Section 4.5.2:  The CONSTANT_Fieldref_info, \
00827 CONSTANT_Methodref_info, and \
00828 CONSTANT_InterfaceMethodref_info structures
00829  *
00830  */
00831 
00832 /*@{ */ /* Begin grouped definitions */
00833 
00834 typedef struct
00835 {
00836     u1 tag;
00837     u2 class_index;
00838     u2 name_and_type_index;
00839 
00840 
00841     /*** LOCAL IMPLEMENTATION LATE BINDING EXTENSIONS ***/
00842 
00843     /*!
00844      * @brief Local implementation late binding extensions for
00845      * @link #CONSTANT_Fieldref_info CONSTANT_Fieldref_info@endlink.
00846      *
00847      * Uses LOCAL_ as a prefix to signify an item that is @e not
00848      * part of the JVM spec itself, but an implementation detail.
00849      *
00850      */
00851     struct LOCAL_Fieldref_binding
00852     {
00853         jvm_class_index clsidxJVM;   /**< JVM class table index of
00854                                           this class */
00855 
00856         jvm_field_index fluidxJVM;   /**< JVM class table field lookup
00857                                         index of this field */
00858 
00859         rboolean        oiflagJVM;   /**< JVM class table flag: class
00860                                       * static vs object instance
00861                                       * field.  This information is
00862                                       * derived directly from the
00863                                       * field's definition of its
00864                                       * @link #field_info.access_flags
00865                                         field_info.access_flags@endlink,
00866                                       * namely @link #ACC_STATIC
00867                                         ACC_STATIC@endlink.  This
00868                                       * information is duplicated here
00869                                       * for a localized copy of this
00870                                       * information for implementation
00871                                       * convenience.  It is not
00872                                       * something that will ever change
00873                                       * over the life of the loaded
00874                                       * class.  It is @link #rtrue
00875                                         rtrue@endlink if this field is
00876                                       * part of an object instance
00877                                       * and @link #rfalse rfalse@endlink
00878                                       * if it is part of a class static
00879                                       * instance.
00880                                       */
00881 
00882         jvm_basetype  jvaluetypeJVM; /**< JVM class table field type.
00883                                       * It is needed to know which kind
00884                                       * of load and store to use for
00885                                       * a field access, which involves
00886                                       * a member of a jvalue.
00887                                       */
00888 
00889     } LOCAL_Fieldref_binding;
00890 
00891 } CONSTANT_Fieldref_info;
00892 
00893 typedef struct
00894 {
00895     u1 tag;
00896     u2 class_index;
00897     u2 name_and_type_index;
00898 
00899 
00900     /*** LOCAL IMPLEMENTATION LATE BINDING EXTENSIONS ***/
00901 
00902     /*!
00903      * @brief Local implementation late binding extensions for
00904      * @link #CONSTANT_Methodref_info CONSTANT_Methodref_info@endlink.
00905      *
00906      * Uses LOCAL_ as a prefix to signify an item that is @e not
00907      * part of the JVM spec itself, but an implementation detail.
00908      *
00909      */
00910     struct LOCAL_Methodref_binding
00911     {
00912         jvm_class_index clsidxJVM;   /**< JVM class table index of
00913                                           this class */
00914 
00915         jvm_method_index mthidxJVM;  /**< JVM method table index
00916                                           of this method */
00917 
00918         jvm_attribute_index
00919             codeatridxJVM;           /**< JVM method attribute table
00920                                       *   index of the code for this
00921                                       *   method.
00922                                       */
00923 
00924         jvm_attribute_index
00925             excpatridxJVM;           /**< JVM method attribute table
00926                                       *   index of the exceptions for
00927                                       *   this method.
00928                                       */
00929 
00930         jvm_native_method_ordinal
00931             nmordJVM;                /**< JVM local native method
00932                                       *   ordinal number of this
00933                                       *   native method.
00934                                       */
00935 
00936     } LOCAL_Methodref_binding;
00937 
00938 } CONSTANT_Methodref_info;
00939 
00940 typedef struct
00941 {
00942     u1 tag;
00943     u2 class_index;
00944     u2 name_and_type_index;
00945 
00946 
00947     /*** LOCAL IMPLEMENTATION LATE BINDING EXTENSIONS ***/
00948 
00949     /*!
00950      * @brief Local implementation late binding extensions for
00951      * @link #CONSTANT_InterfaceMethodref_info
00952        CONSTANT_InterfaceMethodref_info@endlink.
00953      *
00954      * Uses LOCAL_ as a prefix to signify an item that is @e not
00955      * part of the JVM spec itself, but an implementation detail.
00956      *
00957      */
00958     struct LOCAL_InterfaceMethodref_binding
00959     {
00960         jvm_class_index clsidxJVM;   /**< JVM class table index of
00961                                           this class */
00962 
00963         jvm_method_index mthidxJVM;  /**< JVM method table index of
00964                                           this method */
00965 
00966         jvm_attribute_index
00967             codeatridxJVM;           /**< JVM method attribute table
00968                                           index of the code for this
00969                                           method */
00970 
00971         jvm_attribute_index
00972             excpatridxJVM;           /**< JVM method attribute table
00973                                       *   of the exceptions for this
00974                                       *   method.
00975                                       */
00976 
00977         jvm_native_method_ordinal
00978             nmordJVM;               /**< JVM local native method
00979                                      *   ordinal number of this native
00980                                      *   method.
00981                                      */
00982 
00983     } LOCAL_InterfaceMethodref_binding;
00984 
00985 } CONSTANT_InterfaceMethodref_info;
00986 
00987 
00988 #define METHOD_CHAR_INIT '<'        /**< Special character for naming
00989                                          of an object constructor method
00990                                          name, that is, the
00991                                          @c @b <init> method, and the
00992                                          class constructor method
00993                                          name, that is, the
00994                                          @c @b <clinit> method */
00995 
00996 /*@} */ /* End of grouped definitions */
00997 
00998 
00999 /*!
01000  * @name Section 4.5.3:  The CONSTANT_String_info structure
01001  *
01002  */
01003 
01004 /*@{ */ /* Begin grouped definitions */
01005 
01006 typedef struct
01007 {
01008     u1 tag;
01009     u2 string_index;
01010 
01011     /*** LOCAL IMPLEMENTATION LATE BINDING EXTENSIONS ***/
01012 
01013     /*!
01014      * @brief Local implementation late binding extensions for
01015      * @link #CONSTANT_String_info CONSTANT_String_info@endlink.
01016      *
01017      * Uses LOCAL_ as a prefix to signify an item that is @e not
01018      * part of the JVM spec itself, but an implementation detail.
01019      *
01020      */
01021     struct LOCAL_String_binding
01022     {
01023         /*!
01024          * @internal There is not late binding for this structure.
01025          * However, to maintain compatibility with the
01026          * @link #ALLOC_CP_INFO() ALLOC_CP_INFO()@endlink macro
01027          * in @link jvm/src/classfile.c classfile.c@endlink,
01028          * this empty structure is provided.
01029          */
01030     } LOCAL_String_binding;
01031 
01032 } CONSTANT_String_info;
01033 
01034 /*@} */ /* End of grouped definitions */
01035 
01036 
01037 /*!
01038  * @name Section 4.5.4:  The CONSTANT_Integer_info and
01039  *                       CONSTANT_Float_info structures
01040  *
01041  */
01042 
01043 /*@{ */ /* Begin grouped definitions */
01044 
01045 typedef struct
01046 {
01047     u1 tag;
01048     u4 bytes;
01049 
01050     /*** LOCAL IMPLEMENTATION LATE BINDING EXTENSIONS ***/
01051 
01052     /*!
01053      * @brief Local implementation late binding extensions for
01054      * @link #CONSTANT_Integer_info CONSTANT_Integer_info@endlink.
01055      *
01056      * Uses LOCAL_ as a prefix to signify an item that is @e not
01057      * part of the JVM spec itself, but an implementation detail.
01058      *
01059      */
01060     struct LOCAL_Integer_binding
01061     {
01062         /*!
01063          * @internal There is not late binding for this structure.
01064          * However, to maintain compatibility with the
01065          * @link #ALLOC_CP_INFO() ALLOC_CP_INFO()@endlink macro
01066          * in @link jvm/src/classfile.c classfile.c@endlink,
01067          * this empty structure is provided.
01068          */
01069     } LOCAL_Integer_binding;
01070 
01071 } CONSTANT_Integer_info;
01072 
01073 typedef struct
01074 {
01075     u1 tag;
01076     u4 bytes;
01077 
01078     /*** LOCAL IMPLEMENTATION LATE BINDING EXTENSIONS ***/
01079 
01080     /*!
01081      * @brief Local implementation late binding extensions for
01082      * @link #CONSTANT_Float_info CONSTANT_Float_info@endlink.
01083      *
01084      * Uses LOCAL_ as a prefix to signify an item that is @e not
01085      * part of the JVM spec itself, but an implementation detail.
01086      *
01087      */
01088     struct LOCAL_Float_binding
01089     {
01090         /*!
01091          * @internal There is not late binding for this structure.
01092          * However, to maintain compatibility with the
01093          * @link #ALLOC_CP_INFO() ALLOC_CP_INFO()@endlink macro
01094          * in @link jvm/src/classfile.c classfile.c@endlink,
01095          * this empty structure is provided.
01096          */
01097     } LOCAL_Float_binding;
01098 
01099 } CONSTANT_Float_info;
01100 
01101 #ifdef CONFIG_WORDWIDTH64
01102 #define SPFTYPE_INT  unsigned int /**< 32-bit value */
01103 #else
01104 #define SPFTYPE_INT  unsigned int /**< 32-bit value */
01105 #endif
01106 
01107 /*
01108  * Representation of special case single-precision floating point
01109  * numbers
01110  */
01111 
01112 #define FLOAT_POSITIVE_INFINITY    0x7f800000
01113 #define FLOAT_NEGATIVE_INFINITY    0xff800000
01114 
01115 #define FLOAT_IS_NAN(sfpval)                       \
01116     (((0x7f800001 <= (SPFTYPE_INT) sfpval) &&    \
01117       (0x7fffffff >= (SPFTYPE_INT) sfpval))      \
01118                                                 || \
01119      ((0xff800001 <= (SPFTYPE_INT) sfpval) &&    \
01120       (0xffffffff >= (SPFTYPE_INT) sfpval)))
01121 
01122 /*@} */ /* End of grouped definitions */
01123 
01124 
01125 /*!
01126  * @name Section 4.5.5:  The CONSTANT_Long_info and
01127  *                       CONSTANT_Double_info structures
01128  */
01129 
01130 /*@{ */ /* Begin grouped definitions */
01131 
01132 typedef struct
01133 {
01134     u1 tag;
01135     u4 high_bytes;
01136     u4 low_bytes;
01137 
01138     /*** LOCAL IMPLEMENTATION LATE BINDING EXTENSIONS ***/
01139 
01140     /*!
01141      * @brief Local implementation late binding extensions for
01142      * @link #CONSTANT_Long_info CONSTANT_Long_info@endlink.
01143      *
01144      * Uses LOCAL_ as a prefix to signify an item that is @e not
01145      * part of the JVM spec itself, but an implementation detail.
01146      *
01147      */
01148     struct LOCAL_Long_binding
01149     {
01150         /*!
01151          * @internal There is not late binding for this structure.
01152          * However, to maintain compatibility with the
01153          * @link #ALLOC_CP_INFO() ALLOC_CP_INFO()@endlink macro
01154          * in @link jvm/src/classfile.c classfile.c@endlink,
01155          * this empty structure is provided.
01156          */
01157     } LOCAL_Long_binding;
01158 
01159 } CONSTANT_Long_info;
01160 
01161 typedef struct
01162 {
01163     u1 tag;
01164     u4 high_bytes;
01165     u4 low_bytes;
01166 
01167     /*** LOCAL IMPLEMENTATION LATE BINDING EXTENSIONS ***/
01168 
01169     /*!
01170      * @brief Local implementation late binding extensions for
01171      * @link #CONSTANT_Double_info CONSTANT_Double_info@endlink.
01172      *
01173      * Uses LOCAL_ as a prefix to signify an item that is @e not
01174      * part of the JVM spec itself, but an implementation detail.
01175      *
01176      */
01177     struct LOCAL_Double_binding
01178     {
01179         /*!
01180          * @internal There is not late binding for this structure.
01181          * However, to maintain compatibility with the
01182          * @link #ALLOC_CP_INFO() ALLOC_CP_INFO()@endlink macro
01183          * in @link jvm/src/classfile.c classfile.c@endlink,
01184          * this empty structure is provided.
01185          */
01186     } LOCAL_Double_binding;
01187 
01188 } CONSTANT_Double_info;
01189 
01190 #ifdef CONFIG_WORDWIDTH64
01191 #define DPFTYPE_LONG unsigned long      /**< 64-bit value */
01192 #define DPFTYPE_INT  unsigned int       /**< 32-bit value */
01193 #else
01194 #define DPFTYPE_LONG unsigned long long /**< 64-bit value */
01195 #define DPFTYPE_INT  unsigned int       /**< 32-bit value */
01196 #endif
01197 
01198 /*
01199  * Representation of special case double-precision floating point
01200  * numbers
01201  */
01202 
01203 #define DOUBLE_POSITIVE_INFINITY   0x7ff0000000000000L
01204 #define DOUBLE_NEGATIVE_INFINITY   0xfff0000000000000L
01205 
01206 #define DOUBLE_IS_NAN(dfpval)                                   \
01207     (((0x7ff00000000000001 <= (DPFTYPE_LONG) dfpval) &&   \
01208       (0x7fffffffffffffffL >= (DPFTYPE_LONG) dfpval))  || \
01209                                                                 \
01210      ((0xfff0000000000001L <= (DPFTYPE_INT) dfpval) &&        \
01211       (0xffffffffffffffffL >= (DPFTYPE_INT) dfpval)))
01212 
01213 /*@} */ /* End of grouped definitions */
01214 
01215 
01216 /*!
01217  * @name Section 4.5.6:  The CONSTANT_NameAndType_info structure
01218  *
01219  */
01220 
01221 /*@{ */ /* Begin grouped definitions */
01222 
01223 typedef struct
01224 {
01225     u1 tag;
01226     u2 name_index;
01227     u2 descriptor_index;
01228 
01229     /*** LOCAL IMPLEMENTATION LATE BINDING EXTENSIONS ***/
01230 
01231     /*!
01232      * @brief Local implementation late binding extensions for @link
01233        #CONSTANT_NameAndType_info CONSTANT_NameAndType_info@endlink.
01234      *
01235      * Uses LOCAL_ as a prefix to signify an item that is @e not
01236      * part of the JVM spec itself, but an implementation detail.
01237      *
01238      */
01239     struct LOCAL_NameAndType_binding
01240     {
01241         /*!
01242          * @internal There is not late binding for this structure.
01243          * However, to maintain compatibility with the
01244          * @link #ALLOC_CP_INFO() ALLOC_CP_INFO()@endlink macro
01245          * in @link jvm/src/classfile.c classfile.c@endlink,
01246          * this empty structure is provided.
01247          */
01248     } LOCAL_NameAndType_binding;
01249 
01250 } CONSTANT_NameAndType_info;
01251 
01252 #define CONSTANT_UTF8_INSTANCE_CONSTRUCTOR "<init>"
01253 
01254 #define CONSTANT_UTF8_INSTANCE_CONSTRUCTOR_DESCRIPTOR_DEFAULT "()V" /**<
01255                      (Not in this section of spec, but very relevant) */
01256 
01257 /*@} */ /* End of grouped definitions */
01258 
01259 
01260 /*!
01261  * @name Section 4.5.7:  Support for the CONSTANT_Utf8_info structure
01262  *
01263  * <ul>
01264  * <li>
01265  * <b>SINGLE-BYTE UTF-8 FORMAT</b>:
01266  *                           Range of 7-bit ASCII (ANSI alphabet 5),
01267  *                           but @e without the @b NUL character 0x00
01268  * </li>
01269  *
01270  * <li>
01271  * <b>DOUBLE-BYTE UTF-8 FORMAT</b>:
01272  *                           Range of 8th bit on ASCII (plus 7-bit ASCII
01273  *                           NUL character: '\\u0000', namely '\\u0080'
01274  *                           through '\\u00ff', then extending on up
01275  *                           3 more bits, thus adding '\\u100' through
01276  *                           '\\u07ff'.
01277  * </li>
01278  *
01279  * <li>
01280  * <b>TRIPLE-BYTE UTF-8 FORMAT:</b>:
01281  *                          Character ranges '\\u0800' through '\\uFFFF'
01282  * </li>
01283  *
01284  * <li>
01285  * <b>HEXTUPLE-BYTE UTF-16 FORMAT</b>:
01286  *                           There is a typographical error in spec
01287  *                           section 4.5.7 describing describing 21-bit
01288  *                           character encoding.  Therefore, this
01289  *                           format has not been implemented pending
01290  *                           proper resolution.  It probably is correct
01291  *                           to assume that the spurious "-1" in the
01292  *                           second byte of the first triple should say
01293  *                           "(bits 20-16)" instead of "(bits 20-16)-1".
01294  *                           This needs to be researched and
01295  *                           implemented for full spec compliance.
01296  * </li>
01297  *
01298  * <li>
01299  * <b>OTHER UTFx FORMATS</b>: The JVM does not (yet) recognized these.
01300  * </li>
01301  * </ul>
01302  *
01303  *
01304  * @todo: Clarify the hextuple-byte UTF-16 encoding requirements, per
01305  *        above commentary.
01306  *
01307  */
01308 
01309 
01310 /*@{ */ /* Begin grouped definitions */
01311 
01312 /* SINGLE-BYTE UTF-8 FORMAT */
01313 
01314 #define UTF8_SINGLE_MIN   0x01  /**< '\\u0001', UTF-8 representation */
01315 #define UTF8_SINGLE_MAX   0x7f  /**< '\\u007f', UTF-8 representation */
01316 
01317 #define UTF8_SINGLE_MASK1 0x80  /**< Bit 7 must be clear */
01318 #define UTF8_SINGLE_MASK0 0x7f  /**< Bits 0-6 contain data
01319                                      (except != 0, or NUL) */
01320 
01321 #define UNICODE_SINGLE_MIN 0x0001 /**< '\\u0001', Unicode
01322                                        representation */
01323 #define UNICODE_SINGLE_MAX 0x007f /**< '\\u007f', Unicode
01324                                        representation */
01325 
01326 
01327 /* DOUBLE-BYTE UTF-8 FORMAT */
01328 
01329 #define UTF8_DOUBLE_NUL 0x0000  /**< '\\u0000', UTF-8 representation */
01330 #define UTF8_DOUBLE_MIN 0x0080  /**< '\\u0080', UTF-8 representation */
01331 #define UTF8_DOUBLE_MAX 0x07ff  /**< '\\u07ff', UTF-8 representation */
01332 
01333 #define UNICODE_DOUBLE_NUL 0x0000  /**< '\\u0000', Unicode
01334                                         representation */
01335 #define UNICODE_DOUBLE_MIN 0x0080  /**< '\\u0080', Unicode
01336                                         representation */
01337 #define UNICODE_DOUBLE_MAX 0x07ff  /**< '\\u07ff', Unicode
01338                                         representation */
01339 
01340 
01341 /* Definition of first byte (byte "x") of two-byte format: */
01342 
01343 #define UTF8_DOUBLE_FIRST_MASK1  0xe0  /**< Top 3 bits of first byte */
01344 #define UTF8_DOUBLE_FIRST_VAL    0xc0  /**< Top 3 bits are '110' */
01345 
01346 #define UTF8_DOUBLE_FIRST_MASK0  0x1f  /**< Bottom 5 bits contain data
01347                                             bits 10-6 */
01348 #define UTF8_DOUBLE_FIRST_SHIFT     6  /**< Move first byte up to bits
01349                                             10-6 */
01350 
01351 
01352 /* Definition of second byte (byte "y") of two-byte format: */
01353 
01354 #define UTF8_DOUBLE_SECOND_MASK1 0xc0  /**< Top 2 bits of second byte */
01355 #define UTF8_DOUBLE_SECOND_VAL   0x80  /**< Top 2 bits are '10' */
01356 
01357 #define UTF8_DOUBLE_SECOND_MASK0 0x3f  /**< Bottom 6 bits contain data
01358                                             bits 0-5 */
01359 
01360 
01361 /* TRIPLE-BYTE UTF-8 FORMAT: */
01362 
01363 #define UTF8_TRIPLE_MIN 0x0800  /**< '\\u0800', UTF-8 representation */
01364 #define UTF8_TRIPLE_MAX 0xffff  /**< '\\uffff', UTF-8 representation */
01365 
01366 #define UNICODE_TRIPLE_MIN 0x0800  /**< '\\u0800', Unicode
01367                                         representation */
01368 #define UNICODE_TRIPLE_MAX 0xffff  /**< '\\uffff', Unicode
01369                                         representation */
01370 
01371 
01372 /* Definition of first byte (byte "x") of three-byte format: */
01373 
01374 #define UTF8_TRIPLE_FIRST_MASK1  0xf0  /**! Top 4 bits of first byte */
01375 #define UTF8_TRIPLE_FIRST_VAL    0xe0  /**! Top 4 bits are '1110' */
01376 
01377 #define UTF8_TRIPLE_FIRST_MASK0  0x0f  /**! Bottom 5 bits contain data
01378                                             bits 15-12 */
01379 #define UTF8_TRIPLE_FIRST_SHIFT    12  /**! Move first byte up to
01380                                             bits 15-12 */
01381 
01382 
01383 /* Definition of second byte (byte "y") of three-byte format: */
01384 
01385 #define UTF8_TRIPLE_SECOND_MASK1 0xc0  /**! Top 2 bits of second byte */
01386 #define UTF8_TRIPLE_SECOND_VAL   0x80  /**! Top 2 bits are '10' */
01387 
01388 #define UTF8_TRIPLE_SECOND_MASK0 0x3f  /**! Bottom 6 bits contain data
01389                                             bits 11-6 */
01390 #define UTF8_TRIPLE_SECOND_SHIFT    6  /**! Move second byte up to
01391                                             bits 10-6 */
01392 
01393 
01394 /* Definition of third byte (byte "z") of three-byte format: */
01395 
01396 #define UTF8_TRIPLE_THIRD_MASK1  0xc0  /**! Top 2 bits of third byte */
01397 #define UTF8_TRIPLE_THIRD_VAL    0x80  /**! Top 2 bits are '10' */
01398 
01399 #define UTF8_TRIPLE_THIRD_MASK0  0x3f  /**! Bottom 6 bits contain data
01400                                             bits 5-0 */
01401 
01402 /*@} */ /* End of grouped definitions */
01403 
01404 
01405 /*!
01406  * @name Section 4.5.7:  The CONSTANT_Utf8_info structure itself
01407  *
01408  */
01409 
01410 /*@{ */ /* Begin grouped definitions */
01411 
01412 typedef struct
01413 {
01414     u1 tag;
01415     u2 length;
01416     u1 bytes[1];  /**< spec says:
01417                        <b><code>u1 bytes[length];</code></b> */
01418 
01419     /*** LOCAL IMPLEMENTATION LATE BINDING EXTENSIONS ***/
01420 
01421     /*!
01422      * @brief Local implementation late binding extensions for
01423      * @link #CONSTANT_Utf8_info CONSTANT_Utf8_info@endlink.
01424      *
01425      * Uses LOCAL_ as a prefix to signify an item that is @e not
01426      * part of the JVM spec itself, but an implementation detail.
01427      *
01428      */
01429     struct LOCAL_Utf8_binding
01430     {
01431         /*!
01432          * @internal There is not late binding for this structure.
01433          * However, to maintain compatibility with the
01434          * @link #ALLOC_CP_INFO() ALLOC_CP_INFO()@endlink macro
01435          * in @link jvm/src/classfile.c classfile.c@endlink,
01436          * this empty structure is provided.
01437          */
01438     } LOCAL_Utf8_binding;
01439 
01440 } CONSTANT_Utf8_info;
01441 
01442 /*@} */ /* End of grouped definitions */
01443 
01444 
01445 /*!
01446  * @name Forbidden UTF values.
01447  *
01448  * @brief No byte in bytes[] may contain these values because
01449  * they present certain parsing problems in the Java subset of UTF-8.
01450  *
01451  */
01452 /*@{ */ /* Begin grouped definitions */
01453 
01454 #define UTF8_FORBIDDEN_ZERO      0x00  /**< Looks suspiciously like
01455                                             ASCII NUL */
01456 
01457 #define UTF8_FORBIDDEN_MIN       0xf0  /**< Min of range for 4-byte UTF
01458                                             values,etc */
01459 #define UTF8_FORBIDDEN_MAX       0xff  /**< Max of forbidden range */
01460 
01461 /*@} */ /* End of grouped definitions */
01462 
01463 
01464 /*!
01465  * @name Section 4.6: Fields
01466  *
01467  * Table 4.4: Access Flags for Fields (New comments,
01468  * plus new definitions)
01469  *
01470  * typedef struct field_info:  See forward references
01471  * above definition of ClassFile.
01472  *
01473  * Defined first in section 4.6 (Fields), possibly later also.
01474  *
01475  * For other @link #ACC_PUBLIC ACC_xxx@endlink definitions,
01476  * see also table 4.1, 4.5, 4.7.
01477  *
01478  */
01479 
01480 /*@{ */ /* Begin grouped definitions */
01481 
01482 /*      ACC_PUBLIC           */
01483 
01484 #define ACC_PRIVATE   0x0002 /**< Declared @c @b private ; usable only
01485                                   within the defining class. */
01486 
01487 #define ACC_PROTECTED 0x0004 /**< Declared @c @b protected ; may be
01488                                   accessed within subclasses. */
01489 
01490 #define ACC_STATIC    0x0008 /**< Declared @c @b static . */
01491 
01492 /*      ACC_FINAL            ** Declared @c @b final ; no further
01493                                   assignment after initialization. */
01494 
01495 #define ACC_VOLATILE  0x0040 /**< Declared @c @b volatile ; cannot be
01496                                    cached */
01497 
01498 #define ACC_TRANSIENT 0x0080 /**< Declared @c @b transient ; not written
01499                                   or read by a persistent object
01500                                   manager */
01501 
01502 /*      ACC_SYNTHETIC        ** Declared @c @b synthetic ; not present
01503                                   in the source code. */
01504 
01505 /*      ACC_ENUM             ** Declared as an enum type */
01506 
01507 /*@} */ /* End of grouped definitions */
01508 
01509 
01510 /*!
01511  * @name Section 4.7:  Methods
01512  *
01513  * Table 4.5:  Access Flags for methods (New comments,
01514  * plus new definitions)
01515  *
01516  *
01517  * typedef struct method_info:  See forward references
01518  * above definition of ClassFile
01519  *
01520  * Defined first in section 4.7 (Methods), possibly later also.
01521  *
01522  * For other @link #ACC_PUBLIC ACC_xxx@endlink definitions,
01523  * see also table 4.1, 4.4, 4.7.
01524  */
01525 
01526 /*@{ */ /* Begin grouped definitions */
01527 
01528 /*      ACC_PUBLIC           */
01529 /*      ACC_PRIVATE          */
01530 /*      ACC_PROTECTED        */
01531 /*      ACC_STATIC           */
01532 /*      ACC_FINAL            **Declared @c @b final ; may not be
01533                                   overridden */
01534 #define ACC_SYNCHRONIZED 0x0010 /**< Declared @c @b synchronized ;
01535                                    invokation is wrapped in a
01536                                     monitor lock. */
01537 
01538 #define ACC_BRIDGE    0x0040    /**< A bridge method, generated by the
01539                                   compiler. */
01540 
01541 #define ACC_VARARGS   0x0080    /**< Declared with variable number of
01542                                   arguments. */
01543 
01544 #define ACC_NATIVE    0x0100    /**< Declared @c @b native ; implemented
01545                                      in a language other than Java. */
01546 
01547 /*      ACC_ABSTRACT            ** Declared @c @b abstract ; no
01548                                   implementation is provided. */
01549 
01550 #define ACC_STRICT    0x0800    /**< Declared @c @b strictfp ;
01551                                      floating-point mode is FP-strict */
01552 
01553 /*      ACC_SYNTHETIC           ** Declared @c @b synthetic ; not
01554                                    present in the source code. */
01555 
01556 
01557 /*@} */ /* End of grouped definitions */
01558 
01559 
01560 /*!
01561  * @name Section 4.8.1:  Defining and Naming new Attributes
01562  *
01563  * typedef struct attribute_info: See forward references
01564  * above definition of ClassFile
01565  *
01566  */
01567 
01568 /*@{ */ /* Begin grouped definitions */
01569 
01570 #define LOCAL_CONSTANT_UTF8_UNKNOWN_ATTRIBUTE "Unknown" /**<
01571                                                           Not in spec*/
01572 
01573 #define               LOCAL_UNKNOWN_ATTRIBUTE_ENUM   0 /**<
01574                                                           Not in spec */
01575 
01576 /*@} */ /* End of grouped definitions */
01577 
01578 
01579 /*!
01580  * @name Section 4.8.2:  The ConstantValue Attribute
01581  *
01582  * See also table 4.6:  Valid ConstantValue Field Types
01583  *
01584  */
01585 
01586 /*@{ */ /* Begin grouped definitions */
01587 
01588 typedef struct
01589 {
01590     u2 attribute_name_index;
01591     u4 attribute_length;
01592     u2 constantvalue_index;
01593 
01594 } ConstantValue_attribute;
01595 
01596 #define CONSTANT_UTF8_CONSTANTVALUE_ATTRIBUTE "ConstantValue"
01597 
01598 #define       CONSTANTVALUE_ATTRIBUTE_LENGTH 2
01599 #define LOCAL_CONSTANTVALUE_ATTRIBUTE_ENUM   1 /**< Not in spec */
01600 
01601 
01602 /* Table 4.6:  Valid ConstantValue Field Types */
01603 
01604 /*           CONSTANT_Long      */
01605 /*           CONSTANT_Float     */
01606 /*           CONSTANT_Double    */
01607 /*           CONSTANT_Integer   */
01608 /*           CONSTANT_String    */
01609 
01610 /*@} */ /* End of grouped definitions */
01611 
01612 /*!
01613  * @name Section 4.8.3:  The Code Attribute
01614  *
01615  */
01616 
01617 /*@{ */ /* Begin grouped definitions */
01618 
01619 /*!
01620  * @brief The class file @b exception_table structure, here named
01621  * as @b exception_table_entry (to avoid naming conflicts in code
01622  * versus spec requirements).
01623  *
01624  * See section 4.8.3.
01625  *
01626  */
01627 typedef struct
01628 {
01629     u2 start_pc;
01630     u2 end_pc;
01631     u2 handler_pc;
01632     u2 catch_type;
01633 
01634 } exception_table_entry;
01635 
01636 
01637 typedef struct
01638 {
01639     u2 attribute_name_index;
01640     u4 attribute_length;
01641     u2 max_stack;
01642     u2 max_locals;
01643 
01644     u4 code_length;
01645     u1 *code;      /**< Spec pseudo-code: @c @b code[code_length]; */
01646 
01647     u2 exception_table_length;
01648     exception_table_entry *exception_table; /**< Spec pseudo-code:
01649                        @c @b exception_table[exception_table_length]; */
01650 
01651     u2 attributes_count;
01652     attribute_info_dup **attributes; /**< Spec pseudo-code:
01653                    @c @b attribute_info attributes[attributes_count]; */
01654 
01655 } Code_attribute;
01656 
01657 #define CONSTANT_UTF8_CODE_ATTRIBUTE                  "Code"
01658 
01659 #define         LOCAL_CODE_ATTRIBUTE_ENUM             2 /**< Not
01660                                                                in spec*/
01661 
01662 #define CODE_ATTRIBUTE_MAX_LOCALS_BOUNDARY_LONGDOUBLE 2
01663 
01664 #define CODE_ATTRIBUTE_MAX_LOCALS_BOUNDARY_OTHERS     1
01665 
01666 /*@} */ /* End of grouped definitions */
01667 
01668 
01669 /*!
01670  * @name Section 4.8.4:  The Exceptions Attribute
01671  *
01672  */
01673 
01674 /*@{ */ /* Begin grouped definitions */
01675 
01676 typedef struct
01677 {
01678     u2 attribute_name_index;
01679     u4 attribute_length;
01680     u2 number_of_exceptions;
01681 
01682     u2 exception_index_table[1]; /**< Mark space only for one.
01683                                       Spec pseudo-code:
01684                    @c @b exception_index_table[number_of_exceptions]; */
01685 
01686 } Exceptions_attribute;
01687 
01688 #define CONSTANT_UTF8_EXCEPTIONS_ATTRIBUTE      "Exceptions"
01689 
01690 #define         LOCAL_EXCEPTIONS_ATTRIBUTE_ENUM 3 /**< Not in spec */
01691 
01692 #define CODE_DEFAULT_CATCH_TYPE                 0 /**<  This handler is
01693                                                    for all exceptions */
01694 
01695 /*@} */ /* End of grouped definitions */
01696 
01697 
01698 /*!
01699  * @name Section 4.8.5:  The InnerClasses Attribute
01700  *
01701  * For other @link #ACC_PUBLIC ACC_xxx@endlink definitions,
01702  * see also table 4.1, 4.4, 4.5.
01703  *
01704  */
01705 
01706 /*@{ */ /* Begin grouped definitions */
01707 
01708 /*!
01709  * @brief The class file @b inner_class_table_entry structure
01710  * (anonymous in spec).
01711  *
01712  * See section 4.8.5.
01713  *
01714  */
01715 typedef struct
01716 {
01717     u2 inner_class_info_index;
01718     u2 outer_class_info_index;
01719     u2 inner_name_index;
01720     u2 inner_class_access_flags;
01721 
01722 } inner_class_table_entry;
01723 
01724 
01725 typedef struct
01726 {
01727     u2 attribute_name_index;
01728     u4 attribute_length;
01729     u2 number_of_classes;
01730     inner_class_table_entry classes[1]; /**< Mark space only for one.
01731                                              Spec pseudo-code:
01732                                     @c @b classes[number_of_classes]; */
01733 } InnerClasses_attribute;
01734 
01735 #define CONSTANT_UTF8_INNERCLASSES_ATTRIBUTE      "InnerClasses"
01736 
01737 #define         LOCAL_INNERCLASSES_ATTRIBUTE_ENUM 4 /**< Not in spec */
01738 
01739 /* Defined first in section 4.8.5 (The @b InnerClasses attribute),
01740                                                   possibly later also */
01741 
01742 /* Table 4.7: Access Flags for Attributes (New cmts, all defn's above)*/
01743 
01744 /*      ACC_PUBLIC         ** Marked or implicitly @c @b public
01745                                 in source. */
01746 
01747 /*      ACC_PRIVATE        ** Marked @c @b private in source. */
01748 
01749 /*      ACC_PROTECTED      ** Marked @c @b protected in source. */
01750 
01751 /*      ACC_STATIC         ** Marked or implicitly @c @b static
01752                                 in source. */
01753 
01754 /*      ACC_FINAL          ** Marked @c @b final in source. */
01755 
01756 /*      ACC_INTERFACE      ** Was an @c @b interface in source. */
01757 
01758 /*      ACC_ABSTRACT       ** Marked or implicitly @@c b abstract
01759                                 in source. */
01760 
01761 /*      ACC_SYNTHETIC      ** Declared @c @b synthetic ; not present
01762                                 in source. */
01763 
01764 /*      ACC_ANNOTATION     ** Declared as an annotation type */
01765 
01766 /*      ACC_ENUM           ** Declared as an enum type */
01767 
01768 /*@} */ /* End of grouped definitions */
01769 
01770 
01771 /*!
01772  * @name Section 4.8.6:  The EnclosingMethod Attribute
01773  *
01774  */
01775 
01776 /*@{ */ /* Begin grouped definitions */
01777 
01778 typedef struct
01779 {
01780     u2 attribute_name_index;
01781     u4 attribute_length;
01782     u2 class_index;
01783     u2 method_index;
01784 
01785 } EnclosingMethod_attribute;
01786 
01787 #define CONSTANT_UTF8_ENCLOSINGMETHOD_ATTRIBUTE        "EnclosingMethod"
01788 
01789 #define               ENCLOSINGMETHOD_ATTRIBUTE_LENGTH     4
01790 
01791 #define               LOCAL_ENCLOSINGMETHOD_ATTRIBUTE_ENUM 5 /**< Not
01792                                                               in spec */
01793 
01794 /*@} */ /* End of grouped definitions */
01795 
01796 
01797 /*!
01798  * @name Section 4.8.7:  The Synthetic Attribute
01799  *
01800  */
01801 
01802 /*@{ */ /* Begin grouped definitions */
01803 
01804 typedef struct
01805 {
01806     u2 attribute_name_index;
01807     u4 attribute_length;
01808 
01809 } Synthetic_attribute;
01810 
01811 #define CONSTANT_UTF8_SYNTHETIC_ATTRIBUTE        "Synthetic"
01812 
01813 #define               SYNTHETIC_ATTRIBUTE_LENGTH 0
01814 
01815 #define         LOCAL_SYNTHETIC_ATTRIBUTE_ENUM   7 /**< Not in spec */
01816 
01817 /*@} */ /* End of grouped definitions */
01818 
01819 
01820 /*!
01821  * @name Section 4.8.8:  The Signature Attribute
01822  *
01823  */
01824 
01825 /*@{ */ /* Begin grouped definitions */
01826 
01827 typedef struct
01828 {
01829     u2 attribute_name_index;
01830     u4 attribute_length;
01831     u2 signature_index;
01832 
01833 } Signature_attribute;
01834 
01835 #define CONSTANT_UTF8_SIGNATURE_ATTRIBUTE        "Signature"
01836 
01837 #define               SIGNATURE_ATTRIBUTE_LENGTH 2
01838 
01839 #define         LOCAL_SIGNATURE_ATTRIBUTE_ENUM   6 /**< Not in spec */
01840 
01841 /*@} */ /* End of grouped definitions */
01842 
01843 
01844 /*!
01845  * @name Section 4.8.9:  The SourceFile Attribute
01846  *
01847  */
01848 
01849 /*@{ */ /* Begin grouped definitions */
01850 
01851 typedef struct
01852 {
01853     u2 attribute_name_index;
01854     u4 attribute_length;
01855     u2 sourcefile_index;
01856 
01857 } SourceFile_attribute;
01858 
01859 
01860 #define CONSTANT_UTF8_SOURCEFILE_ATTRIBUTE        "SourceFile"
01861 
01862 #define               SOURCEFILE_ATTRIBUTE_LENGTH 2
01863 
01864 #define         LOCAL_SOURCEFILE_ATTRIBUTE_ENUM   8 /**< Not in spec */
01865 
01866 /*@} */ /* End of grouped definitions */
01867 
01868 
01869 /*!
01870  * @name Section 4.8.10:  The LineNumberTable Attribute
01871  *
01872  */
01873 
01874 /*@{ */ /* Begin grouped definitions */
01875 
01876 /*!
01877  * @brief The class file @b line_number_table_entry structure
01878  * (anonymous in spec).
01879  *
01880  * See section 4.8.10.
01881  *
01882  */
01883 typedef struct
01884 {
01885     u2 start_pc;
01886     u2 line_number;
01887 
01888 } line_number_table_entry;
01889 
01890 
01891 typedef struct
01892 {
01893     u2 attribute_name_index;
01894     u4 attribute_length;
01895     u2 line_number_table_length;
01896     line_number_table_entry line_number_table[1]; /**< Mark space only
01897                    for one.  Spec pseudo-code:
01898                    @c @b line_number_table[line_number_table_length]; */
01899 
01900 } LineNumberTable_attribute;
01901 
01902 #define CONSTANT_UTF8_LINENUMBERTABLE_ATTRIBUTE      "LineNumberTable"
01903 
01904 #define         LOCAL_LINENUMBERTABLE_ATTRIBUTE_ENUM 9 /**< Not in
01905                                                                  spec */
01906 
01907 /*@} */ /* End of grouped definitions */
01908 
01909 
01910 /*!
01911  * @name Section 4.8.11:  The LocalVariableTable Attribute
01912  *
01913  */
01914 
01915 /*@{ */ /* Begin grouped definitions */
01916 
01917 /*!
01918  * @brief The class file @b local_variable_table_entry structure
01919  * (anonymous in spec).
01920  *
01921  * See section 4.8.11.
01922  *
01923  */
01924 typedef struct
01925 {
01926     u2 start_pc;
01927     u2 length;
01928     u2 name_index;
01929     u2 descriptor_index;
01930     u2 index;
01931 
01932 } local_variable_table_entry;
01933 
01934 
01935 typedef struct
01936 {
01937     u2 attribute_name_index;
01938     u4 attribute_length;
01939     u2 local_variable_table_length;
01940     local_variable_table_entry local_variable_table[1]; /**< Mark space
01941              only for one.  Spec pseudo-code:
01942              @c @b local_variable_table[local_variable_table_length]; */
01943 
01944 
01945 } LocalVariableTable_attribute;
01946 
01947 #define CONSTANT_UTF8_LOCALVARIABLETABLE_ATTRIBUTE  "LocalVariableTable"
01948 
01949 #define         LOCAL_LOCALVARIABLETABLE_ATTRIBUTE_ENUM 10 /**< Not in
01950                                                                  spec */
01951 
01952 /*@} */ /* End of grouped definitions */
01953 
01954 
01955 /*!
01956  * @name Section 4.8.12:  The LocalVariableTypeTable Attribute
01957  *
01958  */
01959 
01960 /*@{ */ /* Begin grouped definitions */
01961 
01962 /*!
01963  * @brief The class file @b local_variable_type_table_entry structure
01964  * (anonymous in spec).
01965  *
01966  * See section 4.8.12.
01967  *
01968  */
01969 typedef struct
01970 {
01971     u2 start_pc;
01972     u2 length;
01973     u2 name_index;
01974     u2 signature_index;
01975     u2 index;
01976 
01977 } local_variable_type_table_entry;
01978 
01979 
01980 typedef struct
01981 {
01982     u2 attribute_name_index;
01983     u4 attribute_length;
01984     u2 local_variable_type_table_length;
01985     local_variable_type_table_entry local_variable_type_table[1]; /**<
01986         Mark space only for one.  Spec pseudo-code:
01987         @c @b local_variable_table[local_variable_type_table_length]; */
01988 
01989 } LocalVariableTypeTable_attribute;
01990 
01991 #define CONSTANT_UTF8_LOCALVARIABLETYPETABLE_ATTRIBUTE \
01992                                                 "LocalVariableTypeTable"
01993 
01994 #define         LOCAL_LOCALVARIABLETYPETABLE_ATTRIBUTE_ENUM 11 /**< Not
01995                                                               in spec */
01996 
01997 /*@} */ /* End of grouped definitions */
01998 
01999 
02000 /*!
02001  * @name Section 4.8.13:  The Deprecated Attribute
02002  *
02003  */
02004 
02005 /*@{ */ /* Begin grouped definitions */
02006 
02007 typedef struct
02008 {
02009     u2 attribute_name_index;
02010     u4 attribute_length;
02011 
02012 } Deprecated_attribute;
02013 
02014 #define CONSTANT_UTF8_DEPRECATED_ATTRIBUTE        "Deprecated"
02015 
02016 #define               DEPRECATED_ATTRIBUTE_LENGTH 0
02017 
02018 #define         LOCAL_DEPRECATED_ATTRIBUTE_ENUM   12 /**< Not in spec */
02019 
02020 /*@} */ /* End of grouped definitions */
02021 
02022 
02023 /*!
02024  * @name Section 4.8.14:  The RuntimeVisibleAnnotations Attribute
02025  *
02026  * Xtodo When implementing @b RuntimeXxxAnnotations attributes,
02027  * MAKE SURE to understand the implications of
02028  * @link #ARCH_ODD2_ADDRESS_SIGSEGV ARCH_ODD2_ADDRESS_SIGSEGV@endlink
02029  * and
02030  * @link #ARCH_ODD4_ADDRESS_SIGSEGV ARCH_ODD4_ADDRESS_SIGSEGV@endlink
02031  * upon 2- and 4-byte integer storage accesses, respectively.
02032  */
02033 
02034 /*@{ */ /* Begin grouped definitions */
02035 
02036 /*!
02037  * @brief The class file @b enum_const_value structure
02038  *
02039  * See section 4.8.14.1.
02040  *
02041  */
02042 typedef struct
02043 {
02044     u2 type_name_index;
02045     u2 const_name_index;
02046 
02047 } enum_const_value;
02048 
02049 
02050 /*!
02051  * @brief The class file @b element_value structure
02052  *
02053  * Section 4.8.14.1:  The @b element_value structure
02054  *
02055  */
02056 typedef struct
02057 {
02058     u1 tag;
02059 
02060     /*!
02061      * @internal BREAKS COMPILER if declared,
02062      *
02063 
02064     values_union _value;
02065 
02066      *
02067      * due to circular member type references, so access
02068      * it this way:
02069      *
02070      *     values_union *pv = (values_union *) &variablename.value;
02071      *
02072      *     pv->member ...
02073      *
02074      * To access both members of this structure, use the following
02075      * approach:
02076      *
02077      *     element_value var, *ptr;
02078      *
02079      *     var.tag;
02080      *     ELEMENT_VALUE(var).value._const_value_index;
02081      *     ELEMENT_VALUE(var).value._enum_const_value;
02082      *
02083      *     ptr->tag;
02084      *     PTR_ELEMENT_VALUE(ptr)->value._const_value_index;
02085      *     PTR_ELEMENT_VALUE(ptr)->value._enum_const_value;
02086      */
02087 
02088     u1 value;
02089 
02090 } element_value;
02091 
02092 /* Facilitate access to @c @b element_value.value member */
02093 #define ELEMENT_VALUE(var)     (*(values_union *) &(&var)->_value)
02094 #define PTR_ELEMENT_VALUE(ptr) ( (values_union *) &(ptr)->_value)
02095 
02096 
02097 /*!
02098  * @brief The class file @b element_value_pair structure
02099  *
02100  * See section 4.8.14.
02101  *
02102  */
02103 typedef struct
02104 {
02105     u2            element_value_index;
02106     element_value value;
02107 
02108 } element_value_pair;
02109 
02110 
02111 /*!
02112  * @brief The class file @b annotation structure definition.
02113  *
02114  * See spec section 4.8.14.
02115  *
02116  */
02117 typedef struct
02118 {
02119     u2 type_index;
02120     u2 num_element_value_pairs;
02121 
02122     element_value_pair element_value_pairs[1]; /**< Mark space only
02123                  for one.  Spec pseudo-code:
02124                  @c @b element_value_pairs[num_element_value_pairs] */
02125 
02126 } annotation;
02127 
02128 
02129 /*!
02130  * @brief The class file @b array_value structure definition.
02131  *
02132  * See spec section 4.8.14.1.
02133  *
02134  */
02135 typedef struct
02136 {
02137     u2            num_values;
02138 
02139     element_value values[1]; /**< Mark space only for one.  Spec
02140                  pseudo-code: @c @b element_value values[num_values]; */
02141 
02142 } array_values;
02143 
02144 
02145 /*!
02146  * @brief The class file @b values_union structure
02147  * (anonymous in spec).
02148  *
02149  * See section 4.8.14.1.
02150  *
02151  */
02152 typedef union
02153 {
02154     u2                _const_value_index;
02155     enum_const_value  _enum_const_value;
02156     u2                _class_info_index;
02157     annotation        _annotation_value;
02158     array_values      _array_value;
02159 
02160 } values_union;
02161 
02162 
02163 typedef struct
02164 {
02165     u2 attribute_name_index;
02166     u4 attribute_length;
02167     u2 num_annotations;
02168     annotation **annotations; /**< Spec pseudo-code:
02169                        @c @b annotation annotations[num_annotations]; */
02170 
02171 } RuntimeVisibleAnnotations_attribute;
02172 
02173 #define CONSTANT_UTF8_RUNTIMEVISIBLEANNOTATIONS_ATTRIBUTE \
02174                                              "RuntimeVisibleAnnotations"
02175 
02176 #define         LOCAL_RUNTIMEVISIBLEANNOTATIONS_ATTRIBUTE_ENUM 13 /**<
02177                                                           Not in spec */
02178 
02179 /*@} */ /* End of grouped definitions */
02180 
02181 
02182 /*!
02183  * @brief The @b RuntimeInvisibleAnnotations Attribute
02184  *
02185  * See spec section 4.8.15: The @b RuntimeInvisibleAnnotations Attribute
02186  *
02187  */
02188 
02189 /*@{ */ /* Begin grouped definitions */
02190 
02191 typedef struct
02192 {
02193     u2 attribute_name_index;
02194     u4 attribute_length;
02195     u2 num_annotations;
02196     annotation **annotations; /**< Spec pseudo-code:
02197                                   @c @b annotations[num_annotations]; */
02198 
02199 } RuntimeInvisibleAnnotations_attribute;
02200 
02201 #define CONSTANT_UTF8_RUNTIMEINVISIBLEANNOTATIONS_ATTRIBUTE \
02202                                          "RuntimeInvisibleAnnotations"
02203 
02204 #define         LOCAL_RUNTIMEINVISIBLEANNOTATIONS_ATTRIBUTE_ENUM 14 /**<
02205                                                           Not in spec */
02206 
02207 /*@} */ /* End of grouped definitions */
02208 
02209 
02210 /*!
02211  * @brief The @b RuntimeVisibleParameterAnnotations Attribute
02212  *
02213  * See spec section 4.8.16:  The @b RuntimeVisibleParameterAnnotations
02214  * Attribute
02215  *
02216  */
02217 
02218 /*@{ */ /* Begin grouped definitions */
02219 
02220 typedef struct
02221 {
02222     u2 num_annotations;
02223     annotation **annotations; /**< Spec pseudo-code:
02224                                   @c @b annotations[num_annotations]; */
02225 
02226 } parameter_annotation;
02227 
02228 typedef struct
02229 {
02230     u2 attribute_name_index;
02231     u4 attribute_length;
02232     u2 num_parameters;
02233     parameter_annotation **parameter_annotations; /**< Spec pseudo-code:
02234                          @c @b parameter_annotations[num_parameters]; */
02235 
02236 } RuntimeVisibleParameterAnnotations_attribute;
02237 
02238 #define CONSTANT_UTF8_RUNTIMEVISIBLEPARAMETERANNOTATIONS_ATTRIBUTE \
02239                                     "RuntimeVisibleParameterAnnotations"
02240 
02241 #define       LOCAL_RUNTIMEVISIBLEPARAMETERANNOTATIONS_ATTRIBUTE_ENUM 15
02242                                                      /**< Not in spec */
02243 
02244 /*@} */ /* End of grouped definitions */
02245 
02246 
02247 /*!
02248  * @brief The @b RuntimeInvisibleParameterAnnotations Attribute
02249  *
02250  * See spec section 4.8.17: The @b RuntimeInvisibleParameterAnnotations
02251  * Attribute
02252  *
02253  */
02254 
02255 /*@{ */ /* Begin grouped definitions */
02256 
02257 typedef struct
02258 {
02259     u2 attribute_name_index;
02260     u4 attribute_length;
02261     u2 num_parameters;
02262     parameter_annotation **parameter_annotations; /**< Spec pseudo-code:
02263                          @c @b parameter_annotations[num_parameters]; */
02264 
02265 } RuntimeInvisibleParameterAnnotations_attribute;
02266 
02267 #define CONSTANT_UTF8_RUNTIMEINVISIBLEPARAMETERANNOTATIONS_ATTRIBUTE \
02268                                 "RuntimeInvisibleParameterAnnotations"
02269 
02270 #define     LOCAL_RUNTIMEINVISIBLEPARAMETERANNOTATIONS_ATTRIBUTE_ENUM 16
02271                                                      /**< Not in spec */
02272 
02273 /*@} */ /* End of grouped definitions */
02274 
02275 
02276 /*!
02277  * @brief The @b AnnotationDefault Attribute
02278  *
02279  * See spec section 4.8.18: The @b AnnotationDefault Attribute
02280  *
02281  */
02282 
02283 /*@{ */ /* Begin grouped definitions */
02284 
02285 typedef struct
02286 {
02287     u2            attribute_name_index;
02288     u4            attribute_length;
02289     u2            num_parameters;
02290     element_value default_value;
02291 
02292 } AnnotationDefault_attribute;
02293 
02294 #define CONSTANT_UTF8_ANNOTATIONDEFAULT_ATTRIBUTE    "AnnotationDefault"
02295 
02296 #define         LOCAL_ANNOTATIONDEFAULT_ATTRIBUTE_ENUM 17 /**< Not in
02297                                                                  spec */
02298 
02299 /*@} */ /* End of grouped definitions */
02300 
02301 
02302 /*!
02303  * @name Table 4.8:  Additional tag values for annotation attributes
02304  *
02305  */
02306 
02307 /*@{ */ /* Begin grouped definitions */
02308 
02309 #define BASETYPE_CHAR_s    's'   /**< String */
02310 #define BASETYPE_CHAR_e    'e'   /**< enum constant */
02311 #define BASETYPE_CHAR_c    'c'   /**< Class */
02312 #define BASETYPE_CHAR_AT   '@'   /**< Annotation type */
02313 /*      BASETYPE_CHAR_ARRAY         Array (see also table 4.2) */
02314 
02315 #define BASETYPE_STRING_CHAR_ARRAY "[C" /**< @c @b java.lang.String
02316                                           (jchar)[] @p @b value field */
02317 
02318 /*@} */ /* End of grouped definitions */
02319 
02320 
02321 /*!
02322  * @name Section 4.9:  Format Checking
02323  *
02324  */
02325 
02326 /*!
02327  * @name Section 4.10:  Constraints on Java Virtual Machine Code
02328  *
02329  */
02330 
02331 /*!
02332  * @name Section 4.10.1:  Static Constraints
02333  *
02334  */
02335 
02336 /*@{ */ /* Begin grouped definitions */
02337 
02338 #define CODE_CONSTRAINT_CODE_LENGTH_MIN 1 /**< Array size bounds,bytes*/
02339 #define CODE_CONSTRAINT_CODE_LENGTH_MAX 65535
02340 
02341 #define CODE_CONSTRAINT_START_PC        0   /**< Start PC location */
02342 
02343 #define LOCAL_CONSTANT_UTF8_CLASS_CONSTRUCTOR "<clinit>"
02344                                           /**< Not in spec,but implied*/
02345 #define LOCAL_CONSTANT_UTF8_CLASS_CONSTRUCTOR_PARMS "()V"
02346 
02347 #define CODE_CONSTRAINT_OP_INVOKEINTERFACE_PARM4 0
02348 #define CODE_CONSTRAINT_OP_ANEWARRAY_MAX_DIMS  CONSTANT_MAX_ARRAY_DIMS
02349 
02350 #define CODE_CONSTRAINT_OP_NEWARRAY_TYPE_T_BOOLEAN 4
02351 #define CODE_CONSTRAINT_OP_NEWARRAY_TYPE_T_CHAR    5
02352 #define CODE_CONSTRAINT_OP_NEWARRAY_TYPE_T_FLOAT   6
02353 #define CODE_CONSTRAINT_OP_NEWARRAY_TYPE_T_DOUBLE  7
02354 #define CODE_CONSTRAINT_OP_NEWARRAY_TYPE_T_BYTE    8
02355 #define CODE_CONSTRAINT_OP_NEWARRAY_TYPE_T_SHORT   9
02356 #define CODE_CONSTRAINT_OP_NEWARRAY_TYPE_T_INT     10
02357 #define CODE_CONSTRAINT_OP_NEWARRAY_TYPE_T_LONG    11
02358 
02359 /*@} */ /* End of grouped definitions */
02360 
02361 
02362 /*!
02363  * @brief Section 4.10.2:  Structural Constraints
02364  */
02365 
02366 
02367 /*!
02368  * @brief Section 4.11:  Verification of @b class Files
02369  */
02370 
02371 /*!
02372  * @brief Section 4.11.1:  Verification by Type Inference
02373  */
02374 
02375 
02376 /*!
02377  * @brief Section 4.11.1.1:  The Process of Verification by Type
02378  * Inference
02379  *
02380  */
02381 
02382 /*!
02383  * @brief Section 4.11.1.2:  The Bytecode Verifier
02384  *
02385  */
02386 
02387 /*!
02388  * @brief Section 4.11.1.3:  Values of Types @c @b long and @c @b double
02389  *
02390  */
02391 
02392 /*!
02393  * @brief Section 4.11.1.4:  Instance Initialization Methods and Newly
02394  *                           Created Objects
02395  *
02396  */
02397 
02398 /*!
02399  * @brief Section 4.11.1.5:  Exception Handlers
02400  *
02401  */
02402 
02403 /*!
02404  * @brief Section 4.9.6:  Exceptions and @c @b finally -- Removed from
02405  *                        this JVM 1.5 edition, possibly from 1.4.
02406  *
02407  */
02408 
02409 /*!
02410  * @brief Section 4.12:  Limitations of the Java Virtual Machine
02411  *
02412  */
02413  
02414 
02415 /****************************************************************/
02416 
02417 /*!
02418  * @brief Attribute enumeration
02419  *
02420  * Enumeration of all ClassFile attribute types.  Gather the
02421  * @link #LOCAL_CONSTANTVALUE_ATTRIBUTE_ENUM
02422    LOCAL_xxx_ATTRIBUTE_ENUM@endlink values from all over the
02423  * file into one place for use in compiling a single enumeration
02424  * type.  These @link #LOCAL_CONSTANTVALUE_ATTRIBUTE_ENUM
02425    LOCAL_xxx_ATTRIBUTE_ENUM@endlink values were defined in the
02426  * immediate proximity to the attribute they help describe, but
02427  * this is difficult for creating an enumeration type.  Here near
02428  * the end of the file, each one is defined, so the enumeration
02429  * type can be created.  Once created, the @b xxx_ENUM version is
02430  * undefined.  Thus the @b xxx_ENUM is known only locally in this
02431  * file, while the @b xxx version is known as part of the enumeration
02432  * type.
02433  *
02434  */
02435 typedef enum
02436 {
02437     LOCAL_UNKNOWN_ATTRIBUTE =
02438         LOCAL_UNKNOWN_ATTRIBUTE_ENUM,
02439 
02440     LOCAL_CONSTANTVALUE_ATTRIBUTE =
02441         LOCAL_CONSTANTVALUE_ATTRIBUTE_ENUM,
02442 
02443     LOCAL_CODE_ATTRIBUTE =
02444         LOCAL_CODE_ATTRIBUTE_ENUM,
02445 
02446     LOCAL_EXCEPTIONS_ATTRIBUTE =
02447         LOCAL_EXCEPTIONS_ATTRIBUTE_ENUM,
02448 
02449     LOCAL_INNERCLASSES_ATTRIBUTE =
02450         LOCAL_INNERCLASSES_ATTRIBUTE_ENUM,
02451 
02452     LOCAL_ENCLOSINGMETHOD_ATTRIBUTE =
02453         LOCAL_ENCLOSINGMETHOD_ATTRIBUTE_ENUM,
02454 
02455     LOCAL_SYNTHETIC_ATTRIBUTE =
02456         LOCAL_SYNTHETIC_ATTRIBUTE_ENUM,
02457 
02458     LOCAL_SIGNATURE_ATTRIBUTE =
02459         LOCAL_SIGNATURE_ATTRIBUTE_ENUM,
02460 
02461     LOCAL_SOURCEFILE_ATTRIBUTE =
02462         LOCAL_SOURCEFILE_ATTRIBUTE_ENUM,
02463 
02464     LOCAL_LINENUMBERTABLE_ATTRIBUTE =
02465         LOCAL_LINENUMBERTABLE_ATTRIBUTE_ENUM,
02466 
02467     LOCAL_LOCALVARIABLETABLE_ATTRIBUTE =
02468         LOCAL_LOCALVARIABLETABLE_ATTRIBUTE_ENUM,
02469 
02470     LOCAL_LOCALVARIABLETYPETABLE_ATTRIBUTE =
02471         LOCAL_LOCALVARIABLETYPETABLE_ATTRIBUTE_ENUM,
02472 
02473     LOCAL_DEPRECATED_ATTRIBUTE =
02474         LOCAL_DEPRECATED_ATTRIBUTE_ENUM,
02475 
02476     LOCAL_RUNTIMEVISIBLEANNOTATIONS_ATTRIBUTE =
02477         LOCAL_RUNTIMEVISIBLEANNOTATIONS_ATTRIBUTE_ENUM,
02478 
02479     LOCAL_RUNTIMEINVISIBLEANNOTATIONS_ATTRIBUTE =
02480         LOCAL_RUNTIMEINVISIBLEANNOTATIONS_ATTRIBUTE_ENUM,
02481 
02482     LOCAL_RUNTIMEVISIBLEPARAMETERANNOTATIONS_ATTRIBUTE =
02483         LOCAL_RUNTIMEVISIBLEPARAMETERANNOTATIONS_ATTRIBUTE_ENUM,
02484 
02485     LOCAL_RUNTIMEINVISIBLEPARAMETERANNOTATIONS_ATTRIBUTE =
02486         LOCAL_RUNTIMEINVISIBLEPARAMETERANNOTATIONS_ATTRIBUTE_ENUM,
02487 
02488     LOCAL_ANNOTATIONDEFAULT_ATTRIBUTE =
02489         LOCAL_ANNOTATIONDEFAULT_ATTRIBUTE_ENUM
02490 
02491 } classfile_attribute_enum;
02492 
02493 /* Finally remove temporary definitions */
02494 #undef LOCAL_UNKNOWN_ATTRIBUTE_ENUM
02495 #undef LOCAL_CONSTANTVALUE_ATTRIBUTE_ENUM
02496 #undef LOCAL_CODE_ATTRIBUTE_ENUM
02497 #undef LOCAL_EXCEPTIONS_ATTRIBUTE_ENUM
02498 #undef LOCAL_INNERCLASSES_ATTRIBUTE_ENUM
02499 #undef LOCAL_ENCLOSINGMETHOD_ATTRIBUTE_ENUM
02500 #undef LOCAL_SYNTHETIC_ATTRIBUTE_ENUM
02501 #undef LOCAL_SIGNATURE_ATTRIBUTE_ENUM
02502 #undef LOCAL_SOURCEFILE_ATTRIBUTE_ENUM
02503 #undef LOCAL_LINENUMBERTABLE_ATTRIBUTE_ENUM
02504 #undef LOCAL_LOCALVARIABLETABLE_ATTRIBUTE_ENUM
02505 #undef LOCAL_LOCALVARIABLETYPETABLE_ATTRIBUTE_ENUM
02506 #undef LOCAL_DEPRECATED_ATTRIBUTE_ENUM
02507 #undef LOCAL_RUNTIMEVISIBLEANNOTATIONS_ATTRIBUTE_ENUM
02508 #undef LOCAL_RUNTIMEINVISIBLEANNOTATIONS_ATTRIBUTE_ENUM
02509 #undef LOCAL_RUNTIMEVISIBLEPARAMETERANNOTATIONS_ATTRIBUTE_ENUM
02510 #undef LOCAL_RUNTIMEINVISIBLEPARAMETERANNOTATIONS_ATTRIBUTE_ENUM
02511 #undef LOCAL_ANNOTATIONDEFAULT_ATTRIBUTE_ENUM
02512 
02513  
02514 
02515 /* Prototypes for functions in 'classfile.c' */
02516 
02517 extern ClassFile *classfile_allocate_primative(jvm_basetype basetype);
02518 extern ClassFile *classfile_loadclassdata(u1     *classfile_image);
02519 extern rvoid classfile_unloadclassdata(ClassFile *pcfs);
02520 extern u1 *classfile_readclassfile(rchar *filename);
02521 extern u1 *classfile_readjarfile(rchar *filename);
02522 
02523 /* Prototypes for functions in 'cfattrib.c' */
02524 extern u1 *cfattrib_loadattribute(ClassFile           *pcfs,
02525                                   attribute_info_dup **dst,
02526                                   attribute_info      *src);
02527 extern rvoid cfattrib_unloadattribute(ClassFile          *pcfs,
02528                                       attribute_info_dup *dst);
02529 extern classfile_attribute_enum cfattrib_atr2enum(ClassFile *pcfs,
02530                               u2 attribute_attribute_name_index);
02531 extern rboolean cfattrib_iscodeattribute(ClassFile *pcfs,
02532                                      u2 attribute_attribute_name_index);
02533 
02534 /* Prototypes for functions in 'cfmsgs.c' */
02535 extern rvoid cfmsgs_typemsg(rchar *fn, ClassFile *pcfs, u2 idx);
02536 extern rvoid cfmsgs_show_constant_pool(ClassFile *pcfs);
02537 extern rvoid cfmsgs_atrmsg(rchar *fn,
02538                            ClassFile *pcfs,
02539                            attribute_info_dup *atr);
02540 
02541 #endif /* _classfile_h_included_ */
02542 
02543 /* EOF */
02544 

Generated on Fri Sep 30 18:49:00 2005 by  doxygen 1.4.4