1 // defineclass.cc - defining a class from .class format.
3 /* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation
5 This file is part of libgcj.
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
12 Author: Kresten Krab Thorup <krab@gnu.org>
14 Written using the online versions of Java Language Specification (1st
15 ed.) and The Java Virtual Machine Specification (2nd ed.).
17 Future work may include reading (and handling) attributes which are
18 currently being ignored ("InnerClasses", "LineNumber", etc...).
23 #include <java-interp.h>
27 #include <java-cpool.h>
29 #include <execution.h>
31 #include <java/lang/Class.h>
32 #include <java/lang/Float.h>
33 #include <java/lang/Double.h>
34 #include <java/lang/Character.h>
35 #include <java/lang/LinkageError.h>
36 #include <java/lang/InternalError.h>
37 #include <java/lang/ClassFormatError.h>
38 #include <java/lang/NoClassDefFoundError.h>
39 #include <java/lang/ClassCircularityError.h>
40 #include <java/lang/IncompatibleClassChangeError.h>
41 #include <java/lang/reflect/Modifier.h>
42 #include <java/security/ProtectionDomain.h>
48 // these go in some separate functions, to avoid having _Jv_InitClass
49 // inserted all over the place.
50 static void throw_internal_error (const char *msg
)
51 __attribute__ ((__noreturn__
));
52 static void throw_no_class_def_found_error (jstring msg
)
53 __attribute__ ((__noreturn__
));
54 static void throw_no_class_def_found_error (const char *msg
)
55 __attribute__ ((__noreturn__
));
56 static void throw_class_format_error (jstring msg
)
57 __attribute__ ((__noreturn__
));
58 static void throw_incompatible_class_change_error (jstring msg
)
59 __attribute__ ((__noreturn__
));
60 static void throw_class_circularity_error (jstring msg
)
61 __attribute__ ((__noreturn__
));
64 * We define class reading using a class. It is practical, since then
65 * the entire class-reader can be a friend of class Class (it needs to
66 * write all it's different structures); but also because this makes it
67 * easy to make class definition reentrant, and thus two threads can be
68 * defining classes at the same time. This class (_Jv_ClassReader) is
69 * never exposed outside this file, so we don't have to worry about
70 * public or private members here.
73 struct _Jv_ClassReader
76 // do verification? Currently, there is no option to disable this.
77 // This flag just controls the verificaiton done by the class loader;
78 // i.e., checking the integrity of the constant pool; and it is
79 // allways on. You always want this as far as I can see, but it also
80 // controls weither identifiers and type descriptors/signatures are
81 // verified as legal. This could be somewhat more expensive since it
82 // will call Character.isJavaIdentifier{Start,Part} for each character
83 // in any identifier (field name or method name) it comes by. Thus,
84 // it might be useful to turn off this verification for classes that
85 // come from a trusted source. However, for GCJ, trusted classes are
86 // most likely to be linked in.
94 // current input position
97 // the constant pool data
100 unsigned int *offsets
;
102 // the class to define (see java-interp.h)
105 // the classes associated interpreter data.
106 _Jv_InterpClass
*def_interp
;
108 // The name we found.
109 _Jv_Utf8Const
**found_name
;
111 // True if this is a 1.5 class file.
115 /* check that the given number of input bytes are available */
116 inline void check (int num
)
119 throw_class_format_error ("Premature end of data");
122 /* skip a given number of bytes in input */
123 inline void skip (int num
)
129 /* read an unsignend 1-byte unit */
130 inline static jint
get1u (unsigned char* bytes
)
135 /* read an unsigned 1-byte unit */
136 inline jint
read1u ()
139 return get1u (bytes
+pos
-1);
142 /* read an unsigned 2-byte unit */
143 inline static jint
get2u (unsigned char *bytes
)
145 return (((jint
)bytes
[0]) << 8) | ((jint
)bytes
[1]);
148 /* read an unsigned 2-byte unit */
149 inline jint
read2u ()
152 return get2u (bytes
+pos
-2);
155 /* read a 4-byte unit */
156 static jint
get4 (unsigned char *bytes
)
158 return (((jint
)bytes
[0]) << 24)
159 | (((jint
)bytes
[1]) << 16)
160 | (((jint
)bytes
[2]) << 8)
161 | (((jint
)bytes
[3]) << 0);
164 /* read a 4-byte unit, (we don't do that quite so often) */
168 return get4 (bytes
+pos
-4);
171 /* read a 8-byte unit */
172 static jlong
get8 (unsigned char* bytes
)
174 return (((jlong
)bytes
[0]) << 56)
175 | (((jlong
)bytes
[1]) << 48)
176 | (((jlong
)bytes
[2]) << 40)
177 | (((jlong
)bytes
[3]) << 32)
178 | (((jlong
)bytes
[4]) << 24)
179 | (((jlong
)bytes
[5]) << 16)
180 | (((jlong
)bytes
[6]) << 8)
181 | (((jlong
)bytes
[7]) << 0);
184 /* read a 8-byte unit */
185 inline jlong
read8 ()
188 return get8 (bytes
+pos
-8);
191 inline void check_tag (int index
, char expected_tag
)
194 || index
> pool_count
195 || tags
[index
] != expected_tag
)
196 throw_class_format_error ("erroneous constant pool tag");
199 inline void verify_identifier (_Jv_Utf8Const
* name
)
201 if (! _Jv_VerifyIdentifier (name
))
202 throw_class_format_error ("erroneous identifier");
205 inline void verify_classname (unsigned char* ptr
, _Jv_ushort length
)
207 if (! _Jv_VerifyClassName (ptr
, length
))
208 throw_class_format_error ("erroneous class name");
211 inline void verify_classname (_Jv_Utf8Const
*name
)
213 if (! _Jv_VerifyClassName (name
))
214 throw_class_format_error ("erroneous class name");
217 inline void verify_field_signature (_Jv_Utf8Const
*sig
)
219 if (! _Jv_VerifyFieldSignature (sig
))
220 throw_class_format_error ("erroneous type descriptor");
223 inline void verify_method_signature (_Jv_Utf8Const
*sig
)
225 if (! _Jv_VerifyMethodSignature (sig
))
226 throw_class_format_error ("erroneous type descriptor");
229 _Jv_ClassReader (jclass klass
, jbyteArray data
, jint offset
, jint length
,
230 java::security::ProtectionDomain
*pd
,
231 _Jv_Utf8Const
**name_result
)
233 if (klass
== 0 || length
< 0 || offset
+length
> data
->length
)
234 throw_internal_error ("arguments to _Jv_DefineClass");
237 bytes
= (unsigned char*) (elements (data
)+offset
);
243 found_name
= name_result
;
245 def
->size_in_bytes
= -1;
246 def
->vtable_method_count
= -1;
247 def
->engine
= &_Jv_soleInterpreterEngine
;
248 def
->protectionDomain
= pd
;
251 /** and here goes the parser members defined out-of-line */
253 void read_constpool ();
254 void prepare_pool_entry (int index
, unsigned char tag
);
256 void read_methods ();
257 void read_one_class_attribute ();
258 void read_one_method_attribute (int method
);
259 void read_one_code_attribute (int method
);
260 void read_one_field_attribute (int field
);
261 void throw_class_format_error (const char *msg
);
263 /** check an utf8 entry, without creating a Utf8Const object */
264 bool is_attribute_name (int index
, const char *name
);
266 /** here goes the class-loader members defined out-of-line */
267 void handleConstantPool ();
268 void handleClassBegin (int, int, int);
269 void handleInterfacesBegin (int);
270 void handleInterface (int, int);
271 void handleFieldsBegin (int);
272 void handleField (int, int, int, int);
273 void handleFieldsEnd ();
274 void handleConstantValueAttribute (int,int);
275 void handleMethodsBegin (int);
276 void handleMethod (int, int, int, int);
277 void handleMethodsEnd ();
278 void handleCodeAttribute (int, int, int, int, int, int);
279 void handleExceptionTableEntry (int, int, int, int, int, int);
281 void checkExtends (jclass sub
, jclass super
);
282 void checkImplements (jclass sub
, jclass super
);
285 * FIXME: we should keep a hash table of utf8-strings, since many will
286 * be the same. It's a little tricky, however, because the hash table
287 * needs to interact gracefully with the garbage collector. Much
288 * memory is to be saved by this, however! perhaps the improvement
289 * could be implemented in prims.cc (_Jv_makeUtf8Const), since it
290 * computes the hash value anyway.
294 // Note that *NAME_RESULT will only be set if the class is registered
295 // with the class loader. This is how the caller can know whether
296 // unregistration is require.
298 _Jv_DefineClass (jclass klass
, jbyteArray data
, jint offset
, jint length
,
299 java::security::ProtectionDomain
*pd
,
300 _Jv_Utf8Const
**name_result
)
302 _Jv_ClassReader
reader (klass
, data
, offset
, length
, pd
, name_result
);
309 /** This section defines the parsing/scanning of the class data */
311 // Major and minor version numbers for various releases.
324 _Jv_ClassReader::parse ()
326 int magic
= read4 ();
327 if (magic
!= (int) 0xCAFEBABE)
328 throw_class_format_error ("bad magic number");
330 int minor_version
= read2u ();
331 int major_version
= read2u ();
332 if (major_version
< MAJOR_1_1
|| major_version
> MAJOR_1_5
333 || (major_version
== MAJOR_1_5
&& minor_version
> MINOR_1_5
))
334 throw_class_format_error ("unrecognized class file version");
335 is_15
= (major_version
== MAJOR_1_5
);
337 pool_count
= read2u ();
341 int access_flags
= read2u ();
342 int this_class
= read2u ();
343 int super_class
= read2u ();
345 check_tag (this_class
, JV_CONSTANT_Class
);
346 if (super_class
!= 0)
347 check_tag (super_class
, JV_CONSTANT_Class
);
349 handleClassBegin (access_flags
, this_class
, super_class
);
351 // Allocate our aux_info here, after the name is set, to fulfill our
352 // contract with the collector interface.
353 def
->aux_info
= (void *) _Jv_AllocRawObj (sizeof (_Jv_InterpClass
));
354 def_interp
= (_Jv_InterpClass
*) def
->aux_info
;
356 int interfaces_count
= read2u ();
358 handleInterfacesBegin (interfaces_count
);
360 for (int i
= 0; i
< interfaces_count
; i
++)
362 int iface
= read2u ();
363 check_tag (iface
, JV_CONSTANT_Class
);
364 handleInterface (i
, iface
);
370 int attributes_count
= read2u ();
372 for (int i
= 0; i
< attributes_count
; i
++)
374 read_one_class_attribute ();
378 throw_class_format_error ("unused data before end of file");
380 // Tell everyone we're done.
381 def
->state
= JV_STATE_READ
;
382 if (gcj::verbose_class_flag
)
383 _Jv_Linker::print_class_loaded (def
);
387 void _Jv_ClassReader::read_constpool ()
389 tags
= (unsigned char*) _Jv_AllocBytes (pool_count
);
390 offsets
= (unsigned int *) _Jv_AllocBytes (sizeof (int) * pool_count
) ;
392 /** first, we scan the constant pool, collecting tags and offsets */
393 tags
[0] = JV_CONSTANT_Undefined
;
395 for (int c
= 1; c
< pool_count
; c
++)
402 case JV_CONSTANT_String
:
403 case JV_CONSTANT_Class
:
407 case JV_CONSTANT_Fieldref
:
408 case JV_CONSTANT_Methodref
:
409 case JV_CONSTANT_InterfaceMethodref
:
410 case JV_CONSTANT_NameAndType
:
411 case JV_CONSTANT_Integer
:
412 case JV_CONSTANT_Float
:
416 case JV_CONSTANT_Double
:
417 case JV_CONSTANT_Long
:
419 tags
[++c
] = JV_CONSTANT_Undefined
;
422 case JV_CONSTANT_Utf8
:
429 case JV_CONSTANT_Unicode
:
430 throw_class_format_error ("unicode not supported");
434 throw_class_format_error ("erroneous constant pool tag");
438 handleConstantPool ();
442 void _Jv_ClassReader::read_fields ()
444 int fields_count
= read2u ();
445 handleFieldsBegin (fields_count
);
447 for (int i
= 0; i
< fields_count
; i
++)
449 int access_flags
= read2u ();
450 int name_index
= read2u ();
451 int descriptor_index
= read2u ();
452 int attributes_count
= read2u ();
454 check_tag (name_index
, JV_CONSTANT_Utf8
);
455 prepare_pool_entry (name_index
, JV_CONSTANT_Utf8
);
457 check_tag (descriptor_index
, JV_CONSTANT_Utf8
);
458 prepare_pool_entry (descriptor_index
, JV_CONSTANT_Utf8
);
460 handleField (i
, access_flags
, name_index
, descriptor_index
);
462 for (int j
= 0; j
< attributes_count
; j
++)
464 read_one_field_attribute (i
);
472 _Jv_ClassReader::is_attribute_name (int index
, const char *name
)
474 check_tag (index
, JV_CONSTANT_Utf8
);
475 int len
= get2u (bytes
+offsets
[index
]);
476 if (len
!= (int) strlen (name
))
479 return !memcmp (bytes
+offsets
[index
]+2, name
, len
);
482 void _Jv_ClassReader::read_one_field_attribute (int field_index
)
484 int name
= read2u ();
485 int length
= read4 ();
487 if (is_attribute_name (name
, "ConstantValue"))
493 && (tags
[cv
] == JV_CONSTANT_Integer
494 || tags
[cv
] == JV_CONSTANT_Float
495 || tags
[cv
] == JV_CONSTANT_Long
496 || tags
[cv
] == JV_CONSTANT_Double
497 || tags
[cv
] == JV_CONSTANT_String
))
499 handleConstantValueAttribute (field_index
, cv
);
503 throw_class_format_error ("erroneous ConstantValue attribute");
507 throw_class_format_error ("erroneous ConstantValue attribute");
516 void _Jv_ClassReader::read_methods ()
518 int methods_count
= read2u ();
520 handleMethodsBegin (methods_count
);
522 for (int i
= 0; i
< methods_count
; i
++)
524 int access_flags
= read2u ();
525 int name_index
= read2u ();
526 int descriptor_index
= read2u ();
527 int attributes_count
= read2u ();
529 check_tag (name_index
, JV_CONSTANT_Utf8
);
530 prepare_pool_entry (name_index
, JV_CONSTANT_Utf8
);
532 check_tag (descriptor_index
, JV_CONSTANT_Utf8
);
533 prepare_pool_entry (descriptor_index
, JV_CONSTANT_Utf8
);
535 handleMethod (i
, access_flags
, name_index
,
538 for (int j
= 0; j
< attributes_count
; j
++)
540 read_one_method_attribute (i
);
547 void _Jv_ClassReader::read_one_method_attribute (int method_index
)
549 int name
= read2u ();
550 int length
= read4 ();
552 if (is_attribute_name (name
, "Exceptions"))
554 _Jv_Method
*method
= reinterpret_cast<_Jv_Method
*>
555 (&def
->methods
[method_index
]);
556 if (method
->throws
!= NULL
)
557 throw_class_format_error ("only one Exceptions attribute allowed per method");
559 int num_exceptions
= read2u ();
560 _Jv_Utf8Const
**exceptions
=
561 (_Jv_Utf8Const
**) _Jv_AllocBytes ((num_exceptions
+ 1)
562 * sizeof (_Jv_Utf8Const
*));
565 _Jv_word
*pool_data
= def
->constants
.data
;
566 for (int i
= 0; i
< num_exceptions
; ++i
)
569 // JLS 2nd Ed. 4.7.5 requires that the tag not be 0.
572 check_tag (ndx
, JV_CONSTANT_Class
);
573 exceptions
[out
++] = pool_data
[ndx
].utf8
;
576 exceptions
[out
] = NULL
;
577 method
->throws
= exceptions
;
580 else if (is_attribute_name (name
, "Code"))
583 int max_stack
= read2u ();
584 int max_locals
= read2u ();
585 int code_length
= read4 ();
587 int code_start
= pos
;
589 int exception_table_length
= read2u ();
591 handleCodeAttribute (method_index
,
592 max_stack
, max_locals
,
593 code_start
, code_length
,
594 exception_table_length
);
597 for (int i
= 0; i
< exception_table_length
; i
++)
599 int start_pc
= read2u ();
600 int end_pc
= read2u ();
601 int handler_pc
= read2u ();
602 int catch_type
= read2u ();
604 if (start_pc
> end_pc
606 // END_PC can be equal to CODE_LENGTH.
607 // See JVM Spec 4.7.4.
608 || end_pc
> code_length
609 || handler_pc
>= code_length
)
610 throw_class_format_error ("erroneous exception handler info");
612 if (! (tags
[catch_type
] == JV_CONSTANT_Class
613 || tags
[catch_type
] == 0))
615 throw_class_format_error ("erroneous exception handler info");
618 handleExceptionTableEntry (method_index
,
627 int attributes_count
= read2u ();
629 for (int i
= 0; i
< attributes_count
; i
++)
631 read_one_code_attribute (method_index
);
634 if ((pos
- start_off
) != length
)
635 throw_class_format_error ("code attribute too short");
640 /* ignore unknown attributes */
645 void _Jv_ClassReader::read_one_code_attribute (int method_index
)
647 int name
= read2u ();
648 int length
= read4 ();
649 if (is_attribute_name (name
, "LineNumberTable"))
651 _Jv_InterpMethod
*method
= reinterpret_cast<_Jv_InterpMethod
*>
652 (def_interp
->interpreted_methods
[method_index
]);
653 if (method
->line_table
!= NULL
)
654 throw_class_format_error ("Method already has LineNumberTable");
656 int table_len
= read2u ();
657 _Jv_LineTableEntry
* table
658 = (_Jv_LineTableEntry
*) _Jv_AllocBytes (table_len
659 * sizeof (_Jv_LineTableEntry
));
660 for (int i
= 0; i
< table_len
; i
++)
662 table
[i
].bytecode_pc
= read2u ();
663 table
[i
].line
= read2u ();
665 method
->line_table_len
= table_len
;
666 method
->line_table
= table
;
670 /* ignore unknown code attributes */
675 void _Jv_ClassReader::read_one_class_attribute ()
677 int name
= read2u ();
678 int length
= read4 ();
679 if (is_attribute_name (name
, "SourceFile"))
681 int source_index
= read2u ();
682 check_tag (source_index
, JV_CONSTANT_Utf8
);
683 prepare_pool_entry (source_index
, JV_CONSTANT_Utf8
);
684 def_interp
->source_file_name
= _Jv_NewStringUtf8Const
685 (def
->constants
.data
[source_index
].utf8
);
689 /* Currently, we ignore most class attributes.
690 FIXME: Add inner-classes attributes support. */
698 /* this section defines the semantic actions of the parser */
700 void _Jv_ClassReader::handleConstantPool ()
702 /** now, we actually define the class' constant pool */
704 jbyte
*pool_tags
= (jbyte
*) _Jv_AllocBytes (pool_count
);
706 = (_Jv_word
*) _Jv_AllocRawObj (pool_count
* sizeof (_Jv_word
));
708 def
->constants
.tags
= pool_tags
;
709 def
->constants
.data
= pool_data
;
710 def
->constants
.size
= pool_count
;
712 // Here we make a pass to collect the strings! We do this, because
713 // internally in the GCJ runtime, classes are encoded with .'s not /'s.
714 // Therefore, we first collect the strings, and then translate the rest
715 // of the utf8-entries (thus not representing strings) from /-notation
717 for (int i
= 1; i
< pool_count
; i
++)
719 if (tags
[i
] == JV_CONSTANT_String
)
721 unsigned char* str_data
= bytes
+ offsets
[i
];
722 int utf_index
= get2u (str_data
);
723 check_tag (utf_index
, JV_CONSTANT_Utf8
);
724 unsigned char *utf_data
= bytes
+ offsets
[utf_index
];
725 int len
= get2u (utf_data
);
726 pool_data
[i
].utf8
= _Jv_makeUtf8Const ((char*)(utf_data
+2), len
);
727 pool_tags
[i
] = JV_CONSTANT_String
;
731 pool_tags
[i
] = JV_CONSTANT_Undefined
;
735 // and now, we scan everything else but strings & utf8-entries. This
736 // leaves out those utf8-entries which are not used; which will be left
737 // with a tag of JV_CONSTANT_Undefined in the class definition.
738 for (int index
= 1; index
< pool_count
; index
++)
742 case JV_CONSTANT_Undefined
:
743 case JV_CONSTANT_String
:
744 case JV_CONSTANT_Utf8
:
748 prepare_pool_entry (index
, tags
[index
]);
754 /* this is a recursive procedure, which will prepare pool entries as needed.
755 Which is how we avoid initializing those entries which go unused. */
757 _Jv_ClassReader::prepare_pool_entry (int index
, unsigned char this_tag
)
759 /* these two, pool_data and pool_tags, point into the class
760 structure we are currently defining */
762 unsigned char *pool_tags
= (unsigned char*) def
->constants
.tags
;
763 _Jv_word
*pool_data
= def
->constants
.data
;
765 /* this entry was already prepared */
766 if (pool_tags
[index
] == this_tag
)
769 /* this_data points to the constant-pool information for the current
770 constant-pool entry */
772 unsigned char *this_data
= bytes
+ offsets
[index
];
776 case JV_CONSTANT_Utf8
:
778 // If we came here, it is because some other tag needs this
779 // utf8-entry for type information! Thus, we translate /'s to .'s in
780 // order to accomondate gcj's internal representation.
782 int len
= get2u (this_data
);
783 char *buffer
= (char*) __builtin_alloca (len
);
784 char *s
= ((char*) this_data
)+2;
786 /* FIXME: avoid using a buffer here */
787 for (int i
= 0; i
< len
; i
++)
792 buffer
[i
] = (char) s
[i
];
795 pool_data
[index
].utf8
= _Jv_makeUtf8Const (buffer
, len
);
796 pool_tags
[index
] = JV_CONSTANT_Utf8
;
800 case JV_CONSTANT_Class
:
802 int utf_index
= get2u (this_data
);
803 check_tag (utf_index
, JV_CONSTANT_Utf8
);
804 prepare_pool_entry (utf_index
, JV_CONSTANT_Utf8
);
807 verify_classname (pool_data
[utf_index
].utf8
);
809 pool_data
[index
].utf8
= pool_data
[utf_index
].utf8
;
810 pool_tags
[index
] = JV_CONSTANT_Class
;
814 case JV_CONSTANT_String
:
815 // already handled before...
818 case JV_CONSTANT_Fieldref
:
819 case JV_CONSTANT_Methodref
:
820 case JV_CONSTANT_InterfaceMethodref
:
822 int class_index
= get2u (this_data
);
823 int nat_index
= get2u (this_data
+2);
825 check_tag (class_index
, JV_CONSTANT_Class
);
826 prepare_pool_entry (class_index
, JV_CONSTANT_Class
);
828 check_tag (nat_index
, JV_CONSTANT_NameAndType
);
829 prepare_pool_entry (nat_index
, JV_CONSTANT_NameAndType
);
831 // here, verify the signature and identifier name
834 _Jv_ushort name_index
, type_index
;
835 _Jv_loadIndexes (&pool_data
[nat_index
],
836 name_index
, type_index
);
838 if (this_tag
== JV_CONSTANT_Fieldref
)
839 verify_field_signature (pool_data
[type_index
].utf8
);
841 verify_method_signature (pool_data
[type_index
].utf8
);
843 _Jv_Utf8Const
* name
= pool_data
[name_index
].utf8
;
845 if (this_tag
!= JV_CONSTANT_Fieldref
846 && ( _Jv_equalUtf8Consts (name
, clinit_name
)
847 || _Jv_equalUtf8Consts (name
, init_name
)))
850 verify_identifier (pool_data
[name_index
].utf8
);
853 _Jv_storeIndexes (&pool_data
[index
], class_index
, nat_index
);
854 pool_tags
[index
] = this_tag
;
858 case JV_CONSTANT_NameAndType
:
860 _Jv_ushort name_index
= get2u (this_data
);
861 _Jv_ushort type_index
= get2u (this_data
+2);
863 check_tag (name_index
, JV_CONSTANT_Utf8
);
864 prepare_pool_entry (name_index
, JV_CONSTANT_Utf8
);
866 check_tag (type_index
, JV_CONSTANT_Utf8
);
867 prepare_pool_entry (type_index
, JV_CONSTANT_Utf8
);
869 _Jv_storeIndexes (&pool_data
[index
], name_index
, type_index
);
870 pool_tags
[index
] = JV_CONSTANT_NameAndType
;
874 case JV_CONSTANT_Float
:
876 jfloat f
= java::lang::Float::intBitsToFloat ((jint
) get4 (this_data
));
877 _Jv_storeFloat (&pool_data
[index
], f
);
878 pool_tags
[index
] = JV_CONSTANT_Float
;
882 case JV_CONSTANT_Integer
:
884 int i
= get4 (this_data
);
885 _Jv_storeInt (&pool_data
[index
], i
);
886 pool_tags
[index
] = JV_CONSTANT_Integer
;
890 case JV_CONSTANT_Double
:
893 = java::lang::Double::longBitsToDouble ((jlong
) get8 (this_data
));
894 _Jv_storeDouble (&pool_data
[index
], d
);
895 pool_tags
[index
] = JV_CONSTANT_Double
;
899 case JV_CONSTANT_Long
:
901 jlong i
= get8 (this_data
);
902 _Jv_storeLong (&pool_data
[index
], i
);
903 pool_tags
[index
] = JV_CONSTANT_Long
;
908 throw_class_format_error ("erroneous constant pool tag");
914 _Jv_ClassReader::handleClassBegin (int access_flags
, int this_class
, int super_class
)
916 using namespace java::lang::reflect
;
918 unsigned char *pool_tags
= (unsigned char*) def
->constants
.tags
;
919 _Jv_word
*pool_data
= def
->constants
.data
;
921 check_tag (this_class
, JV_CONSTANT_Class
);
922 _Jv_Utf8Const
*loadedName
= pool_data
[this_class
].utf8
;
924 // was ClassLoader.defineClass called with an expected class name?
927 jclass orig
= def
->loader
->findLoadedClass(loadedName
->toString());
931 def
->name
= loadedName
;
935 jstring msg
= JvNewStringUTF ("anonymous "
936 "class data denotes "
938 msg
= msg
->concat (orig
->getName ());
940 throw_no_class_def_found_error (msg
);
944 // assert that the loaded class has the expected name, 5.3.5
945 else if (! _Jv_equalUtf8Consts (loadedName
, def
->name
))
947 jstring msg
= JvNewStringUTF ("loaded class ");
948 msg
= msg
->concat (def
->getName ());
949 msg
= msg
->concat (_Jv_NewStringUTF (" was in fact named "));
950 jstring klass_name
= loadedName
->toString();
951 msg
= msg
->concat (klass_name
);
953 throw_no_class_def_found_error (msg
);
956 def
->accflags
= access_flags
| java::lang::reflect::Modifier::INTERPRETED
;
957 pool_data
[this_class
].clazz
= def
;
958 pool_tags
[this_class
] = JV_CONSTANT_ResolvedClass
;
960 if (super_class
== 0)
962 // Note that this is ok if we are defining java.lang.Object.
963 // But there is no way to have this class be interpreted.
964 throw_class_format_error ("no superclass reference");
967 def
->state
= JV_STATE_PRELOADING
;
969 // Register this class with its defining loader as well (despite the
970 // name of the function we're calling), so that super class lookups
971 // work properly. If there is an error, our caller will unregister
972 // this class from the class loader. Also, we don't need to hold a
973 // lock here, as our caller has acquired it.
974 _Jv_RegisterInitiatingLoader (def
, def
->loader
);
976 // Note that we found a name so that unregistration can happen if
978 *found_name
= def
->name
;
980 if (super_class
!= 0)
982 // Load the superclass.
983 check_tag (super_class
, JV_CONSTANT_Class
);
984 _Jv_Utf8Const
* super_name
= pool_data
[super_class
].utf8
;
986 // Load the superclass using our defining loader.
987 jclass the_super
= _Jv_FindClass (super_name
, def
->loader
);
989 // This will establish that we are allowed to be a subclass,
990 // and check for class circularity error.
991 checkExtends (def
, the_super
);
993 // Note: for an interface we will find Object as the
994 // superclass. We still check it above to ensure class file
995 // validity, but we simply assign `null' to the actual field in
997 def
->superclass
= (((access_flags
& Modifier::INTERFACE
))
999 pool_data
[super_class
].clazz
= the_super
;
1000 pool_tags
[super_class
] = JV_CONSTANT_ResolvedClass
;
1003 // Now we've come past the circularity problem, we can
1004 // now say that we're loading.
1006 def
->state
= JV_STATE_LOADING
;
1010 ///// Implements the checks described in sect. 5.3.5.3
1012 _Jv_ClassReader::checkExtends (jclass sub
, jclass super
)
1014 using namespace java::lang::reflect
;
1016 _Jv_Linker::wait_for_state (super
, JV_STATE_LOADING
);
1018 // Having an interface or a final class as a superclass is no good.
1019 if ((super
->accflags
& (Modifier::INTERFACE
| Modifier::FINAL
)) != 0)
1021 throw_incompatible_class_change_error (sub
->getName ());
1024 // If the super class is not public, we need to check some more.
1025 if ((super
->accflags
& Modifier::PUBLIC
) == 0)
1027 // With package scope, the classes must have the same class
1029 if ( sub
->loader
!= super
->loader
1030 || !_Jv_ClassNameSamePackage (sub
->name
, super
->name
))
1032 throw_incompatible_class_change_error (sub
->getName ());
1036 for (; super
!= 0; super
= super
->getSuperclass ())
1039 throw_class_circularity_error (sub
->getName ());
1045 void _Jv_ClassReader::handleInterfacesBegin (int count
)
1047 def
->interfaces
= (jclass
*) _Jv_AllocRawObj (count
*sizeof (jclass
));
1048 def
->interface_count
= count
;
1051 void _Jv_ClassReader::handleInterface (int if_number
, int offset
)
1053 _Jv_word
* pool_data
= def
->constants
.data
;
1054 unsigned char * pool_tags
= (unsigned char*) def
->constants
.tags
;
1056 jclass the_interface
;
1058 if (pool_tags
[offset
] == JV_CONSTANT_Class
)
1060 _Jv_Utf8Const
* name
= pool_data
[offset
].utf8
;
1061 the_interface
= _Jv_FindClass (name
, def
->loader
);
1063 else if (pool_tags
[offset
] == JV_CONSTANT_ResolvedClass
)
1065 the_interface
= pool_data
[offset
].clazz
;
1069 throw_no_class_def_found_error ("erroneous constant pool tag");
1072 // checks the validity of the_interface, and that we are in fact
1073 // allowed to implement that interface.
1074 checkImplements (def
, the_interface
);
1076 pool_data
[offset
].clazz
= the_interface
;
1077 pool_tags
[offset
] = JV_CONSTANT_ResolvedClass
;
1079 def
->interfaces
[if_number
] = the_interface
;
1083 _Jv_ClassReader::checkImplements (jclass sub
, jclass super
)
1085 using namespace java::lang::reflect
;
1087 // well, it *must* be an interface
1088 if ((super
->accflags
& Modifier::INTERFACE
) == 0)
1090 throw_incompatible_class_change_error (sub
->getName ());
1093 // if it has package scope, it must also be defined by the
1095 if ((super
->accflags
& Modifier::PUBLIC
) == 0)
1097 if ( sub
->loader
!= super
->loader
1098 || !_Jv_ClassNameSamePackage (sub
->name
, super
->name
))
1100 throw_incompatible_class_change_error (sub
->getName ());
1104 // FIXME: add interface circularity check here
1107 throw_class_circularity_error (sub
->getName ());
1111 void _Jv_ClassReader::handleFieldsBegin (int count
)
1113 def
->fields
= (_Jv_Field
*) _Jv_AllocRawObj (count
* sizeof (_Jv_Field
));
1114 def
->field_count
= count
;
1115 def_interp
->field_initializers
1116 = (_Jv_ushort
*) _Jv_AllocRawObj (count
* sizeof (_Jv_ushort
));
1117 for (int i
= 0; i
< count
; i
++)
1118 def_interp
->field_initializers
[i
] = (_Jv_ushort
) 0;
1121 void _Jv_ClassReader::handleField (int field_no
,
1126 using namespace java::lang::reflect
;
1128 _Jv_word
*pool_data
= def
->constants
.data
;
1130 _Jv_Field
*field
= &def
->fields
[field_no
];
1131 _Jv_Utf8Const
*field_name
= pool_data
[name
].utf8
;
1133 field
->name
= field_name
;
1135 // Ignore flags we don't know about.
1136 field
->flags
= flags
& Modifier::ALL_FLAGS
;
1138 _Jv_Utf8Const
* sig
= pool_data
[desc
].utf8
;
1142 verify_identifier (field_name
);
1144 for (int i
= 0; i
< field_no
; ++i
)
1146 if (_Jv_equalUtf8Consts (field_name
, def
->fields
[i
].name
)
1147 && _Jv_equalUtf8Consts (sig
,
1148 // We know the other fields are
1150 (_Jv_Utf8Const
*) def
->fields
[i
].type
))
1151 throw_class_format_error ("duplicate field name");
1154 // At most one of PUBLIC, PRIVATE, or PROTECTED is allowed.
1155 if (1 < ( ((field
->flags
& Modifier::PUBLIC
) ? 1 : 0)
1156 +((field
->flags
& Modifier::PRIVATE
) ? 1 : 0)
1157 +((field
->flags
& Modifier::PROTECTED
) ? 1 : 0)))
1158 throw_class_format_error ("erroneous field access flags");
1160 // FIXME: JVM spec S4.5: Verify ACC_FINAL and ACC_VOLATILE are not
1161 // both set. Verify modifiers for interface fields.
1166 verify_field_signature (sig
);
1168 // field->type is really a jclass, but while it is still
1169 // unresolved we keep an _Jv_Utf8Const* instead.
1170 field
->type
= (jclass
) sig
;
1171 field
->flags
|= _Jv_FIELD_UNRESOLVED_FLAG
;
1172 field
->u
.boffset
= 0;
1176 void _Jv_ClassReader::handleConstantValueAttribute (int field_index
,
1179 using namespace java::lang::reflect
;
1181 _Jv_Field
*field
= &def
->fields
[field_index
];
1183 if ((field
->flags
& (Modifier::STATIC
1185 | Modifier::PRIVATE
)) == 0)
1187 // Ignore, as per vmspec #4.7.2
1191 // do not allow multiple constant fields!
1192 if (field
->flags
& _Jv_FIELD_CONSTANT_VALUE
)
1193 throw_class_format_error ("field has multiple ConstantValue attributes");
1195 field
->flags
|= _Jv_FIELD_CONSTANT_VALUE
;
1196 def_interp
->field_initializers
[field_index
] = value
;
1198 /* type check the initializer */
1200 if (value
<= 0 || value
>= pool_count
)
1201 throw_class_format_error ("erroneous ConstantValue attribute");
1203 /* FIXME: do the rest */
1206 void _Jv_ClassReader::handleFieldsEnd ()
1208 using namespace java::lang::reflect
;
1210 // We need to reorganize the fields so that the static ones are first,
1211 // to conform to GCJ class layout.
1214 int high
= def
->field_count
-1;
1215 _Jv_Field
*fields
= def
->fields
;
1216 _Jv_ushort
*inits
= def_interp
->field_initializers
;
1218 // this is kind of a raw version of quicksort.
1221 // go forward on low, while it's a static
1222 while (low
< high
&& (fields
[low
].flags
& Modifier::STATIC
) != 0)
1225 // go backwards on high, while it's a non-static
1226 while (low
< high
&& (fields
[high
].flags
& Modifier::STATIC
) == 0)
1232 _Jv_Field tmp
= fields
[low
];
1233 _Jv_ushort itmp
= inits
[low
];
1235 fields
[low
] = fields
[high
];
1236 inits
[low
] = inits
[high
];
1245 if ((fields
[low
].flags
& Modifier::STATIC
) != 0)
1248 def
->static_field_count
= low
;
1254 _Jv_ClassReader::handleMethodsBegin (int count
)
1256 def
->methods
= (_Jv_Method
*) _Jv_AllocRawObj (sizeof (_Jv_Method
) * count
);
1258 def_interp
->interpreted_methods
1259 = (_Jv_MethodBase
**) _Jv_AllocRawObj (sizeof (_Jv_MethodBase
*)
1262 for (int i
= 0; i
< count
; i
++)
1264 def_interp
->interpreted_methods
[i
] = 0;
1265 def
->methods
[i
].index
= (_Jv_ushort
) -1;
1268 def
->method_count
= count
;
1272 void _Jv_ClassReader::handleMethod
1273 (int mth_index
, int accflags
, int name
, int desc
)
1275 using namespace java::lang::reflect
;
1277 _Jv_word
*pool_data
= def
->constants
.data
;
1278 _Jv_Method
*method
= &def
->methods
[mth_index
];
1280 check_tag (name
, JV_CONSTANT_Utf8
);
1281 prepare_pool_entry (name
, JV_CONSTANT_Utf8
);
1282 method
->name
= pool_data
[name
].utf8
;
1284 check_tag (desc
, JV_CONSTANT_Utf8
);
1285 prepare_pool_entry (desc
, JV_CONSTANT_Utf8
);
1286 method
->signature
= pool_data
[desc
].utf8
;
1288 // ignore unknown flags
1289 method
->accflags
= accflags
& Modifier::ALL_FLAGS
;
1293 method
->throws
= NULL
;
1297 if (_Jv_equalUtf8Consts (method
->name
, clinit_name
)
1298 || _Jv_equalUtf8Consts (method
->name
, init_name
))
1301 verify_identifier (method
->name
);
1303 verify_method_signature (method
->signature
);
1305 for (int i
= 0; i
< mth_index
; ++i
)
1307 if (_Jv_equalUtf8Consts (method
->name
, def
->methods
[i
].name
)
1308 && _Jv_equalUtf8Consts (method
->signature
,
1309 def
->methods
[i
].signature
))
1310 throw_class_format_error ("duplicate method");
1313 // At most one of PUBLIC, PRIVATE, or PROTECTED is allowed.
1314 if (1 < ( ((method
->accflags
& Modifier::PUBLIC
) ? 1 : 0)
1315 +((method
->accflags
& Modifier::PRIVATE
) ? 1 : 0)
1316 +((method
->accflags
& Modifier::PROTECTED
) ? 1 : 0)))
1317 throw_class_format_error ("erroneous method access flags");
1319 // FIXME: JVM spec S4.6: if ABSTRACT modifier is set, verify other
1320 // flags are not set. Verify flags for interface methods. Verify
1321 // modifiers for initializers.
1325 void _Jv_ClassReader::handleCodeAttribute
1326 (int method_index
, int max_stack
, int max_locals
,
1327 int code_start
, int code_length
, int exc_table_length
)
1329 int size
= _Jv_InterpMethod::size (exc_table_length
, code_length
);
1330 _Jv_InterpMethod
*method
=
1331 (_Jv_InterpMethod
*) (_Jv_AllocRawObj (size
));
1333 method
->max_stack
= max_stack
;
1334 method
->max_locals
= max_locals
;
1335 method
->code_length
= code_length
;
1336 method
->exc_count
= exc_table_length
;
1337 method
->is_15
= is_15
;
1338 method
->defining_class
= def
;
1339 method
->self
= &def
->methods
[method_index
];
1340 method
->prepared
= NULL
;
1341 method
->line_table_len
= 0;
1342 method
->line_table
= NULL
;
1345 // grab the byte code!
1346 memcpy ((void*) method
->bytecode (),
1347 (void*) (bytes
+code_start
),
1350 def_interp
->interpreted_methods
[method_index
] = method
;
1352 if ((method
->self
->accflags
& java::lang::reflect::Modifier::STATIC
))
1354 // Precompute the ncode field for a static method. This lets us
1355 // call a static method of an interpreted class from precompiled
1356 // code without first resolving the class (that will happen
1357 // during class initialization instead).
1358 method
->self
->ncode
= method
->ncode ();
1362 void _Jv_ClassReader::handleExceptionTableEntry
1363 (int method_index
, int exc_index
,
1364 int start_pc
, int end_pc
, int handler_pc
, int catch_type
)
1366 _Jv_InterpMethod
*method
= reinterpret_cast<_Jv_InterpMethod
*>
1367 (def_interp
->interpreted_methods
[method_index
]);
1368 _Jv_InterpException
*exc
= method
->exceptions ();
1370 exc
[exc_index
].start_pc
.i
= start_pc
;
1371 exc
[exc_index
].end_pc
.i
= end_pc
;
1372 exc
[exc_index
].handler_pc
.i
= handler_pc
;
1373 exc
[exc_index
].handler_type
.i
= catch_type
;
1376 void _Jv_ClassReader::handleMethodsEnd ()
1378 using namespace java::lang::reflect
;
1380 for (int i
= 0; i
< def
->method_count
; i
++)
1382 _Jv_Method
*method
= &def
->methods
[i
];
1383 if ((method
->accflags
& Modifier::NATIVE
) != 0)
1385 if (def_interp
->interpreted_methods
[i
] != 0)
1386 throw_class_format_error ("code provided for native method");
1389 _Jv_JNIMethod
*m
= (_Jv_JNIMethod
*)
1390 _Jv_AllocRawObj (sizeof (_Jv_JNIMethod
));
1391 m
->defining_class
= def
;
1394 def_interp
->interpreted_methods
[i
] = m
;
1396 if ((method
->accflags
& Modifier::STATIC
))
1398 // Precompute the ncode field for a static method.
1399 // This lets us call a static method of an
1400 // interpreted class from precompiled code without
1401 // first resolving the class (that will happen
1402 // during class initialization instead).
1403 method
->ncode
= m
->ncode ();
1407 else if ((method
->accflags
& Modifier::ABSTRACT
) != 0)
1409 if (def_interp
->interpreted_methods
[i
] != 0)
1410 throw_class_format_error ("code provided for abstract method");
1411 method
->ncode
= (void *) &_Jv_ThrowAbstractMethodError
;
1415 if (def_interp
->interpreted_methods
[i
] == 0)
1416 throw_class_format_error ("method with no code");
1421 void _Jv_ClassReader::throw_class_format_error (const char *msg
)
1424 if (def
->name
!= NULL
)
1426 jsize mlen
= strlen (msg
);
1427 unsigned char* data
= (unsigned char*) def
->name
->chars();
1428 int ulen
= def
->name
->len();
1429 unsigned char* limit
= data
+ ulen
;
1430 jsize nlen
= _Jv_strLengthUtf8 ((char *) data
, ulen
);
1431 jsize len
= nlen
+ mlen
+ 3;
1432 str
= JvAllocString(len
);
1433 jchar
*chrs
= JvGetStringChars(str
);
1434 while (data
< limit
)
1435 *chrs
++ = UTF8_GET(data
, limit
);
1443 *chrs
++ = c
& 0xFFFF;
1448 str
= JvNewStringLatin1 (msg
);
1449 ::throw_class_format_error (str
);
1452 /** Here we define the exceptions that can be thrown */
1455 throw_no_class_def_found_error (jstring msg
)
1458 ? new java::lang::NoClassDefFoundError (msg
)
1459 : new java::lang::NoClassDefFoundError
);
1463 throw_no_class_def_found_error (const char *msg
)
1465 throw_no_class_def_found_error (JvNewStringLatin1 (msg
));
1469 throw_class_format_error (jstring msg
)
1472 ? new java::lang::ClassFormatError (msg
)
1473 : new java::lang::ClassFormatError
);
1477 throw_internal_error (const char *msg
)
1479 throw new java::lang::InternalError (JvNewStringLatin1 (msg
));
1483 throw_incompatible_class_change_error (jstring msg
)
1485 throw new java::lang::IncompatibleClassChangeError (msg
);
1489 throw_class_circularity_error (jstring msg
)
1491 throw new java::lang::ClassCircularityError (msg
);
1494 #endif /* INTERPRETER */
1498 /** This section takes care of verifying integrity of identifiers,
1499 signatures, field ddescriptors, and class names */
1501 #define UTF8_PEEK(PTR, LIMIT) \
1502 ({ unsigned char* xxkeep = (PTR); \
1503 int xxch = UTF8_GET(PTR,LIMIT); \
1504 PTR = xxkeep; xxch; })
1506 /* Verify one element of a type descriptor or signature. */
1507 static unsigned char*
1508 _Jv_VerifyOne (unsigned char* ptr
, unsigned char* limit
, bool void_ok
)
1513 int ch
= UTF8_GET (ptr
, limit
);
1521 case 'S': case 'B': case 'I': case 'J':
1522 case 'Z': case 'C': case 'F': case 'D':
1527 unsigned char *start
= ptr
, *end
;
1535 if ((ch
= UTF8_GET (ptr
, limit
)) == -1)
1540 if (! _Jv_VerifyClassName (start
, (unsigned short) (end
-start
)))
1546 return _Jv_VerifyOne (ptr
, limit
, false);
1556 /* Verification and loading procedures. */
1558 _Jv_VerifyFieldSignature (_Jv_Utf8Const
*sig
)
1560 unsigned char* ptr
= (unsigned char*) sig
->chars();
1561 unsigned char* limit
= ptr
+ sig
->len();
1563 ptr
= _Jv_VerifyOne (ptr
, limit
, false);
1565 return ptr
== limit
;
1569 _Jv_VerifyMethodSignature (_Jv_Utf8Const
*sig
)
1571 unsigned char* ptr
= (unsigned char*) sig
->chars();
1572 unsigned char* limit
= ptr
+ sig
->len();
1574 if (ptr
== limit
|| UTF8_GET(ptr
,limit
) != '(')
1577 while (ptr
&& UTF8_PEEK (ptr
, limit
) != ')')
1578 ptr
= _Jv_VerifyOne (ptr
, limit
, false);
1580 if (! ptr
|| UTF8_GET (ptr
, limit
) != ')')
1583 // get the return type
1584 ptr
= _Jv_VerifyOne (ptr
, limit
, true);
1586 return ptr
== limit
;
1589 /* We try to avoid calling the Character methods all the time, in
1590 fact, they will only be called for non-standard things. */
1591 static __inline__
int
1592 is_identifier_start (int c
)
1594 unsigned int ch
= (unsigned)c
;
1596 if ((ch
- 0x41U
) < 29U) /* A ... Z */
1598 if ((ch
- 0x61U
) < 29U) /* a ... z */
1600 if (ch
== 0x5FU
) /* _ */
1603 return java::lang::Character::isJavaIdentifierStart ((jchar
) ch
);
1606 static __inline__
int
1607 is_identifier_part (int c
)
1609 unsigned int ch
= (unsigned)c
;
1611 if ((ch
- 0x41U
) < 29U) /* A ... Z */
1613 if ((ch
- 0x61U
) < 29U) /* a ... z */
1615 if ((ch
- 0x30) < 10U) /* 0 .. 9 */
1617 if (ch
== 0x5FU
|| ch
== 0x24U
) /* _ $ */
1620 return java::lang::Character::isJavaIdentifierStart ((jchar
) ch
);
1624 _Jv_VerifyIdentifier (_Jv_Utf8Const
* name
)
1626 unsigned char *ptr
= (unsigned char*) name
->chars();
1627 unsigned char *limit
= (unsigned char*) name
->limit();
1630 if ((ch
= UTF8_GET (ptr
, limit
))==-1
1631 || ! is_identifier_start (ch
))
1634 while (ptr
!= limit
)
1636 if ((ch
= UTF8_GET (ptr
, limit
))==-1
1637 || ! is_identifier_part (ch
))
1644 _Jv_VerifyClassName (unsigned char* ptr
, _Jv_ushort length
)
1646 unsigned char *limit
= ptr
+length
;
1649 if ('[' == UTF8_PEEK (ptr
, limit
))
1651 unsigned char *end
= _Jv_VerifyOne (++ptr
, limit
, false);
1652 // _Jv_VerifyOne must leave us looking at the terminating nul
1662 if ((ch
= UTF8_GET (ptr
, limit
))==-1)
1664 if (! is_identifier_start (ch
))
1669 else if ((ch
= UTF8_GET (ptr
, limit
))==-1)
1673 else if (! is_identifier_part (ch
))
1680 _Jv_VerifyClassName (_Jv_Utf8Const
*name
)
1682 return _Jv_VerifyClassName ((unsigned char*)name
->chars(), name
->len());
1685 /* Returns true, if NAME1 and NAME2 represent classes in the same
1686 package. Neither NAME2 nor NAME2 may name an array type. */
1688 _Jv_ClassNameSamePackage (_Jv_Utf8Const
*name1
, _Jv_Utf8Const
*name2
)
1690 unsigned char* ptr1
= (unsigned char*) name1
->chars();
1691 unsigned char* limit1
= (unsigned char*) name1
->limit();
1693 unsigned char* last1
= ptr1
;
1695 // scan name1, and find the last occurrence of '.'
1696 while (ptr1
< limit1
) {
1697 int ch1
= UTF8_GET (ptr1
, limit1
);
1706 // Now the length of NAME1's package name is LEN.
1707 int len
= last1
- (unsigned char*) name1
->chars();
1709 // If this is longer than NAME2, then we're off.
1710 if (len
> name2
->len())
1713 // Then compare the first len bytes for equality.
1714 if (memcmp ((void*) name1
->chars(), (void*) name2
->chars(), len
) == 0)
1716 // Check that there are no .'s after position LEN in NAME2.
1718 unsigned char* ptr2
= (unsigned char*) name2
->chars() + len
;
1719 unsigned char* limit2
= (unsigned char*) name2
->limit();
1721 while (ptr2
< limit2
)
1723 int ch2
= UTF8_GET (ptr2
, limit2
);
1724 if (ch2
== -1 || ch2
== '.')