@@ -28,6 +28,24 @@ static inline bool isDigit(char c) {
2828}
2929
3030
31+ // Based on: https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#:~:text=Table%C2%A04.5.%C2%A0Method%20access%20and%20property%20flags
32+ // Good practice order from: https://checkstyle.sourceforge.io/config_modifier.html#ModifierOrder
33+ const static std::pair<int , std::string> access_flags [] = {
34+ std::make_pair (0x0001 , " public" ),
35+ std::make_pair (0x0002 , " private" ),
36+ std::make_pair (0x0004 , " protected" ),
37+ std::make_pair (0x0400 , " abstract" ),
38+ std::make_pair (0x0008 , " static" ),
39+ std::make_pair (0x0010 , " final" ),
40+ std::make_pair (0x0020 , " synchronized" ),
41+ std::make_pair (0x0100 , " native" ),
42+ std::make_pair (0x0800 , " strict" ),
43+ std::make_pair (0x0040 , " bridge" ),
44+ std::make_pair (0x0080 , " varargs" ),
45+ std::make_pair (0x1000 , " synthetic" ),
46+ };
47+
48+
3149Matcher::Matcher (const char * pattern) {
3250 if (pattern[0 ] == ' *' ) {
3351 _type = MATCH_ENDS_WITH;
@@ -95,7 +113,7 @@ FrameName::FrameName(Arguments& args, int style, int epoch, Mutex& thread_names_
95113{
96114 // Require printf to use standard C format regardless of system locale
97115 _saved_locale = uselocale (newlocale (LC_NUMERIC_MASK, " C" , (locale_t )0 ));
98-
116+ _includemm = args. _includemm ;
99117 buildFilter (_include, args._buf , args._include );
100118 buildFilter (_exclude, args._buf , args._exclude );
101119
@@ -167,6 +185,7 @@ void FrameName::javaMethodName(jmethodID method) {
167185 char * class_name = NULL ;
168186 char * method_name = NULL ;
169187 char * method_sig = NULL ;
188+ jint modifiers = 0 ;
170189
171190 jvmtiEnv* jvmti = VM::jvmti ();
172191 jvmtiError err;
@@ -176,6 +195,16 @@ void FrameName::javaMethodName(jmethodID method) {
176195 (err = jvmti->GetClassSignature (method_class, &class_name, NULL )) == 0 ) {
177196 // Trim 'L' and ';' off the class descriptor like 'Ljava/lang/Object;'
178197 javaClassName (class_name + 1 , strlen (class_name) - 2 , _style);
198+ if (_includemm) {
199+ jvmti->GetMethodModifiers (method, &modifiers);
200+ std::string modifiers_to_append = " " ;
201+ for (int i=0 ; i<(sizeof (access_flags) / sizeof (access_flags[0 ])); i++) {
202+ if (modifiers & access_flags[i].first ) {
203+ modifiers_to_append.append (access_flags[i].second + " " );
204+ }
205+ }
206+ _str.insert (0 , modifiers_to_append);
207+ }
179208 _str.append (" ." ).append (method_name);
180209 if (_style & STYLE_SIGNATURES) {
181210 if (_style & STYLE_NO_SEMICOLON) {
0 commit comments