mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-16 13:35:22 +02:00
[277764] [dstore][regression] IllegalAccessException thrown when connecting to a running server
This commit is contained in:
parent
27838e12cd
commit
9576ec7cd8
1 changed files with 7 additions and 1 deletions
|
@ -11,6 +11,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* David McKnight (IBM) - [261644] [dstore] remote search improvements
|
* David McKnight (IBM) - [261644] [dstore] remote search improvements
|
||||||
|
* David McKnight (IBM) - [277764] [dstore][regression] IllegalAccessException thrown when connecting to a running server
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.dstore.internal.core.util;
|
package org.eclipse.dstore.internal.core.util;
|
||||||
|
@ -57,13 +58,15 @@ public class MemoryManager {
|
||||||
Object mbObj = list.get(i);
|
Object mbObj = list.get(i);
|
||||||
Class mbClass = mbObj.getClass();
|
Class mbClass = mbObj.getClass();
|
||||||
|
|
||||||
Method getSupportedMethod = mbClass.getDeclaredMethod("isUsageThresholdSupported", new Class[0]); //$NON-NLS-1$
|
|
||||||
|
|
||||||
|
Method getSupportedMethod = mbClass.getDeclaredMethod("isUsageThresholdSupported", new Class[0]); //$NON-NLS-1$
|
||||||
|
getSupportedMethod.setAccessible(true);
|
||||||
Boolean usageThresholdSupported = (Boolean)getSupportedMethod.invoke(mbObj, null);
|
Boolean usageThresholdSupported = (Boolean)getSupportedMethod.invoke(mbObj, null);
|
||||||
if (usageThresholdSupported.booleanValue()){
|
if (usageThresholdSupported.booleanValue()){
|
||||||
|
|
||||||
Method getTypeMethod = mbClass.getDeclaredMethod("getType", new Class[0]); //$NON-NLS-1$
|
Method getTypeMethod = mbClass.getDeclaredMethod("getType", new Class[0]); //$NON-NLS-1$
|
||||||
|
|
||||||
|
getTypeMethod.setAccessible(true);
|
||||||
Object typeObj = getTypeMethod.invoke(mbObj, null);
|
Object typeObj = getTypeMethod.invoke(mbObj, null);
|
||||||
Class memoryType = Class.forName("java.lang.management.MemoryType"); //$NON-NLS-1$
|
Class memoryType = Class.forName("java.lang.management.MemoryType"); //$NON-NLS-1$
|
||||||
Field field = memoryType.getField("HEAP"); //$NON-NLS-1$
|
Field field = memoryType.getField("HEAP"); //$NON-NLS-1$
|
||||||
|
@ -71,16 +74,19 @@ public class MemoryManager {
|
||||||
|
|
||||||
if (fieldObj.equals(typeObj)){
|
if (fieldObj.equals(typeObj)){
|
||||||
Method getUsageMethod = mbClass.getDeclaredMethod("getUsage", new Class[0]); //$NON-NLS-1$
|
Method getUsageMethod = mbClass.getDeclaredMethod("getUsage", new Class[0]); //$NON-NLS-1$
|
||||||
|
getUsageMethod.setAccessible(true);
|
||||||
Object usageObj = getUsageMethod.invoke(mbObj, null);
|
Object usageObj = getUsageMethod.invoke(mbObj, null);
|
||||||
|
|
||||||
Class usageClass = usageObj.getClass();
|
Class usageClass = usageObj.getClass();
|
||||||
Method getMaxMethod = usageClass.getDeclaredMethod("getMax", new Class[0]); //$NON-NLS-1$
|
Method getMaxMethod = usageClass.getDeclaredMethod("getMax", new Class[0]); //$NON-NLS-1$
|
||||||
|
getMaxMethod.setAccessible(true);
|
||||||
Long maxObj = (Long)getMaxMethod.invoke(usageObj, null);
|
Long maxObj = (Long)getMaxMethod.invoke(usageObj, null);
|
||||||
|
|
||||||
Method setThresholdMethod = mbClass.getDeclaredMethod("setUsageThreshold", new Class[] { long.class }); //$NON-NLS-1$
|
Method setThresholdMethod = mbClass.getDeclaredMethod("setUsageThreshold", new Class[] { long.class }); //$NON-NLS-1$
|
||||||
Object[] args = new Object[1];
|
Object[] args = new Object[1];
|
||||||
args[0] = new Long((long)(maxObj.longValue() * threshold));
|
args[0] = new Long((long)(maxObj.longValue() * threshold));
|
||||||
|
|
||||||
|
setThresholdMethod.setAccessible(true);
|
||||||
setThresholdMethod.invoke(mbObj, args);
|
setThresholdMethod.invoke(mbObj, args);
|
||||||
mbean = mbObj;
|
mbean = mbObj;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Reference in a new issue