JDK-7041183 : Improve error handling in src/share/vm/services/management.cpp
  • Type: Bug
  • Component: core-svc
  • Sub-Component: java.lang.management
  • Affected Version: 7
  • Priority: P5
  • Status: Closed
  • Resolution: Not an Issue
  • OS: generic
  • CPU: generic
  • Submitted: 2011-05-02
  • Updated: 2023-12-14
  • Resolved: 2015-11-24
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdResolved
Related Reports
Relates :  
Relates :  
Description
JNIEXPORT jobject JNICALL
Java_sun_management_MemoryPoolImpl_getUsage0
  (JNIEnv *env, jobject pool)
{
    jobject usage = jmm_interface->GetMemoryPoolUsage(env, pool);
    if (usage == NULL) {
        // Throw internal error since this implementation expects the
        // pool will never become invalid.
        JNU_ThrowInternalError(env, "Memory Pool not found");
    }
    return usage;
}

This function as well as Java_sun_management_MemoryPoolImpl_getMemoryManagers0, Java_sun_management_MemoryPoolImpl_getPeakUsage0 should propagate the exception that may be returned by the jmm call rather than throw InternalError.

Comments
Closing this as per the discussion in: http://mail.openjdk.java.net/pipermail/serviceability-dev/2015-November/018263.html
24-11-2015

Basic premise: MemoryPoolMXBeans should never be invalid VM code returns NULL if they are found to be invalid JMM library code converts NULL to InternalError because it should not happen. If it does it is a VM bug. If you find a situation where they are invalid the cause of that needs to be determined and either fixed, or else the specifications and code updated to reflect that there are circumstances where they can be invalid.
13-11-2015

The initial issue was raised as: Improve error handling in jdk/src/share/native/sun/management/MemoryPoolImpl.c. The functions described above reside in MemoryPoolImpl.c. The actual file modified is jdk/src/share/vm/services/management.cpp, due to the above mentioned functions indirectly calling get_memory_pool_from_jobject(), and the change is done to have get_memory_pool_from_jobject() throw an exception instead of just returning the MemoryPool when it is NULL. Added asserts in the upper layer for double checking.
30-10-2015

Fix under review.
27-10-2015