src/hotspot/share/runtime/flags/jvmFlagWriteableList.hpp
author gziemski
Mon, 23 Apr 2018 10:59:39 -0500
changeset 49857 31e07291ae29
parent 47216 src/hotspot/share/runtime/commandLineFlagWriteableList.hpp@71c04702a3d5
permissions -rw-r--r--
8081519: Split globals.hpp to factor out the Flag class Summary: Factored out Flag out go globals, renamed to JVMFlag Reviewed-by: coleenp, dholmes, kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
38273
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
     1
/*
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
     2
 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
     4
 *
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
     7
 * published by the Free Software Foundation.
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
     8
 *
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    13
 * accompanied this code).
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    14
 *
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    18
 *
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    21
 * questions.
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    22
 *
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    23
 */
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    24
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 47216
diff changeset
    25
#ifndef SHARE_VM_RUNTIME_JVMFLAGWRITEABLE_HPP
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 47216
diff changeset
    26
#define SHARE_VM_RUNTIME_JVMFLAGWRITEABLE_HPP
38273
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    27
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    28
#include "utilities/growableArray.hpp"
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    29
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 47216
diff changeset
    30
class JVMFlagWriteable : public CHeapObj<mtArguments> {
38273
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    31
public:
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    32
  enum WriteableType {
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    33
    // can be set without any limits
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    34
    Always           = 0,
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    35
    // can only be set once, either via command lines or during runtime
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    36
    Once             = 1,
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    37
    // can only be set on command line (multiple times allowed)
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    38
    CommandLineOnly  = 2
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    39
  };
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    40
private:
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    41
  const char* _name;
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    42
  WriteableType _type;
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    43
  bool _writeable;
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    44
  bool _startup_done;
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    45
public:
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    46
  // the "name" argument must be a string literal
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 47216
diff changeset
    47
  JVMFlagWriteable(const char* name, WriteableType type) { _name=name; _type=type; _writeable=true; _startup_done=false; }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 47216
diff changeset
    48
  ~JVMFlagWriteable() {}
38273
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    49
  const char* name() { return _name; }
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    50
  const WriteableType type() { return _type; }
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    51
  bool is_writeable(void);
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    52
  void mark_once(void);
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    53
  void mark_startup(void);
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    54
};
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    55
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 47216
diff changeset
    56
class JVMFlagWriteableList : public AllStatic {
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 47216
diff changeset
    57
  static GrowableArray<JVMFlagWriteable*>* _controls;
38273
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    58
public:
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    59
  static void init();
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    60
  static int length() { return (_controls != NULL) ? _controls->length() : 0; }
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 47216
diff changeset
    61
  static JVMFlagWriteable* at(int i) { return (_controls != NULL) ? _controls->at(i) : NULL; }
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 47216
diff changeset
    62
  static JVMFlagWriteable* find(const char* name);
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 47216
diff changeset
    63
  static void add(JVMFlagWriteable* range) { _controls->append(range); }
38273
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    64
  static void mark_startup(void);
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    65
};
2634194d7555 8073500: Prevent certain commercial flags from being changed at runtime
gziemski
parents:
diff changeset
    66
49857
31e07291ae29 8081519: Split globals.hpp to factor out the Flag class
gziemski
parents: 47216
diff changeset
    67
#endif // SHARE_VM_RUNTIME_JVMFLAGWRITEABLE_HPP