1 /*
2 * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 // SignatureIterators iterate over a Java signature (or parts of it).
26 // (Syntax according to: "The Java Virtual Machine Specification" by
27 // Tim Lindholm & Frank Yellin; section 4.3 Descriptors; p. 89ff.)
28 //
29 // Example: Iterating over ([Lfoo;D)I using
30 // 0123456789
31 //
32 // iterate_parameters() calls: do_array(2, 7); do_double();
33 // iterate_returntype() calls: do_int();
34 // iterate() calls: do_array(2, 7); do_double(); do_int();
35 //
36 // is_return_type() is: false ; false ; true
37 //
38 // NOTE: The new optimizer has an alternate, for-loop based signature
39 // iterator implemented in opto/type.cpp, TypeTuple::make().
40
41 class SignatureIterator: public ResourceObj {
42 protected:
43 symbolHandle _signature; // the signature to iterate over
44 int _index; // the current character index (only valid during iteration)
399 enum FailureMode { ReturnNull, CNFException, NCDFError };
400 klassOop as_klass(Handle class_loader, Handle protection_domain, FailureMode failure_mode, TRAPS);
401 oop as_java_mirror(Handle class_loader, Handle protection_domain, FailureMode failure_mode, TRAPS);
402
403 // return same as_symbol except allocation of new symbols is avoided.
404 symbolOop as_symbol_or_null();
405 };
406
407 class SignatureVerifier : public StackObj {
408 public:
409 // Returns true if the symbol is valid method or type signature
410 static bool is_valid_signature(symbolHandle sig);
411
412 static bool is_valid_method_signature(symbolHandle sig);
413 static bool is_valid_type_signature(symbolHandle sig);
414 private:
415
416 static ssize_t is_valid_type(const char*, ssize_t);
417 static bool invalid_name_char(char);
418 };
|
1 /*
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_RUNTIME_SIGNATURE_HPP
26 #define SHARE_VM_RUNTIME_SIGNATURE_HPP
27
28 #include "memory/allocation.hpp"
29 #include "oops/methodOop.hpp"
30 #include "utilities/top.hpp"
31
32 // SignatureIterators iterate over a Java signature (or parts of it).
33 // (Syntax according to: "The Java Virtual Machine Specification" by
34 // Tim Lindholm & Frank Yellin; section 4.3 Descriptors; p. 89ff.)
35 //
36 // Example: Iterating over ([Lfoo;D)I using
37 // 0123456789
38 //
39 // iterate_parameters() calls: do_array(2, 7); do_double();
40 // iterate_returntype() calls: do_int();
41 // iterate() calls: do_array(2, 7); do_double(); do_int();
42 //
43 // is_return_type() is: false ; false ; true
44 //
45 // NOTE: The new optimizer has an alternate, for-loop based signature
46 // iterator implemented in opto/type.cpp, TypeTuple::make().
47
48 class SignatureIterator: public ResourceObj {
49 protected:
50 symbolHandle _signature; // the signature to iterate over
51 int _index; // the current character index (only valid during iteration)
406 enum FailureMode { ReturnNull, CNFException, NCDFError };
407 klassOop as_klass(Handle class_loader, Handle protection_domain, FailureMode failure_mode, TRAPS);
408 oop as_java_mirror(Handle class_loader, Handle protection_domain, FailureMode failure_mode, TRAPS);
409
410 // return same as_symbol except allocation of new symbols is avoided.
411 symbolOop as_symbol_or_null();
412 };
413
414 class SignatureVerifier : public StackObj {
415 public:
416 // Returns true if the symbol is valid method or type signature
417 static bool is_valid_signature(symbolHandle sig);
418
419 static bool is_valid_method_signature(symbolHandle sig);
420 static bool is_valid_type_signature(symbolHandle sig);
421 private:
422
423 static ssize_t is_valid_type(const char*, ssize_t);
424 static bool invalid_name_char(char);
425 };
426
427 #endif // SHARE_VM_RUNTIME_SIGNATURE_HPP
|