diff options
author | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-09-15 22:02:13 +0000 |
---|---|---|
committer | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-09-15 22:02:13 +0000 |
commit | 9981c44b92386c6d642ef71245fab27974f08dbf (patch) | |
tree | 9f425c2996ae0b146771dcc668979c48675ee708 /libjava/defineclass.cc | |
parent | 966073719a045032562f6bbfd595456b85b28e24 (diff) | |
download | gcc-9981c44b92386c6d642ef71245fab27974f08dbf.tar.gz |
PR libgcj/16032:
* interpret.cc (AVAL1U): Resolve pool entry when not direct
threaded.
(AVAL2U): Likewise.
(compile): Handle 'ldc class' specially.
(_Jv_InterpMethod::run): Added special 'ldc class' instruction.
* verify.cc (check_constant): Handle 'ldc class' for 1.5 classes.
* defineclass.cc (handleCodeAttribute): Set new field.
(MAJOR_1_1, MINOR_1_1, MAJOR_1_2, MINOR_1_2, MAJOR_1_3, MINOR_1_3,
MAJOR_1_4, MINOR_1_4, MAJOR_1_5, MINOR_1_5): New defines.
(parse): Check version numbers.
(_Jv_ClassReader::is_15): New field.
(_Jv_ClassReader): Initialize it.
* include/java-interp.h (_Jv_InterpMethod::is_15): New field.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@104325 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/defineclass.cc')
-rw-r--r-- | libjava/defineclass.cc | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/libjava/defineclass.cc b/libjava/defineclass.cc index d12e3278481..89e0636f4aa 100644 --- a/libjava/defineclass.cc +++ b/libjava/defineclass.cc @@ -101,13 +101,17 @@ struct _Jv_ClassReader // the class to define (see java-interp.h) jclass def; - + // the classes associated interpreter data. _Jv_InterpClass *def_interp; // The name we found. _Jv_Utf8Const **found_name; + // True if this is a 1.5 class file. + bool is_15; + + /* check that the given number of input bytes are available */ inline void check (int num) { @@ -233,6 +237,8 @@ struct _Jv_ClassReader bytes = (unsigned char*) (elements (data)+offset); len = length; pos = 0; + is_15 = false; + def = klass; found_name = name_result; @@ -302,19 +308,32 @@ _Jv_DefineClass (jclass klass, jbyteArray data, jint offset, jint length, /** This section defines the parsing/scanning of the class data */ +// Major and minor version numbers for various releases. +#define MAJOR_1_1 45 +#define MINOR_1_1 3 +#define MAJOR_1_2 46 +#define MINOR_1_2 0 +#define MAJOR_1_3 47 +#define MINOR_1_3 0 +#define MAJOR_1_4 48 +#define MINOR_1_4 0 +#define MAJOR_1_5 49 +#define MINOR_1_5 0 + void _Jv_ClassReader::parse () { int magic = read4 (); - - /* FIXME: Decide which range of version numbers to allow */ - - /* int minor_version = */ read2u (); - /* int major_verson = */ read2u (); - if (magic != (int) 0xCAFEBABE) throw_class_format_error ("bad magic number"); + int minor_version = read2u (); + int major_version = read2u (); + if (major_version < MAJOR_1_1 || major_version > MAJOR_1_5 + || (major_version == MAJOR_1_5 && minor_version > MINOR_1_5)) + throw_class_format_error ("unrecognized class file version"); + is_15 = (major_version == MAJOR_1_5); + pool_count = read2u (); read_constpool (); @@ -1318,6 +1337,7 @@ void _Jv_ClassReader::handleCodeAttribute method->max_locals = max_locals; method->code_length = code_length; method->exc_count = exc_table_length; + method->is_15 = is_15; method->defining_class = def; method->self = &def->methods[method_index]; method->prepared = NULL; |