Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
Licensed under the Apache License, Version 2.0 ("the License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
Definition in file class.c.
#include "arch.h"
#include <string.h>
#include "jvmcfg.h"
#include "cfmacros.h"
#include "classfile.h"
#include "classpath.h"
#include "exit.h"
#include "field.h"
#include "gc.h"
#include "jvm.h"
#include "jvmclass.h"
#include "linkage.h"
#include "method.h"
#include "nts.h"
#include "utf.h"
#include "util.h"
Go to the source code of this file.
DEFAULT SYSTEM CLASS LOADER: | ||||||||||||||||
perform the duties of java.lang.ClassLoader Using either null-terminated strings or UTF strings from CONSTANT_Utf8_info or CONSTANT_Class_info constant_pool entries, the following three functions function as the system default class loader that can be invoked three different ways. It searches CLASSPATH, reads in a class file, parses its contents, and loads it into the class table and object table, and performs static initialization.Notice that the array formatting must already be included in clsname (if this is an array class), and that the arraylength array must contain the same number of integers as described in clsname. No checking is done for this in this function.
ClassLoader.defineClass(String name, byte[] b, int off, int len) but combines the operands effectively into,
ClassLoader.defineClass(String name) where name is a null-terminated string passed as the only parm, and b is the byte array read in by classfile_readclassfile() or classfile_readjarfile(), and off is zero, and len being discovered by classfile_read_XXXfile().
| ||||||||||||||||
jvm_class_index | class_load_from_cp_entry_utf (cp_info_dup *clsname, rboolean find_registerNatives, jint *arraylength) | |||||||||||||||
jvm_class_index | class_load_from_prchar (rchar *clsname, rboolean find_registerNatives, jint *arraylength) | |||||||||||||||
Functions | ||||||||||||||||
static jvm_class_index | class_allocate_slot (rboolean tryagain) | |||||||||||||||
Locate and reserve an unused class table slot for a new class. | ||||||||||||||||
static void | class_c_dummy (void) | |||||||||||||||
jvm_class_index | class_find_by_cp_entry (cp_info_dup *clsname) | |||||||||||||||
Scan class table using CP table entry for presence of a class of specific name and number of dimensions. | ||||||||||||||||
jvm_class_index | class_find_by_prchar (rchar *clsname) | |||||||||||||||
Retrieve by (rchar *) name a class index to a class. | ||||||||||||||||
static rvoid | class_get_constant_field_attribute (jvm_class_index clsidx, ClassFile *pcfs, jvm_field_index fldidx, jvalue *field_data, jvm_field_lookup_index fluidx, rboolean staticmark, jvm_object_hash objhash) | |||||||||||||||
Retrieve data from a CONSTANT_xxx_info structure and insert it into a slot in the field data table. Also implements table 4.6. | ||||||||||||||||
u2 | class_get_num_object_instance_fields (ClassFile *pcfs) | |||||||||||||||
Report number of object instance fields are in a class file. | ||||||||||||||||
u2 | class_get_num_static_fields (ClassFile *pcfs) | |||||||||||||||
Report number of class static fields are in a class file. | ||||||||||||||||
jvalue * | class_get_object_instance_field_data (jvm_class_index clsidx, jvm_object_hash objhash, ClassFile *pcfs) | |||||||||||||||
Load the field data table for object instance fields in this class. | ||||||||||||||||
jvm_field_index * | class_get_object_instance_field_lookups (ClassFile *pcfs) | |||||||||||||||
Load the field lookup table for object instance fields in this class. | ||||||||||||||||
jvalue * | class_get_static_field_data (jvm_class_index clsidx, ClassFile *pcfs) | |||||||||||||||
Load the field data table for class static fields in this class. | ||||||||||||||||
jvm_field_index * | class_get_static_field_lookups (ClassFile *pcfs) | |||||||||||||||
Load the field lookup table for class static fields in this class. | ||||||||||||||||
rvoid | class_init () | |||||||||||||||
Initialize the class area of the JVM model. | ||||||||||||||||
jvm_class_index | class_load_primative (u1 basetype) | |||||||||||||||
Load primative classes for java.lang.Class. | ||||||||||||||||
jvm_class_index | class_load_resolve_clinit (rchar *clsname, jvm_thread_index thridx, rboolean usesystemthread, rboolean find_registerNatives) | |||||||||||||||
All-purpose class loading, load, resolve, <clinit> , each step only run if needed. | ||||||||||||||||
jvm_class_index | class_reload (jvm_class_index clsidxOLD) | |||||||||||||||
Reload a class in the class table after java.lang.String has become available. | ||||||||||||||||
rvoid | class_shutdown_1 () | |||||||||||||||
Shut down the class area of the JVM model after JVM execution in two stages. | ||||||||||||||||
rvoid | class_shutdown_2 () | |||||||||||||||
jvm_class_index | class_static_delete (jvm_class_index clsidx, rboolean rmref) | |||||||||||||||
Un-reserve a slot from the class table. | ||||||||||||||||
jvm_class_index | class_static_new (rushort special_cls, ClassFile *pcfs, jvm_array_dim arraydims, jint *arraylength, jvm_class_index lower_dim_array) | |||||||||||||||
Load a class into ad class table slot and load up its associated class definition object. | ||||||||||||||||
rvoid | class_static_setup (jvm_class_index clsidx) | |||||||||||||||
Set up an empty class in a given class table slot. | ||||||||||||||||
Variables | ||||||||||||||||
static char * | class_c_copyright = "\0" "$URL: https://svn.apache.org/path/name/class.c $ $Id: class.c 0 09/28/2005 dlydick $" " " "Copyright 2005 The Apache Software Foundation or its licensors, as applicable." |
|
|
|
Set up an empty class in a given class table slot. The clsidx of JVMCFG_NULL_CLASS has special properties in that it can ALWAYS be allocated and is NEVER garbage collected! Part of the purpose for this is the JVMCFG_NULL_CLASS is of value zero, which is widely used throughout the code as a special value. This this slot is not available for anything else.
< NULL class slot. Exactly on exists in normal use, any else besides the JVMCFG_NULL_CLASS is a class slot now being initialized. < Not stated in spec, but implied Definition at line 80 of file class.c. References CLASS, CLASS_STATUS_INUSE, CLASS_STATUS_NULL, jvm_class_index_null, jvm_object_hash_null, LOCAL_CONSTANT_NO_ARRAY_DIMS, and rnull. |
|
Initialize the class area of the JVM model. Parameters: rvoid
|
|
Locate and reserve an unused class table slot for a new class.
< This slot contains a class < NULL class slot. Exactly on exists in normal use, any else besides the JVMCFG_NULL_CLASS is a class slot now being initialized. Definition at line 192 of file class.c. References CLASS, rjvm::class_allocate_last, CLASS_STATUS_INUSE, CLASS_STATUS_NULL, EXIT_JVM_CLASS, exit_throw_exception(), GC_RUN, JVMCFG_FIRST_CLASS, JVMCFG_MAX_CLASSES, JVMCLASS_JAVA_LANG_OUTOFMEMORYERROR, pjvm, rfalse, and rtrue. |
|
Load a class into ad class table slot and load up its associated class definition object.
Create a Java class itself (and NOT a
No verification of special_cls is performed, only these values are assumed. Use a simple circular slot allocation mechanism to report where most recent class was allocated. The search for the next slot will begin from here and go all the way around the array to this same slot. If not successful, throw error, but do not return.
java.lang.Class < This slot is available for use
< Primative for
< Class is an array type where < This object is a class definition instead of an object instance
< Class is an array type where
< NULL class slot. Exactly on exists in normal use, any else besides the JVMCFG_NULL_CLASS is a class slot now being initialized. Definition at line 353 of file class.c. References jvm_class_index_null. |
|
Reload a class in the class table after This process does not re-read the class file, only redoes class initialization. The class_objhash does not get deleted.
< NULL class slot. Exactly on exists in normal use, any else besides the JVMCFG_NULL_CLASS is a class slot now being initialized. < This slot is available for use < NULL class slot. Exactly on exists in normal use, any else besides the JVMCFG_NULL_CLASS is a class slot now being initialized. |
|
Un-reserve a slot from the class table. This is the reverse of the process of class_static_new() above. Only tear down the heap allocations and mark the slot as empty. Leave the rest of the data in place for post-mortem. When the slot gets allocated again, any zeroing out of values will just get overwritten again, so don't bother.
Definition at line 732 of file class.c. References CLASS, GC_CLASS_FIELD_RMREF, and HEAP_FREE_DATA. |
|
Scan class table using CP table entry for presence of a class of specific name and number of dimensions.
< NULL class slot. Exactly on exists in normal use, any else besides the JVMCFG_NULL_CLASS is a class slot now being initialized. Definition at line 839 of file class.c. References class_find_by_cp_entry(), HEAP_FREE_DATA, and nts_prchar2utf(). Referenced by class_find_by_cp_entry(), class_load_primative(), and linkage_resolve_class(). |
|
Retrieve by (rchar *) name a class index to a class.
Definition at line 898 of file class.c. Referenced by opcode_run(), and thread_new(). |
|
Load primative classes for
Load primative classes as opposed to a real class Classes loaded with this method will typically never have any references to them except from their class object created within class_static_new(), yet are completely valid and are used intensively by class type processing. Because they never have references removed, they will never be marked for garbage collection, either. In this way, they are permanently available to the JVM for class type processing.
java.lang.Class < Not stated in spec, but implied
Definition at line 940 of file class.c. References class_find_by_cp_entry(), class_load_from_prchar(), CONSTANT_Utf8, EXIT_JVM_INTERNAL, exit_throw_exception(), jvm_class_index_null, JVMCLASS_JAVA_LANG_INTERNALERROR, LOCAL_CONSTANT_NO_ARRAY_DIMS, PTR_THIS_CP_Utf8, rnull, utf_get_utf_arraydims(), and utf_utf2prchar(). |
|
< Not stated in spec, but implied < Not stated in spec, but implied < Not stated in spec, but implied < This slot is available for use
< Class is an array type where < Convenient alias for DML5 < Convenient alias for DML5
< Not stated in spec, but implied < Convenient alias for DML5 For internal use only. Load superclass
WATCH OUT! RECURSIVE CALL! This will recurse until super_class is a
<clinit>
|
|
|
All-purpose class loading, load, resolve,
Load a class into the JVM, resolve its linkages, and run its
For internal use only. see similar logic for loading a new stack frame and PC in thread_new_common()
< Start PC location
< Class loaded, needs Definition at line 1445 of file class.c. Referenced by opcode_load_run_throwable(), and opcode_run(). |
|
Retrieve data from a CONSTANT_xxx_info structure and insert it into a slot in the field data table. Also implements table 4.6.
pcfs->constant_pool [PTR_CP_ENTRY_TYPE( CONSTANT_String_info, pcfs, constantvalue_index) ->string_index] But do not store directly into,
Instead, store the resulting object hash from the algorithm shown in jvm_init() where the main() parameter
DO NOT do this until the class initialization is complete for Definition at line 1641 of file class.c. Referenced by class_get_static_field_lookups(). |
|
Report number of class static fields are in a class file.
static .
Definition at line 1887 of file class.c. References class_get_num_static_fields(), HEAP_GET_DATA, and rtrue. Referenced by class_get_num_static_fields(). |
|
Load the field lookup table for class static fields in this class.
static .
Definition at line 1921 of file class.c. References ACC_STATIC, field_info::access_flags, class_get_constant_field_attribute(), ClassFile::fields, jvm_object_hash_null, and rtrue. |
|
Load the field data table for class static fields in this class.
static .
Definition at line 1968 of file class.c. References ACC_STATIC, field_info::access_flags, class_get_num_object_instance_fields(), ClassFile::fields, HEAP_GET_DATA, and rfalse. |
|
Report number of object instance fields are in a class file.
static .
Definition at line 2020 of file class.c. References class_get_num_object_instance_fields(). Referenced by class_get_num_object_instance_fields(), and class_get_static_field_data(). |
|
Load the field lookup table for object instance fields in this class.
static .
|
|
Load the field data table for object instance fields in this class. This initialization is the same for all objects of this class, so this function is still naturally a part of class processing instead of object processing.
static .
Definition at line 2111 of file class.c. References CLASS, CLASS_STATUS_NULL, GC_CLASS_RMREF_FROM_CLASS, GC_OBJECT_RMREF_FROM_CLASS, and jvm_class_index_null. |
|
Shut down the class area of the JVM model after JVM execution in two stages. In between these two stages will be object_shutdown() which performs related reference cleanup from the object side: Stage 1-- remove class object references and class array references. object_shutdown()-- remove class references from objects here. Stage 2-- all remaining cleanup. Notice that references are removed here also except during this shutdown process. Parameters: rvoid
< NULL class slot. Exactly on exists in normal use, any else besides the JVMCFG_NULL_CLASS is a class slot now being initialized. |
|
< This slot contains a class |
|
|