Skip to content

Commit 7c381e6

Browse files
committed
JDK24 remove System.getSecurityManager part 2
Signed-off-by: Theresa Mammarella <[email protected]>
1 parent 0232648 commit 7c381e6

File tree

16 files changed

+270
-73
lines changed

16 files changed

+270
-73
lines changed

jcl/src/java.management/share/classes/com/ibm/java/lang/management/internal/ManagementUtils.java

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -432,65 +432,6 @@ public static TabularData toSystemPropertiesTabularData(Map<String, String> prop
432432
return result;
433433
}
434434

435-
/**
436-
* Convenience method that sets out to return the {@link Class} object for
437-
* the specified type named <code>name</code>. Unlike the
438-
* {@link Class#forName(java.lang.String)} method, this will work even for
439-
* primitive types.
440-
*
441-
* @param name
442-
* the name of a Java type
443-
* @return the <code>Class</code> object for the type <code>name</code>
444-
* @throws ClassNotFoundException
445-
* if <code>name</code> does not correspond to any known type
446-
* (including primitive types).
447-
*/
448-
public static Class<?> getClassMaybePrimitive(String name) throws ClassNotFoundException {
449-
int i = name.lastIndexOf('.');
450-
451-
if (i != -1) {
452-
@SuppressWarnings("removal")
453-
SecurityManager sm = System.getSecurityManager();
454-
if (sm != null) {
455-
sm.checkPackageAccess(name.substring(0, i));
456-
}
457-
}
458-
459-
Class<?> result = null;
460-
461-
try {
462-
result = Class.forName(name);
463-
} catch (ClassNotFoundException e) {
464-
if (name.equals(boolean.class.getName())) {
465-
result = boolean.class;
466-
} else if (name.equals(char.class.getName())) {
467-
result = char.class;
468-
} else if (name.equals(byte.class.getName())) {
469-
result = byte.class;
470-
} else if (name.equals(short.class.getName())) {
471-
result = short.class;
472-
} else if (name.equals(int.class.getName())) {
473-
result = int.class;
474-
} else if (name.equals(long.class.getName())) {
475-
result = long.class;
476-
} else if (name.equals(float.class.getName())) {
477-
result = float.class;
478-
} else if (name.equals(double.class.getName())) {
479-
result = double.class;
480-
} else if (name.equals(void.class.getName())) {
481-
result = void.class;
482-
} else {
483-
if (ManagementUtils.VERBOSE_MODE) {
484-
e.printStackTrace(System.err);
485-
}
486-
// Rethrow the original ClassNotFoundException
487-
throw e;
488-
}
489-
}
490-
491-
return result;
492-
}
493-
494435
/**
495436
* Convenience method to determine if the <code>wrapper</code>
496437
* <code>Class</code>

jcl/src/java.management/share/classes/com/ibm/java/lang/management/internal/MemoryMXBeanImpl.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,11 +467,13 @@ public boolean isVerbose() {
467467
*/
468468
@Override
469469
public void setVerbose(boolean value) {
470+
/*[IF JAVA_SPEC_VERSION < 24]*/
470471
@SuppressWarnings("removal")
471472
SecurityManager security = System.getSecurityManager();
472473
if (security != null) {
473474
security.checkPermission(ManagementPermissionHelper.MPCONTROL);
474475
}
476+
/*[ENDIF] JAVA_SPEC_VERSION < 24 */
475477
this.setVerboseImpl(value);
476478
}
477479

@@ -526,11 +528,13 @@ public void setMaxHeapSize(long size) {
526528
if (size < this.getMinHeapSize() || size > this.getMaxHeapSizeLimit()) {
527529
throw new IllegalArgumentException();
528530
}
531+
/*[IF JAVA_SPEC_VERSION < 24]*/
529532
@SuppressWarnings("removal")
530533
SecurityManager security = System.getSecurityManager();
531534
if (security != null) {
532535
security.checkPermission(ManagementPermissionHelper.MPCONTROL);
533536
}
537+
/*[ENDIF] JAVA_SPEC_VERSION < 24 */
534538
this.setMaxHeapSizeImpl(size);
535539
}
536540

@@ -662,11 +666,13 @@ public boolean setSharedClassCacheSoftmxBytes(long value) {
662666
if (value < 0) {
663667
throw new IllegalArgumentException();
664668
}
669+
/*[IF JAVA_SPEC_VERSION < 24]*/
665670
@SuppressWarnings("removal")
666671
SecurityManager security = System.getSecurityManager();
667672
if (security != null) {
668673
security.checkPermission(ManagementPermissionHelper.MPCONTROL);
669674
}
675+
/*[ENDIF] JAVA_SPEC_VERSION < 24 */
670676
return this.setSharedClassCacheSoftmxBytesImpl(value);
671677
}
672678

@@ -677,11 +683,13 @@ public boolean setSharedClassCacheMinAotBytes(long value) {
677683
if (value < 0) {
678684
throw new IllegalArgumentException();
679685
}
686+
/*[IF JAVA_SPEC_VERSION < 24]*/
680687
@SuppressWarnings("removal")
681688
SecurityManager security = System.getSecurityManager();
682689
if (security != null) {
683690
security.checkPermission(ManagementPermissionHelper.MPCONTROL);
684691
}
692+
/*[ENDIF] JAVA_SPEC_VERSION < 24 */
685693
return this.setSharedClassCacheMinAotBytesImpl(value);
686694
}
687695

@@ -692,11 +700,13 @@ public boolean setSharedClassCacheMaxAotBytes(long value) {
692700
if (value < 0) {
693701
throw new IllegalArgumentException();
694702
}
703+
/*[IF JAVA_SPEC_VERSION < 24]*/
695704
@SuppressWarnings("removal")
696705
SecurityManager security = System.getSecurityManager();
697706
if (security != null) {
698707
security.checkPermission(ManagementPermissionHelper.MPCONTROL);
699708
}
709+
/*[ENDIF] JAVA_SPEC_VERSION < 24 */
700710
return this.setSharedClassCacheMaxAotBytesImpl(value);
701711
}
702712

@@ -707,11 +717,13 @@ public boolean setSharedClassCacheMinJitDataBytes(long value) {
707717
if (value < 0) {
708718
throw new IllegalArgumentException();
709719
}
720+
/*[IF JAVA_SPEC_VERSION < 24]*/
710721
@SuppressWarnings("removal")
711722
SecurityManager security = System.getSecurityManager();
712723
if (security != null) {
713724
security.checkPermission(ManagementPermissionHelper.MPCONTROL);
714725
}
726+
/*[ENDIF] JAVA_SPEC_VERSION < 24 */
715727
return this.setSharedClassCacheMinJitDataBytesImpl(value);
716728
}
717729

@@ -722,11 +734,13 @@ public boolean setSharedClassCacheMaxJitDataBytes(long value) {
722734
if (value < 0) {
723735
throw new IllegalArgumentException();
724736
}
737+
/*[IF JAVA_SPEC_VERSION < 24]*/
725738
@SuppressWarnings("removal")
726739
SecurityManager security = System.getSecurityManager();
727740
if (security != null) {
728741
security.checkPermission(ManagementPermissionHelper.MPCONTROL);
729742
}
743+
/*[ENDIF] JAVA_SPEC_VERSION < 24 */
730744
return this.setSharedClassCacheMaxJitDataBytesImpl(value);
731745
}
732746

jcl/src/java.management/share/classes/com/ibm/java/lang/management/internal/MemoryPoolMXBeanImpl.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,11 +360,13 @@ public boolean isValid() {
360360
*/
361361
@Override
362362
public void resetPeakUsage() {
363+
/*[IF JAVA_SPEC_VERSION < 24]*/
363364
@SuppressWarnings("removal")
364365
SecurityManager security = System.getSecurityManager();
365366
if (security != null) {
366367
security.checkPermission(ManagementPermissionHelper.MPCONTROL);
367368
}
369+
/*[ENDIF] JAVA_SPEC_VERSION < 24 */
368370
this.resetPeakUsageImpl(id);
369371
}
370372

@@ -386,11 +388,13 @@ public void setCollectionUsageThreshold(long threshold) {
386388
throw new UnsupportedOperationException(com.ibm.oti.util.Msg.getString("K05EE")); //$NON-NLS-1$
387389
}
388390

391+
/*[IF JAVA_SPEC_VERSION < 24]*/
389392
@SuppressWarnings("removal")
390393
SecurityManager security = System.getSecurityManager();
391394
if (security != null) {
392395
security.checkPermission(ManagementPermissionHelper.MPCONTROL);
393396
}
397+
/*[ENDIF] JAVA_SPEC_VERSION < 24 */
394398

395399
if (threshold < 0) {
396400
/*[MSG "K05FE", "Collection usage threshold cannot be negative."]*/
@@ -421,11 +425,13 @@ public void setUsageThreshold(long threshold) {
421425
throw new UnsupportedOperationException(com.ibm.oti.util.Msg.getString("K05EF")); //$NON-NLS-1$
422426
}
423427

428+
/*[IF JAVA_SPEC_VERSION < 24]*/
424429
@SuppressWarnings("removal")
425430
SecurityManager security = System.getSecurityManager();
426431
if (security != null) {
427432
security.checkPermission(ManagementPermissionHelper.MPCONTROL);
428433
}
434+
/*[ENDIF] JAVA_SPEC_VERSION < 24 */
429435

430436
if (threshold < 0) {
431437
/*[MSG "K05F0", "Usage threshold cannot be negative."]*/

jcl/src/java.management/share/classes/com/ibm/java/lang/management/internal/RuntimeMXBeanImpl.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ public final String getBootClassPath() {
7171
throw new UnsupportedOperationException(com.ibm.oti.util.Msg.getString("K05F5")); //$NON-NLS-1$
7272
}
7373

74+
/*[IF JAVA_SPEC_VERSION < 24]*/
7475
checkMonitorPermission();
76+
/*[ENDIF] JAVA_SPEC_VERSION < 24 */
7577
return VM.internalGetProperties().getProperty("sun.boot.class.path"); //$NON-NLS-1$
7678
}
7779

@@ -208,7 +210,9 @@ public final boolean isBootClassPathSupported() {
208210
*/
209211
@Override
210212
public final List<String> getInputArguments() {
213+
/*[IF JAVA_SPEC_VERSION < 24]*/
211214
checkMonitorPermission();
215+
/*[ENDIF] JAVA_SPEC_VERSION < 24 */
212216
return Collections.unmodifiableList(ManagementUtils.convertStringArrayToList(VM.getVMArgs()));
213217
}
214218

@@ -237,6 +241,7 @@ public final ObjectName getObjectName() {
237241
return objectName;
238242
}
239243

244+
/*[IF JAVA_SPEC_VERSION < 24]*/
240245
public static void checkMonitorPermission() {
241246
@SuppressWarnings("removal")
242247
SecurityManager security = System.getSecurityManager();
@@ -245,5 +250,6 @@ public static void checkMonitorPermission() {
245250
security.checkPermission(ManagementPermissionHelper.MPMONITOR);
246251
}
247252
}
253+
/*[ENDIF] JAVA_SPEC_VERSION < 24 */
248254

249255
}

0 commit comments

Comments
 (0)