< prev index next >

src/share/vm/services/management.cpp

Print this page


   1 /*
   2  * Copyright (c) 2003, 2015, 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  *


1593       // Exclude the locked (diagnostic, experimental) flags
1594       if ((flag->is_unlocked() || flag->is_unlocker()) &&
1595           add_global_entry(env, null_h, &globals[num_entries], flag, THREAD)) {
1596         num_entries++;
1597       }
1598     }
1599     return num_entries;
1600   }
1601 JVM_END
1602 
1603 JVM_ENTRY(void, jmm_SetVMGlobal(JNIEnv *env, jstring flag_name, jvalue new_value))
1604   ResourceMark rm(THREAD);
1605 
1606   oop fn = JNIHandles::resolve_external_guard(flag_name);
1607   if (fn == NULL) {
1608     THROW_MSG(vmSymbols::java_lang_NullPointerException(),
1609               "The flag name cannot be null.");
1610   }
1611   char* name = java_lang_String::as_utf8_string(fn);
1612 
1613   FormatBuffer<80> err_msg("%s", "");
1614   int succeed = WriteableFlags::set_flag(name, new_value, Flag::MANAGEMENT, err_msg);
1615 
1616   if (succeed != Flag::SUCCESS) {
1617     if (succeed == Flag::MISSING_VALUE) {
1618       // missing value causes NPE to be thrown
1619       THROW(vmSymbols::java_lang_NullPointerException());
1620     } else {
1621       // all the other errors are reported as IAE with the appropriate error message
1622       THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
1623                 err_msg.buffer());
1624     }
1625   }
1626   assert(succeed == Flag::SUCCESS, "Setting flag should succeed");
1627 JVM_END
1628 
1629 class ThreadTimesClosure: public ThreadClosure {
1630  private:
1631   objArrayHandle _names_strings;
1632   char **_names_chars;
1633   typeArrayHandle _times;
1634   int _names_len;
1635   int _times_len;
1636   int _count;
1637 
1638  public:
1639   ThreadTimesClosure(objArrayHandle names, typeArrayHandle times);
1640   ~ThreadTimesClosure();
1641   virtual void do_thread(Thread* thread);
1642   void do_unlocked();
1643   int count() { return _count; }


   1 /*
   2  * Copyright (c) 2003, 2016, 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  *


1593       // Exclude the locked (diagnostic, experimental) flags
1594       if ((flag->is_unlocked() || flag->is_unlocker()) &&
1595           add_global_entry(env, null_h, &globals[num_entries], flag, THREAD)) {
1596         num_entries++;
1597       }
1598     }
1599     return num_entries;
1600   }
1601 JVM_END
1602 
1603 JVM_ENTRY(void, jmm_SetVMGlobal(JNIEnv *env, jstring flag_name, jvalue new_value))
1604   ResourceMark rm(THREAD);
1605 
1606   oop fn = JNIHandles::resolve_external_guard(flag_name);
1607   if (fn == NULL) {
1608     THROW_MSG(vmSymbols::java_lang_NullPointerException(),
1609               "The flag name cannot be null.");
1610   }
1611   char* name = java_lang_String::as_utf8_string(fn);
1612 
1613   FormatBuffer<80> error_msg("%s", "");
1614   int succeed = WriteableFlags::set_flag(name, new_value, Flag::MANAGEMENT, error_msg);
1615 
1616   if (succeed != Flag::SUCCESS) {
1617     if (succeed == Flag::MISSING_VALUE) {
1618       // missing value causes NPE to be thrown
1619       THROW(vmSymbols::java_lang_NullPointerException());
1620     } else {
1621       // all the other errors are reported as IAE with the appropriate error message
1622       THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
1623                 error_msg.buffer());
1624     }
1625   }
1626   assert(succeed == Flag::SUCCESS, "Setting flag should succeed");
1627 JVM_END
1628 
1629 class ThreadTimesClosure: public ThreadClosure {
1630  private:
1631   objArrayHandle _names_strings;
1632   char **_names_chars;
1633   typeArrayHandle _times;
1634   int _names_len;
1635   int _times_len;
1636   int _count;
1637 
1638  public:
1639   ThreadTimesClosure(objArrayHandle names, typeArrayHandle times);
1640   ~ThreadTimesClosure();
1641   virtual void do_thread(Thread* thread);
1642   void do_unlocked();
1643   int count() { return _count; }


< prev index next >