Resource Management is a commercial feature that must be unlocked before being used. To learn more about commercial features and how to unlock them visit http://www.oracle.com/technetwork/java/javaseproducts/
jdk.management.resource

## Class BoundedMeter

- java.lang.Object
- - jdk.management.resource.SimpleMeter
  - - jdk.management.resource.NotifyingMeter
    - - jdk.management.resource.BoundedMeter

- All Implemented Interfaces:
    ResourceMeter, ResourceRequest

      public class BoundedMeter
      extends NotifyingMeter
      implements ResourceMeter, ResourceRequest

  A BoundedMeter enforces an upper bound, provides an approver callback for changes and allocates from an optional parent. Approval callbacks occur upon crossing the granularity threshold and when the bound is exceeded; the approval callback occurs before the bounds check. All requests are granted in full or not granted. Requests that are denied are not allocated from the parent.
  Since:
    8u40

- - ### Constructor Summary

    Constructors
    Modifier | Constructor | Description
    --- | --- | ---
    `protected` | `BoundedMeter(ResourceType type, long bound, ResourceRequest parent, ResourceApprover approver)` | Constructor of a BoundedMeter.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static BoundedMeter` | `create(ResourceType type, long bound)` | Returns a new BoundedMeter with the type and upper bound.
    `static BoundedMeter` | `create(ResourceType type, long bound, ResourceApprover approver)` | Returns a new BoundedMeter with the type, upper bound, and approver.
    `static BoundedMeter` | `create(ResourceType type, long bound, ResourceRequest parent)` | Returns a new BoundedMeter with the type, upper bound, and parent.
    `static BoundedMeter` | `create(ResourceType type, long bound, ResourceRequest parent, ResourceApprover approver)` | Returns a new BoundedMeter with the type, upper bound, parent, and approver.
    `long` | `getBound()` | Returns the upper bound for the meter.
    `long` | `setBound(long bound)` | Sets the bound.
    `String` | `toString()` | Returns a string representation of the meter.
    `protected long` | `validate(long previous, long amount, ResourceId id)` | Returns the amount validated by the approver.

    - ### Methods inherited from class jdk.management.resource.NotifyingMeter

      `create, create, getApprover, getGranularity, setGranularity`

    - ### Methods inherited from class jdk.management.resource.SimpleMeter

      `create, create, equals, getAllocated, getParent, getType, getValue, hashCode, request`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface jdk.management.resource.ResourceMeter

      `getAllocated, getType, getValue`

    - ### Methods inherited from interface jdk.management.resource.ResourceRequest

      `request`

- - ### Constructor Detail

    - #### BoundedMeter

          protected BoundedMeter(ResourceType type,
                                 long bound,
                                 ResourceRequest parent,
                                 ResourceApprover approver)

      Constructor of a BoundedMeter.
      Parameters:
        `type` - the ResourceType of the meter
        `bound` - the initial upper bound
        `parent` - a ResourceRequest to request from; may be `null`
        `approver` - the ResourceApprover to be notified; may be `null`

  - ### Method Detail

    - #### create

          public static BoundedMeter create(ResourceType type,
                                            long bound)

      Returns a new BoundedMeter with the type and upper bound.
      Parameters:
        `type` - the ResourceType
        `bound` - the upper bound; must be zero or greater
      Returns:
        a new BoundedMeter with the type and bound
      Throws:
        `IllegalArgumentException` - if the bound is less than zero

    - #### create

          public static BoundedMeter create(ResourceType type,
                                            long bound,
                                            ResourceRequest parent)

      Returns a new BoundedMeter with the type, upper bound, and parent.
      Parameters:
        `type` - the ResourceType
        `bound` - the upper bound; must be zero or greater
        `parent` - a ResourceRequest to request from; may be `null`
      Returns:
        a new BoundedMeter with the type, bound, and parent approver
      Throws:
        `IllegalArgumentException` - if the bound is less than zero

    - #### create

          public static BoundedMeter create(ResourceType type,
                                            long bound,
                                            ResourceRequest parent,
                                            ResourceApprover approver)

      Returns a new BoundedMeter with the type, upper bound, parent, and approver.
      Parameters:
        `type` - the ResourceType
        `bound` - the upper bound; must be zero or greater
        `parent` - a ResourceRequest to request from; may be `null`
        `approver` - the ResourceApprover to be notified; may be `null`
      Returns:
        a new BoundedMeter with the type, bound, parent, and approver
      Throws:
        `IllegalArgumentException` - if the bound is less than zero

    - #### create

          public static BoundedMeter create(ResourceType type,
                                            long bound,
                                            ResourceApprover approver)

      Returns a new BoundedMeter with the type, upper bound, and approver.
      Parameters:
        `type` - the ResourceType
        `bound` - the upper bound; must be zero or greater
        `approver` - the ResourceApprover to be notified; may be `null`
      Returns:
        a new BoundedMeter with the type, bound, parent, and approver
      Throws:
        `IllegalArgumentException` - if the bound is less than zero

    - #### validate

          protected long validate(long previous,
                                  long amount,
                                  ResourceId id)

      Description copied from class: `NotifyingMeter`
      Returns the amount validated by the approver. The `ResourceApprover.request` must return only the amount requested, zero, or throw a `ResourceRequestDeniedException`. If the amount returned is any other value, it is ignored and the requested amount is returned.
      Overrides:
        `validate` in class `NotifyingMeter`
      Parameters:
        `previous` - the previous meter value
        `amount` - the amount to validate; if zero nothing is done
        `id` - the ResourceId for the resource instance; may be `null`
      Returns:
        the value validated zero, positive or negative

    - #### getBound

          public final long getBound()

      Returns the upper bound for the meter.
      Returns:
        the upper bound

    - #### setBound

          public final long setBound(long bound)

      Sets the bound.
      Parameters:
        `bound` - the bound; must be zero or greater
      Returns:
        the previous upper bound
      Throws:
        `IllegalArgumentException` - if the bound is less than zero

    - #### toString

          public String toString()

      Description copied from class: `SimpleMeter`
      Returns a string representation of the meter.
      Overrides:
        `toString` in class `SimpleMeter`
      Returns:
        a string representation of the meter

Copyright © 2014, 2026, Oracle and/or its affiliates. All rights reserved.