2007-12-01 00:00:00 +00:00
|
|
|
/*
|
2012-03-23 11:16:05 -04:00
|
|
|
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
|
2007-12-01 00:00:00 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
2010-05-27 19:08:38 -07:00
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
2007-12-01 00:00:00 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-11-23 13:22:55 -08:00
|
|
|
#ifndef SHARE_VM_CLASSFILE_CLASSFILEPARSER_HPP
|
|
|
|
#define SHARE_VM_CLASSFILE_CLASSFILEPARSER_HPP
|
|
|
|
|
|
|
|
#include "classfile/classFileStream.hpp"
|
|
|
|
#include "memory/resourceArea.hpp"
|
|
|
|
#include "oops/oop.inline.hpp"
|
|
|
|
#include "oops/typeArrayOop.hpp"
|
|
|
|
#include "runtime/handles.inline.hpp"
|
|
|
|
#include "utilities/accessFlags.hpp"
|
2012-07-12 00:39:53 -07:00
|
|
|
#include "classfile/symbolTable.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
|
2011-09-10 17:29:02 -07:00
|
|
|
class FieldAllocationCount;
|
|
|
|
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Parser for for .class files
|
|
|
|
//
|
|
|
|
// The bytes describing the class file structure is read from a Stream object
|
|
|
|
|
|
|
|
class ClassFileParser VALUE_OBJ_CLASS_SPEC {
|
|
|
|
private:
|
|
|
|
bool _need_verify;
|
|
|
|
bool _relax_verify;
|
|
|
|
u2 _major_version;
|
|
|
|
u2 _minor_version;
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol* _class_name;
|
2009-04-08 10:56:49 -07:00
|
|
|
KlassHandle _host_klass;
|
2008-11-12 22:33:26 -08:00
|
|
|
GrowableArray<Handle>* _cp_patches; // overrides for CP entries
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2012-07-12 00:39:53 -07:00
|
|
|
// precomputed flags
|
2007-12-01 00:00:00 +00:00
|
|
|
bool _has_finalizer;
|
|
|
|
bool _has_empty_finalizer;
|
|
|
|
bool _has_vanilla_constructor;
|
2012-07-12 00:39:53 -07:00
|
|
|
int _max_bootstrap_specifier_index; // detects BSS values
|
|
|
|
|
|
|
|
// class attributes parsed before the instance klass is created:
|
|
|
|
bool _synthetic_flag;
|
|
|
|
Symbol* _sourcefile;
|
|
|
|
Symbol* _generic_signature;
|
2012-07-16 19:50:52 -07:00
|
|
|
char* _sde_buffer;
|
|
|
|
int _sde_length;
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Array<u2>* _inner_classes;
|
|
|
|
AnnotationArray* _annotations;
|
2012-12-20 10:22:19 +01:00
|
|
|
AnnotationArray* _type_annotations;
|
2012-07-12 00:39:53 -07:00
|
|
|
|
|
|
|
void set_class_synthetic_flag(bool x) { _synthetic_flag = x; }
|
|
|
|
void set_class_sourcefile(Symbol* x) { _sourcefile = x; }
|
|
|
|
void set_class_generic_signature(Symbol* x) { _generic_signature = x; }
|
2012-07-16 19:50:52 -07:00
|
|
|
void set_class_sde_buffer(char* x, int len) { _sde_buffer = x; _sde_length = len; }
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void set_class_inner_classes(Array<u2>* x) { _inner_classes = x; }
|
|
|
|
void set_class_annotations(AnnotationArray* x) { _annotations = x; }
|
2012-12-20 10:22:19 +01:00
|
|
|
void set_class_type_annotations(AnnotationArray* x) { _type_annotations = x; }
|
2012-07-12 00:39:53 -07:00
|
|
|
void init_parsed_class_attributes() {
|
|
|
|
_synthetic_flag = false;
|
|
|
|
_sourcefile = NULL;
|
|
|
|
_generic_signature = NULL;
|
2012-07-16 19:50:52 -07:00
|
|
|
_sde_buffer = NULL;
|
|
|
|
_sde_length = 0;
|
2012-12-20 10:22:19 +01:00
|
|
|
_annotations = _type_annotations = NULL;
|
2012-07-12 00:39:53 -07:00
|
|
|
// initialize the other flags too:
|
|
|
|
_has_finalizer = _has_empty_finalizer = _has_vanilla_constructor = false;
|
|
|
|
_max_bootstrap_specifier_index = -1;
|
|
|
|
}
|
|
|
|
void apply_parsed_class_attributes(instanceKlassHandle k); // update k
|
|
|
|
|
|
|
|
class AnnotationCollector {
|
|
|
|
public:
|
|
|
|
enum Location { _in_field, _in_method, _in_class };
|
|
|
|
enum ID {
|
|
|
|
_unknown = 0,
|
|
|
|
_method_ForceInline,
|
2012-07-24 10:51:00 -07:00
|
|
|
_method_DontInline,
|
|
|
|
_method_LambdaForm_Compiled,
|
|
|
|
_method_LambdaForm_Hidden,
|
2012-07-12 00:39:53 -07:00
|
|
|
_annotation_LIMIT
|
|
|
|
};
|
|
|
|
const Location _location;
|
|
|
|
int _annotations_present;
|
|
|
|
AnnotationCollector(Location location)
|
|
|
|
: _location(location), _annotations_present(0)
|
|
|
|
{
|
|
|
|
assert((int)_annotation_LIMIT <= (int)sizeof(_annotations_present) * BitsPerByte, "");
|
|
|
|
}
|
|
|
|
// If this annotation name has an ID, report it (or _none).
|
|
|
|
ID annotation_index(Symbol* name);
|
|
|
|
// Set the annotation name:
|
|
|
|
void set_annotation(ID id) {
|
|
|
|
assert((int)id >= 0 && (int)id < (int)_annotation_LIMIT, "oob");
|
|
|
|
_annotations_present |= nth_bit((int)id);
|
|
|
|
}
|
|
|
|
// Report if the annotation is present.
|
|
|
|
bool has_any_annotations() { return _annotations_present != 0; }
|
|
|
|
bool has_annotation(ID id) { return (nth_bit((int)id) & _annotations_present) != 0; }
|
|
|
|
};
|
|
|
|
class FieldAnnotationCollector: public AnnotationCollector {
|
|
|
|
public:
|
|
|
|
FieldAnnotationCollector() : AnnotationCollector(_in_field) { }
|
|
|
|
void apply_to(FieldInfo* f);
|
|
|
|
};
|
|
|
|
class MethodAnnotationCollector: public AnnotationCollector {
|
|
|
|
public:
|
|
|
|
MethodAnnotationCollector() : AnnotationCollector(_in_method) { }
|
|
|
|
void apply_to(methodHandle m);
|
|
|
|
};
|
|
|
|
class ClassAnnotationCollector: public AnnotationCollector {
|
|
|
|
public:
|
|
|
|
ClassAnnotationCollector() : AnnotationCollector(_in_class) { }
|
|
|
|
void apply_to(instanceKlassHandle k);
|
|
|
|
};
|
2010-12-03 15:53:57 -08:00
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
enum { fixed_buffer_size = 128 };
|
|
|
|
u_char linenumbertable_buffer[fixed_buffer_size];
|
|
|
|
|
|
|
|
ClassFileStream* _stream; // Actual input stream
|
|
|
|
|
|
|
|
enum { LegalClass, LegalField, LegalMethod }; // used to verify unqualified names
|
|
|
|
|
|
|
|
// Accessors
|
|
|
|
ClassFileStream* stream() { return _stream; }
|
|
|
|
void set_stream(ClassFileStream* st) { _stream = st; }
|
|
|
|
|
|
|
|
// Constant pool parsing
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void parse_constant_pool_entries(ClassLoaderData* loader_data,
|
2012-03-23 11:16:05 -04:00
|
|
|
constantPoolHandle cp, int length, TRAPS);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
constantPoolHandle parse_constant_pool(ClassLoaderData* loader_data, TRAPS);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Interface parsing
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Array<Klass*>* parse_interfaces(constantPoolHandle cp,
|
2007-12-01 00:00:00 +00:00
|
|
|
int length,
|
2012-09-29 06:40:00 -04:00
|
|
|
ClassLoaderData* loader_data,
|
2007-12-01 00:00:00 +00:00
|
|
|
Handle protection_domain,
|
2011-01-27 16:11:27 -08:00
|
|
|
Symbol* class_name,
|
2012-10-11 12:25:42 -04:00
|
|
|
bool* has_default_methods,
|
2007-12-01 00:00:00 +00:00
|
|
|
TRAPS);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void record_defined_class_dependencies(instanceKlassHandle defined_klass, TRAPS);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Field parsing
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void parse_field_attributes(ClassLoaderData* loader_data,
|
|
|
|
constantPoolHandle cp, u2 attributes_count,
|
2007-12-01 00:00:00 +00:00
|
|
|
bool is_static, u2 signature_index,
|
|
|
|
u2* constantvalue_index_addr,
|
|
|
|
bool* is_synthetic_addr,
|
|
|
|
u2* generic_signature_index_addr,
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
AnnotationArray** field_annotations,
|
2012-12-20 10:22:19 +01:00
|
|
|
AnnotationArray** field_type_annotations,
|
2012-07-12 00:39:53 -07:00
|
|
|
FieldAnnotationCollector* parsed_annotations,
|
|
|
|
TRAPS);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Array<u2>* parse_fields(ClassLoaderData* loader_data,
|
|
|
|
Symbol* class_name,
|
2012-09-29 06:40:00 -04:00
|
|
|
constantPoolHandle cp, bool is_interface,
|
|
|
|
FieldAllocationCount *fac,
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Array<AnnotationArray*>** fields_annotations,
|
2012-12-20 10:22:19 +01:00
|
|
|
Array<AnnotationArray*>** fields_type_annotations,
|
2012-09-29 06:40:00 -04:00
|
|
|
u2* java_fields_count_ptr, TRAPS);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Method parsing
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
methodHandle parse_method(ClassLoaderData* loader_data,
|
|
|
|
constantPoolHandle cp,
|
|
|
|
bool is_interface,
|
2007-12-01 00:00:00 +00:00
|
|
|
AccessFlags* promoted_flags,
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
AnnotationArray** method_annotations,
|
|
|
|
AnnotationArray** method_parameter_annotations,
|
|
|
|
AnnotationArray** method_default_annotations,
|
2012-12-20 10:22:19 +01:00
|
|
|
AnnotationArray** method_type_annotations,
|
2007-12-01 00:00:00 +00:00
|
|
|
TRAPS);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Array<Method*>* parse_methods(ClassLoaderData* loader_data,
|
2012-09-29 06:40:00 -04:00
|
|
|
constantPoolHandle cp,
|
|
|
|
bool is_interface,
|
2007-12-01 00:00:00 +00:00
|
|
|
AccessFlags* promoted_flags,
|
|
|
|
bool* has_final_method,
|
2012-09-29 06:40:00 -04:00
|
|
|
Array<AnnotationArray*>** methods_annotations,
|
|
|
|
Array<AnnotationArray*>** methods_parameter_annotations,
|
|
|
|
Array<AnnotationArray*>** methods_default_annotations,
|
2012-12-20 10:22:19 +01:00
|
|
|
Array<AnnotationArray*>** methods_type_annotations,
|
2012-10-11 12:25:42 -04:00
|
|
|
bool* has_default_method,
|
2007-12-01 00:00:00 +00:00
|
|
|
TRAPS);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Array<int>* sort_methods(ClassLoaderData* loader_data,
|
|
|
|
Array<Method*>* methods,
|
|
|
|
Array<AnnotationArray*>* methods_annotations,
|
|
|
|
Array<AnnotationArray*>* methods_parameter_annotations,
|
|
|
|
Array<AnnotationArray*>* methods_default_annotations,
|
2012-12-20 10:22:19 +01:00
|
|
|
Array<AnnotationArray*>* methods_type_annotations,
|
2007-12-01 00:00:00 +00:00
|
|
|
TRAPS);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
u2* parse_exception_table(ClassLoaderData* loader_data,
|
|
|
|
u4 code_length, u4 exception_table_length,
|
2012-06-26 19:08:44 -04:00
|
|
|
constantPoolHandle cp, TRAPS);
|
2007-12-01 00:00:00 +00:00
|
|
|
void parse_linenumber_table(
|
|
|
|
u4 code_attribute_length, u4 code_length,
|
|
|
|
CompressedLineNumberWriteStream** write_stream, TRAPS);
|
|
|
|
u2* parse_localvariable_table(u4 code_length, u2 max_locals, u4 code_attribute_length,
|
|
|
|
constantPoolHandle cp, u2* localvariable_table_length,
|
|
|
|
bool isLVTT, TRAPS);
|
|
|
|
u2* parse_checked_exceptions(u2* checked_exceptions_length, u4 method_attribute_length,
|
|
|
|
constantPoolHandle cp, TRAPS);
|
|
|
|
void parse_type_array(u2 array_length, u4 code_length, u4* u1_index, u4* u2_index,
|
|
|
|
u1* u1_array, u2* u2_array, constantPoolHandle cp, TRAPS);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Array<u1>* parse_stackmap_table(ClassLoaderData* loader_data, u4 code_attribute_length, TRAPS);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Classfile attribute parsing
|
2012-07-12 00:39:53 -07:00
|
|
|
void parse_classfile_sourcefile_attribute(constantPoolHandle cp, TRAPS);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void parse_classfile_source_debug_extension_attribute(constantPoolHandle cp,
|
|
|
|
int length, TRAPS);
|
|
|
|
u2 parse_classfile_inner_classes_attribute(ClassLoaderData* loader_data,
|
|
|
|
u1* inner_classes_attribute_start,
|
2012-03-13 13:50:48 -04:00
|
|
|
bool parsed_enclosingmethod_attribute,
|
|
|
|
u2 enclosing_method_class_index,
|
|
|
|
u2 enclosing_method_method_index,
|
|
|
|
constantPoolHandle cp,
|
2012-07-12 00:39:53 -07:00
|
|
|
TRAPS);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void parse_classfile_attributes(ClassLoaderData* loader_data,
|
|
|
|
constantPoolHandle cp,
|
2012-07-12 00:39:53 -07:00
|
|
|
ClassAnnotationCollector* parsed_annotations,
|
|
|
|
TRAPS);
|
|
|
|
void parse_classfile_synthetic_attribute(constantPoolHandle cp, TRAPS);
|
|
|
|
void parse_classfile_signature_attribute(constantPoolHandle cp, TRAPS);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
void parse_classfile_bootstrap_methods_attribute(ClassLoaderData* loader_data, constantPoolHandle cp, u4 attribute_length, TRAPS);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Annotations handling
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
AnnotationArray* assemble_annotations(ClassLoaderData* loader_data,
|
|
|
|
u1* runtime_visible_annotations,
|
2012-09-29 06:40:00 -04:00
|
|
|
int runtime_visible_annotations_length,
|
|
|
|
u1* runtime_invisible_annotations,
|
|
|
|
int runtime_invisible_annotations_length, TRAPS);
|
2012-07-12 00:39:53 -07:00
|
|
|
int skip_annotation(u1* buffer, int limit, int index);
|
|
|
|
int skip_annotation_value(u1* buffer, int limit, int index);
|
|
|
|
void parse_annotations(u1* buffer, int limit, constantPoolHandle cp,
|
|
|
|
/* Results (currently, only one result is supported): */
|
|
|
|
AnnotationCollector* result,
|
|
|
|
TRAPS);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Final setup
|
2009-08-13 16:22:45 -07:00
|
|
|
unsigned int compute_oop_map_count(instanceKlassHandle super,
|
|
|
|
unsigned int nonstatic_oop_count,
|
|
|
|
int first_nonstatic_oop_offset);
|
|
|
|
void fill_oop_maps(instanceKlassHandle k,
|
|
|
|
unsigned int nonstatic_oop_map_count,
|
|
|
|
int* nonstatic_oop_offsets,
|
|
|
|
unsigned int* nonstatic_oop_counts);
|
2007-12-01 00:00:00 +00:00
|
|
|
void set_precomputed_flags(instanceKlassHandle k);
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
Array<Klass*>* compute_transitive_interfaces(ClassLoaderData* loader_data,
|
2012-09-29 06:40:00 -04:00
|
|
|
instanceKlassHandle super,
|
|
|
|
Array<Klass*>* local_ifs, TRAPS);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Format checker methods
|
|
|
|
void classfile_parse_error(const char* msg, TRAPS);
|
|
|
|
void classfile_parse_error(const char* msg, int index, TRAPS);
|
|
|
|
void classfile_parse_error(const char* msg, const char *name, TRAPS);
|
|
|
|
void classfile_parse_error(const char* msg, int index, const char *name, TRAPS);
|
|
|
|
inline void guarantee_property(bool b, const char* msg, TRAPS) {
|
|
|
|
if (!b) { classfile_parse_error(msg, CHECK); }
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void assert_property(bool b, const char* msg, TRAPS) {
|
|
|
|
#ifdef ASSERT
|
|
|
|
if (!b) { fatal(msg); }
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void check_property(bool property, const char* msg, int index, TRAPS) {
|
|
|
|
if (_need_verify) {
|
|
|
|
guarantee_property(property, msg, index, CHECK);
|
|
|
|
} else {
|
|
|
|
assert_property(property, msg, CHECK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void check_property(bool property, const char* msg, TRAPS) {
|
|
|
|
if (_need_verify) {
|
|
|
|
guarantee_property(property, msg, CHECK);
|
|
|
|
} else {
|
|
|
|
assert_property(property, msg, CHECK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void guarantee_property(bool b, const char* msg, int index, TRAPS) {
|
|
|
|
if (!b) { classfile_parse_error(msg, index, CHECK); }
|
|
|
|
}
|
|
|
|
inline void guarantee_property(bool b, const char* msg, const char *name, TRAPS) {
|
|
|
|
if (!b) { classfile_parse_error(msg, name, CHECK); }
|
|
|
|
}
|
|
|
|
inline void guarantee_property(bool b, const char* msg, int index, const char *name, TRAPS) {
|
|
|
|
if (!b) { classfile_parse_error(msg, index, name, CHECK); }
|
|
|
|
}
|
|
|
|
|
2010-05-27 17:06:39 -04:00
|
|
|
void throwIllegalSignature(
|
2011-01-27 16:11:27 -08:00
|
|
|
const char* type, Symbol* name, Symbol* sig, TRAPS);
|
2010-05-27 17:06:39 -04:00
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
bool is_supported_version(u2 major, u2 minor);
|
|
|
|
bool has_illegal_visibility(jint flags);
|
|
|
|
|
|
|
|
void verify_constantvalue(int constantvalue_index, int signature_index, constantPoolHandle cp, TRAPS);
|
|
|
|
void verify_legal_utf8(const unsigned char* buffer, int length, TRAPS);
|
2011-01-27 16:11:27 -08:00
|
|
|
void verify_legal_class_name(Symbol* name, TRAPS);
|
|
|
|
void verify_legal_field_name(Symbol* name, TRAPS);
|
|
|
|
void verify_legal_method_name(Symbol* name, TRAPS);
|
|
|
|
void verify_legal_field_signature(Symbol* fieldname, Symbol* signature, TRAPS);
|
|
|
|
int verify_legal_method_signature(Symbol* methodname, Symbol* signature, TRAPS);
|
2007-12-01 00:00:00 +00:00
|
|
|
void verify_legal_class_modifiers(jint flags, TRAPS);
|
|
|
|
void verify_legal_field_modifiers(jint flags, bool is_interface, TRAPS);
|
2011-01-27 16:11:27 -08:00
|
|
|
void verify_legal_method_modifiers(jint flags, bool is_interface, Symbol* name, TRAPS);
|
2007-12-01 00:00:00 +00:00
|
|
|
bool verify_unqualified_name(char* name, unsigned int length, int type);
|
|
|
|
char* skip_over_field_name(char* name, bool slash_ok, unsigned int length);
|
|
|
|
char* skip_over_field_signature(char* signature, bool void_ok, unsigned int length, TRAPS);
|
|
|
|
|
2009-04-08 10:56:49 -07:00
|
|
|
bool is_anonymous() {
|
2011-03-31 02:31:57 -07:00
|
|
|
assert(EnableInvokeDynamic || _host_klass.is_null(), "");
|
2009-04-08 10:56:49 -07:00
|
|
|
return _host_klass.not_null();
|
|
|
|
}
|
2008-11-12 22:33:26 -08:00
|
|
|
bool has_cp_patch_at(int index) {
|
2011-03-31 02:31:57 -07:00
|
|
|
assert(EnableInvokeDynamic, "");
|
2008-11-12 22:33:26 -08:00
|
|
|
assert(index >= 0, "oob");
|
|
|
|
return (_cp_patches != NULL
|
|
|
|
&& index < _cp_patches->length()
|
|
|
|
&& _cp_patches->adr_at(index)->not_null());
|
|
|
|
}
|
|
|
|
Handle cp_patch_at(int index) {
|
|
|
|
assert(has_cp_patch_at(index), "oob");
|
|
|
|
return _cp_patches->at(index);
|
|
|
|
}
|
|
|
|
Handle clear_cp_patch_at(int index) {
|
|
|
|
Handle patch = cp_patch_at(index);
|
|
|
|
_cp_patches->at_put(index, Handle());
|
|
|
|
assert(!has_cp_patch_at(index), "");
|
|
|
|
return patch;
|
|
|
|
}
|
|
|
|
void patch_constant_pool(constantPoolHandle cp, int index, Handle patch, TRAPS);
|
|
|
|
|
|
|
|
// Wrapper for constantTag.is_klass_[or_]reference.
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// In older versions of the VM, Klass*s cannot sneak into early phases of
|
2008-11-12 22:33:26 -08:00
|
|
|
// constant pool construction, but in later versions they can.
|
|
|
|
// %%% Let's phase out the old is_klass_reference.
|
|
|
|
bool is_klass_reference(constantPoolHandle cp, int index) {
|
2012-10-11 14:46:20 -07:00
|
|
|
return (EnableInvokeDynamic
|
2008-11-12 22:33:26 -08:00
|
|
|
? cp->tag_at(index).is_klass_or_reference()
|
|
|
|
: cp->tag_at(index).is_klass_reference());
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
public:
|
|
|
|
// Constructor
|
|
|
|
ClassFileParser(ClassFileStream* st) { set_stream(st); }
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Parse .class file and return new Klass*. The Klass* is not hooked up
|
2007-12-01 00:00:00 +00:00
|
|
|
// to the system dictionary or any other structures, so a .class file can
|
|
|
|
// be loaded several times if desired.
|
|
|
|
// The system dictionary hookup is done by the caller.
|
|
|
|
//
|
|
|
|
// "parsed_name" is updated by this method, and is the name found
|
|
|
|
// while parsing the stream.
|
2011-01-27 16:11:27 -08:00
|
|
|
instanceKlassHandle parseClassFile(Symbol* name,
|
2012-11-29 16:50:29 -05:00
|
|
|
ClassLoaderData* loader_data,
|
2007-12-01 00:00:00 +00:00
|
|
|
Handle protection_domain,
|
2011-01-27 16:11:27 -08:00
|
|
|
TempNewSymbol& parsed_name,
|
2009-09-04 12:53:02 -04:00
|
|
|
bool verify,
|
2008-11-12 22:33:26 -08:00
|
|
|
TRAPS) {
|
2009-04-08 10:56:49 -07:00
|
|
|
KlassHandle no_host_klass;
|
2012-11-29 16:50:29 -05:00
|
|
|
return parseClassFile(name, loader_data, protection_domain, no_host_klass, NULL, parsed_name, verify, THREAD);
|
2008-11-12 22:33:26 -08:00
|
|
|
}
|
2011-01-27 16:11:27 -08:00
|
|
|
instanceKlassHandle parseClassFile(Symbol* name,
|
2012-11-29 16:50:29 -05:00
|
|
|
ClassLoaderData* loader_data,
|
2008-11-12 22:33:26 -08:00
|
|
|
Handle protection_domain,
|
2009-04-08 10:56:49 -07:00
|
|
|
KlassHandle host_klass,
|
2008-11-12 22:33:26 -08:00
|
|
|
GrowableArray<Handle>* cp_patches,
|
2011-01-27 16:11:27 -08:00
|
|
|
TempNewSymbol& parsed_name,
|
2009-09-04 12:53:02 -04:00
|
|
|
bool verify,
|
2007-12-01 00:00:00 +00:00
|
|
|
TRAPS);
|
|
|
|
|
|
|
|
// Verifier checks
|
|
|
|
static void check_super_class_access(instanceKlassHandle this_klass, TRAPS);
|
|
|
|
static void check_super_interface_access(instanceKlassHandle this_klass, TRAPS);
|
|
|
|
static void check_final_method_override(instanceKlassHandle this_klass, TRAPS);
|
|
|
|
static void check_illegal_static_method(instanceKlassHandle this_klass, TRAPS);
|
|
|
|
};
|
2010-11-23 13:22:55 -08:00
|
|
|
|
|
|
|
#endif // SHARE_VM_CLASSFILE_CLASSFILEPARSER_HPP
|