Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JDK12 setSecurityManager according to java.security.manager special tokens #4738

Merged
merged 1 commit into from
Feb 14, 2019

Conversation

JasonFengJ9
Copy link
Member

JDK12 setSecurityManager() according to system property java.security.manager special tokens

JDK12 throws UnsupportedOperationException when the system property java.security.manager is set to special token disallow during startup via command line options;
In addition, special token allow permits setSecurityManager dynamically instead of an actual SecurityManager implementation class name;
Replaced deprecated (since Java9) Class.newInstance() with Class.getDeclaredConstructor().newInstance() (not other occurrences, maybe another PR) ;
Minor javadoc updates.

Note: JDK8 and JDK11 don't support these special tokens allow and disallow.

Manually verified behaviors matching RI.
Expected JTReg tests to provide test coverage such as following.
https://github.com/ibmruntimes/openj9-openjdk-jdk12/blob/e969f57ff8031485b00ccf2ed10f87a627c7bd68/test/jdk/java/lang/System/AllowSecurityManager.java#L24-L32

Fixes: #4734

Reviewer: @pshipton
FYI: @DanHeidinga

Signed-off-by: Jason Feng fengj@ca.ibm.com

@@ -1305,3 +1305,6 @@ K0900="Create a new Reference, since a Reference cannot be cloned."
#java.lang.invoke.MethodHandle
K0A00="Failed to resolve Constant Dynamic entry with j9class: {0}, name: {1}, descriptor: {2}, bsmData: {3}"
K0A01="Constant_Dynamic references bootstrap method '{0}' does not have java.lang.invoke.MethodHandles.Lookup as first parameter."

#java.lang.System
K0B00="Runtime is specified to disallow setting security manager"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be more explicit. i.e. -Djava.security.manager=disallow has been specified

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the message.

if (javaSecurityManager.isEmpty() || "default".equals(javaSecurityManager)) {
if ((javaSecurityManager != null)
/*[IF Java12]*/
&& !javaSecurityManager.equals("disallow") //$NON-NLS-1$ /* special token to disallow SecurityManager */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment to refer to the SecurityManager javadoc.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JDK 12 doc is still an early access, added a comment More details are at JDK 12 javadoc jdk12/docs/api/java.base/java/lang/SecurityManager.html instead.

Please have another look.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't mean to include a direct link. In fact, I don't think the path is desired either. I'm fine with a comment at says "See the SecurityManager javadoc for details."

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, the comment is updated.

java.security.manager special tokens

JDK12 throws UnsupportedOperationException when the system property
java.security.manager is set to special token disallow during startup
via command line options;
In addition, special token allow permits setSecurityManager dynamically
instead of an actual SecurityManager implementation class name;
Replaced deprecated (since Java9) Class.newInstance() with
Class.getDeclaredConstructor().newInstance() (not other occurrences,
maybe another PR) ;
Minor javadoc updates.

Note: JDK8 and JDK11 don't support these special tokens allow and
disallow.

Signed-off-by: Jason Feng <fengj@ca.ibm.com>
@pshipton
Copy link
Member

jenkins test sanity zlinux jdk11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants