public void setCollectionUsageThreshold(long threshold) { if (!isCollectionUsageThresholdSupported()) { //lm.13=VM does not support collection usage threshold. throw new UnsupportedOperationException(Messages.getString("lm.13")); //$NON-NLS-1$ } SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkPermission(new ManagementPermission("control")); } if (threshold < 0) { //lm.15=Collection usage threshold cannot be negative. throw new IllegalArgumentException(Messages.getString("lm.15")); //$NON-NLS-1$ } if (exceedsMaxPoolSize(threshold)) { //lm.16=Collection usage threshold cannot exceed maximum amount of memory for pool. throw new IllegalArgumentException(Messages.getString("lm.16")); //$NON-NLS-1$ } this.setCollectionUsageThresholdImpl(threshold); }
public void setUsageThreshold(long threshold) { if (!isUsageThresholdSupported()) { //lm.13=VM does not support collection usage threshold. throw new UnsupportedOperationException(Messages.getString("lm.13")); } SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkPermission(new ManagementPermission("control")); } if (threshold < 0) { //lm.15=Collection usage threshold cannot be negative. throw new IllegalArgumentException(Messages.getString("lm.15")); //$NON-NLS-1$ } if (exceedsMaxPoolSize(threshold)) { //lm.16=Collection usage threshold cannot exceed maximum amount of memory for pool. throw new IllegalArgumentException(Messages.getString("lm.16")); //$NON-NLS-1$ } this.setUsageThresholdImpl(threshold); }
public String getBootClassPath() { if (!isBootClassPathSupported()) { //lm.1A=VM does not support boot classpath throw new UnsupportedOperationException(Messages.getString("lm.1A")); //$NON-NLS-1$ } SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkPermission(new ManagementPermission("monitor")); } return AccessController.doPrivileged(new PrivilegedAction<String>() { public String run() { return System.getProperty("sun.boot.class.path"); }// end method run }); }
public ThreadInfo[] getThreadInfo(long[] ids, int maxDepth) { SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkPermission(new ManagementPermission("monitor")); } // Validate inputs for (int i = 0; i < ids.length; i++) { if (ids[i] <= 0) { //lm.1B=Thread id must be greater than 0 throw new IllegalArgumentException(Messages.getString("lm.1B")); //$NON-NLS-1$ } } if (maxDepth < 0) { //lm.1D=maxDepth value cannot be negative. throw new IllegalArgumentException(Messages.getString("lm.1D")); //$NON-NLS-1$ } // Create an array and populate with individual ThreadInfos ThreadInfo[] tis = new ThreadInfo[ids.length]; for (int i = 0; i < ids.length; i++) { tis[i] = this.getThreadInfoImpl(ids[i], maxDepth); } return tis; }
public ThreadInfo getThreadInfo(long id, int maxDepth) { SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkPermission(new ManagementPermission("monitor")); } // Validate inputs if (id <= 0) { //lm.1B=Thread id must be greater than 0 throw new IllegalArgumentException(Messages.getString("lm.1B")); //$NON-NLS-1$ } if (maxDepth < 0) { //lm.1D=maxDepth value cannot be negative. throw new IllegalArgumentException(Messages.getString("lm.1D")); //$NON-NLS-1$ } return this.getThreadInfoImpl(id, maxDepth); }
public void setCollectionUsageThreshold(long threshold) { if (!isCollectionUsageThresholdSupported()) { throw new UnsupportedOperationException( "VM does not support collection usage threshold."); } SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkPermission(new ManagementPermission("control")); } if (threshold < 0) { throw new IllegalArgumentException( "Collection usage threshold cannot be negative."); } if (exceedsMaxPoolSize(threshold)) { throw new IllegalArgumentException( "Collection usage threshold cannot exceed maximum amount of memory for pool."); } this.setCollectionUsageThresholdImpl(threshold); }
public void setUsageThreshold(long threshold) { if (!isUsageThresholdSupported()) { throw new UnsupportedOperationException( "VM does not support usage threshold."); } SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkPermission(new ManagementPermission("control")); } if (threshold < 0) { throw new IllegalArgumentException( "Usage threshold cannot be negative."); } if (exceedsMaxPoolSize(threshold)) { throw new IllegalArgumentException( "Usage threshold cannot exceed maximum amount of memory for pool."); } this.setUsageThresholdImpl(threshold); }
public String getBootClassPath() { if (!isBootClassPathSupported()) { throw new UnsupportedOperationException( "VM does not support boot classpath."); } SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkPermission(new ManagementPermission("monitor")); } return AccessController.doPrivileged(new PrivilegedAction<String>() { public String run() { return System.getProperty("sun.boot.class.path"); }// end method run }); }
public ThreadInfo[] getThreadInfo(long[] ids, int maxDepth) { SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkPermission(new ManagementPermission("monitor")); } // Validate inputs for (int i = 0; i < ids.length; i++) { if (ids[i] <= 0) { throw new IllegalArgumentException( "Thread id must be greater than 0."); } } if (maxDepth < 0) { throw new IllegalArgumentException( "maxDepth value cannot be negative."); } // Create an array and populate with individual ThreadInfos ThreadInfo[] tis = new ThreadInfo[ids.length]; for (int i = 0; i < ids.length; i++) { tis[i] = this.getThreadInfoImpl(ids[i], maxDepth); } return tis; }
public ThreadInfo getThreadInfo(long id, int maxDepth) { SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkPermission(new ManagementPermission("monitor")); } // Validate inputs if (id <= 0) { throw new IllegalArgumentException( "Thread id must be greater than 0."); } if (maxDepth < 0) { throw new IllegalArgumentException( "maxDepth value cannot be negative."); } return this.getThreadInfoImpl(id, maxDepth); }
/** * If JVM security manager exists then checks JVM security 'control' permission. */ public static void checkSecurity() { SecurityManager securityManager = System.getSecurityManager(); if (securityManager != null) { securityManager.checkPermission(new ManagementPermission(PERMISSION_NAME_CONTROL)); } }
public static JvmInfo jvmInfo() { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new ManagementPermission("monitor")); sm.checkPropertyAccess("*"); } return INSTANCE; }
protected boolean checkManagementPermission(ManagementPermission perm) { String name = perm.getName(); if (name.equals("monitor")) { return true; } /* * "control" sounds bit risky */ return false; }
public void resetPeakUsage() { SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkPermission(new ManagementPermission("control")); } this.resetPeakUsageImpl(); }
public void setVerbose(boolean value) { SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkPermission(new ManagementPermission("control")); } this.setVerboseImpl(value); }
public List<String> getInputArguments() { SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkPermission(new ManagementPermission("monitor")); } // TODO : Retrieve the input args from the VM return new ArrayList<String>(); }
public long[] findMonitorDeadlockedThreads() { SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkPermission(new ManagementPermission("monitor")); } return this.findMonitorDeadlockedThreadsImpl(); }
public long[] getAllThreadIds() { SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkPermission(new ManagementPermission("monitor")); } return this.getAllThreadIdsImpl(); }
public void resetPeakThreadCount() { SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkPermission(new ManagementPermission("control")); } this.resetPeakThreadCountImpl(); }
public void setThreadContentionMonitoringEnabled(boolean enable) { if (!isThreadContentionMonitoringSupported()) { //lm.1E=Thread contention monitoring is not supported on this virtual machine. throw new UnsupportedOperationException(Messages.getString("lm.1E")); //$NON-NLS-1$ } SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkPermission(new ManagementPermission("control")); } this.setThreadContentionMonitoringEnabledImpl(enable); }
public void setThreadCpuTimeEnabled(boolean enable) { if (!isThreadCpuTimeSupported()) { //lm.01=Thread CPU timing is not supported on this virtual machine. throw new UnsupportedOperationException(Messages.getString("lm.01")); //$NON-NLS-1$ } SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkPermission(new ManagementPermission("control")); } this.setThreadCpuTimeEnabledImpl(enable); }
public void testManagementPermissionString() { ManagementPermission control = new ManagementPermission("control"); assertEquals("control", control.getName()); ManagementPermission monitor = new ManagementPermission("monitor"); assertEquals("monitor", monitor.getName()); try { new ManagementPermission("invalid"); fail(); } catch (IllegalArgumentException e) { } }
public void testImplies() { ManagementPermission mp1 = new ManagementPermission("monitor"); ManagementPermission mp2 = new ManagementPermission("control"); ManagementPermission mp3 = new ManagementPermission("monitor", ""); assertTrue(mp1.implies(mp1)); assertTrue(mp1.implies(mp3)); assertFalse(mp1.implies(mp2)); assertFalse(mp2.implies(mp1)); }
public void setThreadContentionMonitoringEnabled(boolean enable) { if (!isThreadContentionMonitoringSupported()) { throw new UnsupportedOperationException( "Thread contention monitoring is not supported on this virtual machine."); } SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkPermission(new ManagementPermission("control")); } this.setThreadContentionMonitoringEnabledImpl(enable); }
public void setThreadCpuTimeEnabled(boolean enable) { if (!isThreadCpuTimeSupported()) { throw new UnsupportedOperationException( "Thread CPU timing is not supported on this virtual machine."); } SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkPermission(new ManagementPermission("control")); } this.setThreadCpuTimeEnabledImpl(enable); }