< prev index next >

src/hotspot/share/classfile/classFileParser.cpp

Print this page

 951                          "Bad string initial value in class file %s",
 952                          CHECK);
 953       break;
 954     }
 955     default: {
 956       classfile_parse_error("Unable to set initial value %u in class file %s",
 957                              constantvalue_index,
 958                              THREAD);
 959     }
 960   }
 961 }
 962 
 963 class AnnotationCollector : public ResourceObj{
 964 public:
 965   enum Location { _in_field, _in_method, _in_class };
 966   enum ID {
 967     _unknown = 0,
 968     _method_CallerSensitive,
 969     _method_ForceInline,
 970     _method_DontInline,


 971     _method_InjectedProfile,
 972     _method_LambdaForm_Compiled,
 973     _method_Hidden,
 974     _method_Scoped,
 975     _method_IntrinsicCandidate,
 976     _jdk_internal_vm_annotation_Contended,
 977     _field_Stable,
 978     _jdk_internal_vm_annotation_ReservedStackAccess,
 979     _jdk_internal_ValueBased,
 980     _annotation_LIMIT
 981   };
 982   const Location _location;
 983   int _annotations_present;
 984   u2 _contended_group;
 985 
 986   AnnotationCollector(Location location)
 987     : _location(location), _annotations_present(0), _contended_group(0)
 988   {
 989     assert((int)_annotation_LIMIT <= (int)sizeof(_annotations_present) * BitsPerByte, "");
 990   }

1970   // Privileged code can use all annotations.  Other code silently drops some.
1971   const bool privileged = loader_data->is_boot_class_loader_data() ||
1972                           loader_data->is_platform_class_loader_data() ||
1973                           can_access_vm_annotations;
1974   switch (sid) {
1975     case VM_SYMBOL_ENUM_NAME(reflect_CallerSensitive_signature): {
1976       if (_location != _in_method)  break;  // only allow for methods
1977       if (!privileged)              break;  // only allow in privileged code
1978       return _method_CallerSensitive;
1979     }
1980     case VM_SYMBOL_ENUM_NAME(jdk_internal_vm_annotation_ForceInline_signature): {
1981       if (_location != _in_method)  break;  // only allow for methods
1982       if (!privileged)              break;  // only allow in privileged code
1983       return _method_ForceInline;
1984     }
1985     case VM_SYMBOL_ENUM_NAME(jdk_internal_vm_annotation_DontInline_signature): {
1986       if (_location != _in_method)  break;  // only allow for methods
1987       if (!privileged)              break;  // only allow in privileged code
1988       return _method_DontInline;
1989     }










1990     case VM_SYMBOL_ENUM_NAME(java_lang_invoke_InjectedProfile_signature): {
1991       if (_location != _in_method)  break;  // only allow for methods
1992       if (!privileged)              break;  // only allow in privileged code
1993       return _method_InjectedProfile;
1994     }
1995     case VM_SYMBOL_ENUM_NAME(java_lang_invoke_LambdaForm_Compiled_signature): {
1996       if (_location != _in_method)  break;  // only allow for methods
1997       if (!privileged)              break;  // only allow in privileged code
1998       return _method_LambdaForm_Compiled;
1999     }
2000     case VM_SYMBOL_ENUM_NAME(jdk_internal_vm_annotation_Hidden_signature): {
2001       if (_location != _in_method)  break;  // only allow for methods
2002       if (!privileged)              break;  // only allow in privileged code
2003       return _method_Hidden;
2004     }
2005     case VM_SYMBOL_ENUM_NAME(jdk_internal_misc_Scoped_signature): {
2006       if (_location != _in_method)  break;  // only allow for methods
2007       if (!privileged)              break;  // only allow in privileged code
2008       return _method_Scoped;
2009     }

2046 void ClassFileParser::FieldAnnotationCollector::apply_to(FieldInfo* f) {
2047   if (is_contended())
2048     f->set_contended_group(contended_group());
2049   if (is_stable())
2050     f->set_stable(true);
2051 }
2052 
2053 ClassFileParser::FieldAnnotationCollector::~FieldAnnotationCollector() {
2054   // If there's an error deallocate metadata for field annotations
2055   MetadataFactory::free_array<u1>(_loader_data, _field_annotations);
2056   MetadataFactory::free_array<u1>(_loader_data, _field_type_annotations);
2057 }
2058 
2059 void MethodAnnotationCollector::apply_to(const methodHandle& m) {
2060   if (has_annotation(_method_CallerSensitive))
2061     m->set_caller_sensitive(true);
2062   if (has_annotation(_method_ForceInline))
2063     m->set_force_inline(true);
2064   if (has_annotation(_method_DontInline))
2065     m->set_dont_inline(true);




2066   if (has_annotation(_method_InjectedProfile))
2067     m->set_has_injected_profile(true);
2068   if (has_annotation(_method_LambdaForm_Compiled) && m->intrinsic_id() == vmIntrinsics::_none)
2069     m->set_intrinsic_id(vmIntrinsics::_compiledLambdaForm);
2070   if (has_annotation(_method_Hidden))
2071     m->set_hidden(true);
2072   if (has_annotation(_method_Scoped))
2073     m->set_scoped(true);
2074   if (has_annotation(_method_IntrinsicCandidate) && !m->is_synthetic())
2075     m->set_intrinsic_candidate(true);
2076   if (has_annotation(_jdk_internal_vm_annotation_ReservedStackAccess))
2077     m->set_has_reserved_stack_access(true);
2078 }
2079 
2080 void ClassFileParser::ClassAnnotationCollector::apply_to(InstanceKlass* ik) {
2081   assert(ik != NULL, "invariant");
2082   if (has_annotation(_jdk_internal_vm_annotation_Contended)) {
2083     ik->set_is_contended(is_contended());
2084   }
2085   if (has_annotation(_jdk_internal_ValueBased)) {

 951                          "Bad string initial value in class file %s",
 952                          CHECK);
 953       break;
 954     }
 955     default: {
 956       classfile_parse_error("Unable to set initial value %u in class file %s",
 957                              constantvalue_index,
 958                              THREAD);
 959     }
 960   }
 961 }
 962 
 963 class AnnotationCollector : public ResourceObj{
 964 public:
 965   enum Location { _in_field, _in_method, _in_class };
 966   enum ID {
 967     _unknown = 0,
 968     _method_CallerSensitive,
 969     _method_ForceInline,
 970     _method_DontInline,
 971     _method_ChangesCurrentThread,
 972     _method_JvmtiMountTransition,
 973     _method_InjectedProfile,
 974     _method_LambdaForm_Compiled,
 975     _method_Hidden,
 976     _method_Scoped,
 977     _method_IntrinsicCandidate,
 978     _jdk_internal_vm_annotation_Contended,
 979     _field_Stable,
 980     _jdk_internal_vm_annotation_ReservedStackAccess,
 981     _jdk_internal_ValueBased,
 982     _annotation_LIMIT
 983   };
 984   const Location _location;
 985   int _annotations_present;
 986   u2 _contended_group;
 987 
 988   AnnotationCollector(Location location)
 989     : _location(location), _annotations_present(0), _contended_group(0)
 990   {
 991     assert((int)_annotation_LIMIT <= (int)sizeof(_annotations_present) * BitsPerByte, "");
 992   }

1972   // Privileged code can use all annotations.  Other code silently drops some.
1973   const bool privileged = loader_data->is_boot_class_loader_data() ||
1974                           loader_data->is_platform_class_loader_data() ||
1975                           can_access_vm_annotations;
1976   switch (sid) {
1977     case VM_SYMBOL_ENUM_NAME(reflect_CallerSensitive_signature): {
1978       if (_location != _in_method)  break;  // only allow for methods
1979       if (!privileged)              break;  // only allow in privileged code
1980       return _method_CallerSensitive;
1981     }
1982     case VM_SYMBOL_ENUM_NAME(jdk_internal_vm_annotation_ForceInline_signature): {
1983       if (_location != _in_method)  break;  // only allow for methods
1984       if (!privileged)              break;  // only allow in privileged code
1985       return _method_ForceInline;
1986     }
1987     case VM_SYMBOL_ENUM_NAME(jdk_internal_vm_annotation_DontInline_signature): {
1988       if (_location != _in_method)  break;  // only allow for methods
1989       if (!privileged)              break;  // only allow in privileged code
1990       return _method_DontInline;
1991     }
1992     case VM_SYMBOL_ENUM_NAME(jdk_internal_vm_annotation_ChangesCurrentThread_signature): {
1993       if (_location != _in_method)  break;  // only allow for methods
1994       if (!privileged)              break;  // only allow in privileged code
1995       return _method_ChangesCurrentThread;
1996     }
1997     case VM_SYMBOL_ENUM_NAME(jdk_internal_vm_annotation_JvmtiMountTransition_signature): {
1998       if (_location != _in_method)  break;  // only allow for methods
1999       if (!privileged)              break;  // only allow in privileged code
2000       return _method_JvmtiMountTransition;
2001     }
2002     case VM_SYMBOL_ENUM_NAME(java_lang_invoke_InjectedProfile_signature): {
2003       if (_location != _in_method)  break;  // only allow for methods
2004       if (!privileged)              break;  // only allow in privileged code
2005       return _method_InjectedProfile;
2006     }
2007     case VM_SYMBOL_ENUM_NAME(java_lang_invoke_LambdaForm_Compiled_signature): {
2008       if (_location != _in_method)  break;  // only allow for methods
2009       if (!privileged)              break;  // only allow in privileged code
2010       return _method_LambdaForm_Compiled;
2011     }
2012     case VM_SYMBOL_ENUM_NAME(jdk_internal_vm_annotation_Hidden_signature): {
2013       if (_location != _in_method)  break;  // only allow for methods
2014       if (!privileged)              break;  // only allow in privileged code
2015       return _method_Hidden;
2016     }
2017     case VM_SYMBOL_ENUM_NAME(jdk_internal_misc_Scoped_signature): {
2018       if (_location != _in_method)  break;  // only allow for methods
2019       if (!privileged)              break;  // only allow in privileged code
2020       return _method_Scoped;
2021     }

2058 void ClassFileParser::FieldAnnotationCollector::apply_to(FieldInfo* f) {
2059   if (is_contended())
2060     f->set_contended_group(contended_group());
2061   if (is_stable())
2062     f->set_stable(true);
2063 }
2064 
2065 ClassFileParser::FieldAnnotationCollector::~FieldAnnotationCollector() {
2066   // If there's an error deallocate metadata for field annotations
2067   MetadataFactory::free_array<u1>(_loader_data, _field_annotations);
2068   MetadataFactory::free_array<u1>(_loader_data, _field_type_annotations);
2069 }
2070 
2071 void MethodAnnotationCollector::apply_to(const methodHandle& m) {
2072   if (has_annotation(_method_CallerSensitive))
2073     m->set_caller_sensitive(true);
2074   if (has_annotation(_method_ForceInline))
2075     m->set_force_inline(true);
2076   if (has_annotation(_method_DontInline))
2077     m->set_dont_inline(true);
2078   if (has_annotation(_method_ChangesCurrentThread))
2079     m->set_changes_current_thread(true);
2080   if (has_annotation(_method_JvmtiMountTransition))
2081     m->set_jvmti_mount_transition(true);
2082   if (has_annotation(_method_InjectedProfile))
2083     m->set_has_injected_profile(true);
2084   if (has_annotation(_method_LambdaForm_Compiled) && m->intrinsic_id() == vmIntrinsics::_none)
2085     m->set_intrinsic_id(vmIntrinsics::_compiledLambdaForm);
2086   if (has_annotation(_method_Hidden))
2087     m->set_hidden(true);
2088   if (has_annotation(_method_Scoped))
2089     m->set_scoped(true);
2090   if (has_annotation(_method_IntrinsicCandidate) && !m->is_synthetic())
2091     m->set_intrinsic_candidate(true);
2092   if (has_annotation(_jdk_internal_vm_annotation_ReservedStackAccess))
2093     m->set_has_reserved_stack_access(true);
2094 }
2095 
2096 void ClassFileParser::ClassAnnotationCollector::apply_to(InstanceKlass* ik) {
2097   assert(ik != NULL, "invariant");
2098   if (has_annotation(_jdk_internal_vm_annotation_Contended)) {
2099     ik->set_is_contended(is_contended());
2100   }
2101   if (has_annotation(_jdk_internal_ValueBased)) {
< prev index next >