< prev index next >

src/hotspot/share/classfile/classFileParser.cpp

Print this page

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


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

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










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

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




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

 949                          "Bad string initial value in class file %s",
 950                          CHECK);
 951       break;
 952     }
 953     default: {
 954       classfile_parse_error("Unable to set initial value %u in class file %s",
 955                              constantvalue_index,
 956                              THREAD);
 957     }
 958   }
 959 }
 960 
 961 class AnnotationCollector : public ResourceObj{
 962 public:
 963   enum Location { _in_field, _in_method, _in_class };
 964   enum ID {
 965     _unknown = 0,
 966     _method_CallerSensitive,
 967     _method_ForceInline,
 968     _method_DontInline,
 969     _method_ChangesCurrentThread,
 970     _method_JvmtiMountTransition,
 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(jdk_internal_vm_annotation_ChangesCurrentThread_signature): {
1991       if (_location != _in_method)  break;  // only allow for methods
1992       if (!privileged)              break;  // only allow in privileged code
1993       return _method_ChangesCurrentThread;
1994     }
1995     case VM_SYMBOL_ENUM_NAME(jdk_internal_vm_annotation_JvmtiMountTransition_signature): {
1996       if (_location != _in_method)  break;  // only allow for methods
1997       if (!privileged)              break;  // only allow in privileged code
1998       return _method_JvmtiMountTransition;
1999     }
2000     case VM_SYMBOL_ENUM_NAME(java_lang_invoke_InjectedProfile_signature): {
2001       if (_location != _in_method)  break;  // only allow for methods
2002       if (!privileged)              break;  // only allow in privileged code
2003       return _method_InjectedProfile;
2004     }
2005     case VM_SYMBOL_ENUM_NAME(java_lang_invoke_LambdaForm_Compiled_signature): {
2006       if (_location != _in_method)  break;  // only allow for methods
2007       if (!privileged)              break;  // only allow in privileged code
2008       return _method_LambdaForm_Compiled;
2009     }
2010     case VM_SYMBOL_ENUM_NAME(jdk_internal_vm_annotation_Hidden_signature): {
2011       if (_location != _in_method)  break;  // only allow for methods
2012       if (!privileged)              break;  // only allow in privileged code
2013       return _method_Hidden;
2014     }
2015     case VM_SYMBOL_ENUM_NAME(jdk_internal_misc_Scoped_signature): {
2016       if (_location != _in_method)  break;  // only allow for methods
2017       if (!privileged)              break;  // only allow in privileged code
2018       return _method_Scoped;
2019     }

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