@@ -1265,6 +1265,9 @@ static void checkTmpDir() {
1265
1265
1266
1266
/*[IF JAVA_SPEC_VERSION >= 9]*/
1267
1267
static void initSecurityManager (ClassLoader applicationClassLoader ) {
1268
+ /*[IF JAVA_SPEC_VERSION >= 24]*/
1269
+ boolean throwErrorOnInit = false ;
1270
+ /*[ENDIF] JAVA_SPEC_VERSION >= 24 */
1268
1271
String javaSecurityManager = internalGetProperties ().getProperty ("java.security.manager" ); //$NON-NLS-1$
1269
1272
if (null == javaSecurityManager ) {
1270
1273
/*[IF JAVA_SPEC_VERSION >= 18]*/
@@ -1273,14 +1276,21 @@ static void initSecurityManager(ClassLoader applicationClassLoader) {
1273
1276
/* Do nothing. */
1274
1277
/*[ENDIF] JAVA_SPEC_VERSION >= 18 */
1275
1278
} else if ("allow" .equals (javaSecurityManager )) { //$NON-NLS-1$
1279
+ /*[IF JAVA_SPEC_VERSION >= 24]*/
1280
+ throwErrorOnInit = true ;
1281
+ /*[ELSE] JAVA_SPEC_VERSION >= 24 */
1276
1282
/* Do nothing. */
1283
+ /*[ENDIF] JAVA_SPEC_VERSION >= 24 */
1277
1284
} else if ("disallow" .equals (javaSecurityManager )) { //$NON-NLS-1$
1278
1285
/*[IF JAVA_SPEC_VERSION > 11]*/
1279
1286
throwUOEFromSetSM = true ;
1280
1287
/*[ELSE] JAVA_SPEC_VERSION > 11 */
1281
1288
/* Do nothing. */
1282
1289
/*[ENDIF] JAVA_SPEC_VERSION > 11 */
1283
1290
} else {
1291
+ /*[IF JAVA_SPEC_VERSION >= 24]*/
1292
+ throwErrorOnInit = true ;
1293
+ /*[ELSE] JAVA_SPEC_VERSION >= 24 */
1284
1294
/*[IF JAVA_SPEC_VERSION >= 17]*/
1285
1295
initialErr .println ("WARNING: A command line option has enabled the Security Manager" ); //$NON-NLS-1$
1286
1296
initialErr .println ("WARNING: The Security Manager is deprecated and will be removed in a future release" ); //$NON-NLS-1$
@@ -1297,7 +1307,14 @@ static void initSecurityManager(ClassLoader applicationClassLoader) {
1297
1307
throw new Error (Msg .getString ("K0631" , e .toString ()), e ); //$NON-NLS-1$
1298
1308
}
1299
1309
}
1310
+ /*[ENDIF] JAVA_SPEC_VERSION >= 24 */
1300
1311
}
1312
+ /*[IF JAVA_SPEC_VERSION >= 24]*/
1313
+ if (throwErrorOnInit ) {
1314
+ /*[MSG "K0B04", "A command line option has attempted to allow or enable the Security Manager. Enabling a Security Manager is not supported."]*/
1315
+ throw new Error (Msg .getString ("K0B04" )); //$NON-NLS-1$
1316
+ }
1317
+ /*[ENDIF] JAVA_SPEC_VERSION >= 24 */
1301
1318
}
1302
1319
/*[ENDIF] JAVA_SPEC_VERSION >= 9 */
1303
1320
@@ -1315,17 +1332,25 @@ static boolean allowSecurityManager() {
1315
1332
*
1316
1333
* @param s the new security manager
1317
1334
*
1335
+ /*[IF JAVA_SPEC_VERSION >= 24]
1336
+ * @throws UnsupportedOperationException always
1337
+ /*[ELSE] JAVA_SPEC_VERSION >= 24
1318
1338
* @throws SecurityException if the security manager has already been set and its checkPermission method doesn't allow it to be replaced.
1319
1339
/*[IF JAVA_SPEC_VERSION > 11]
1320
1340
* @throws UnsupportedOperationException if s is non-null and a special token "disallow" has been set for system property "java.security.manager"
1321
1341
* which indicates that a security manager is not allowed to be set dynamically.
1322
1342
/*[ENDIF] JAVA_SPEC_VERSION > 11
1343
+ /*[ENDIF] JAVA_SPEC_VERSION >= 24
1323
1344
*/
1324
1345
/*[IF JAVA_SPEC_VERSION >= 17]*/
1325
1346
@ Deprecated (since ="17" , forRemoval =true )
1326
1347
@ CallerSensitive
1327
1348
/*[ENDIF] JAVA_SPEC_VERSION >= 17 */
1328
1349
public static void setSecurityManager (final SecurityManager s ) {
1350
+ /*[IF JAVA_SPEC_VERSION >= 24]*/
1351
+ /*[MSG "K0B03", "Setting a Security Manager is not supported"]*/
1352
+ throw new UnsupportedOperationException (Msg .getString ("K0B03" )); //$NON-NLS-1$
1353
+ /*[ELSE] JAVA_SPEC_VERSION >= 24*/
1329
1354
/*[IF CRIU_SUPPORT]*/
1330
1355
if (openj9 .internal .criu .InternalCRIUSupport .isCRIUSupportEnabled ()) {
1331
1356
/*[MSG "K0B02", "Enabling a SecurityManager currently unsupported when -XX:+EnableCRIUSupport is specified"]*/
@@ -1403,6 +1428,7 @@ public Void run() {
1403
1428
currentSecurity .checkPermission (com .ibm .oti .util .RuntimePermissions .permissionSetSecurityManager );
1404
1429
}
1405
1430
security = s ;
1431
+ /*[ENDIF] JAVA_SPEC_VERSION >= 24*/
1406
1432
}
1407
1433
1408
1434
/**
0 commit comments