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

JDK-8290975 Minor cleanup could be done in javax.security #9664

Closed
wants to merge 7 commits into from

Conversation

mcpowers
Copy link
Contributor

@mcpowers mcpowers commented Jul 27, 2022

https://bugs.openjdk.org/browse/JDK-8290975


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8290975: Minor cleanup could be done in javax.security

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/9664/head:pull/9664
$ git checkout pull/9664

Update a local copy of the PR:
$ git checkout pull/9664
$ git pull https://git.openjdk.org/jdk pull/9664/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 9664

View PR using the GUI difftool:
$ git pr show -t 9664

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/9664.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 27, 2022

👋 Welcome back mcpowers! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Jul 27, 2022

@mcpowers The following label will be automatically applied to this pull request:

  • security

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the security security-dev@openjdk.org label Jul 27, 2022
@mcpowers mcpowers marked this pull request as ready for review July 28, 2022 14:28
@openjdk openjdk bot added the rfr Pull request is ready for review label Jul 28, 2022
@mlbridge
Copy link

mlbridge bot commented Jul 28, 2022

Webrevs

@@ -127,7 +127,7 @@ public final class PrivateCredentialPermission extends Permission {
/**
* @serial
*/
private boolean testing = false;
private final boolean testing = false;
Copy link
Member

Choose a reason for hiding this comment

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

This should really use java.security.debug so this tracing can be enabled at runtime, but that's probably more of a separate fix - feel free to file a separate issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll file a bug later today and add to this bug report.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You must mean sun.security.util.Debug.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

JDK-8291974

@@ -25,22 +25,18 @@

package javax.security.auth;

import java.util.*;
import java.io.*;
import sun.security.util.ResourcesMgr;
Copy link
Member

Choose a reason for hiding this comment

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

I suggest putting the internal imports below the java.* or other standard imports. This isn't a rule, but is more consistent with other code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IJ complains about unnecessary imports and asks If I want to let it automatically optimize them. I always answer "yes". I'll fix as you suggest.

Copy link
Contributor

Choose a reason for hiding this comment

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

The default setup wants to put the sun.* imports above the java.*. The default order is defined in "Import Layout":

all other imports
<blank line>
import javax.*
import java.*
<blank line>
import static all other imports

I have mine set to:

import java.*
import javax.*
<blank line>
all other imports
<blank line>
import static all other imports

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed my IJ defaults. Thanks for the suggestion.

@@ -855,7 +851,7 @@ public <T> Set<T> getPublicCredentials(Class<T> c) {
* {@code Class}.
*
* <p> If a security manager is installed, the caller must have a
* {@link PrivateCredentialPermission} to access all of the requested
* {@link PrivateCredentialPermission} to access all the requested
Copy link
Member

Choose a reason for hiding this comment

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

Hmm. I think the previous text was more correct/readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay. I'll revert the change. It was just an IJ suggestion.

@@ -42,7 +42,7 @@ public class NameCallback implements Callback, java.io.Serializable {
* @serial
* @since 1.4
*/
private String prompt;
private final String prompt;
Copy link
Member

Choose a reason for hiding this comment

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

I think you can also mark defaultName final.

Copy link
Contributor

Choose a reason for hiding this comment

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

First constructor doesn't set defaultName (or inputName), so there will be a error "might not have been initialized".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I verified the error message happens when defaultName is final.

Copy link
Member

Choose a reason for hiding this comment

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

Yes but defaultName (like prompt) should never change once the object is constructed. So it seems inconsistent not to also mark it final (and if necessary, set it to a default value (null) in the constructors).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. I'll make the change.

Copy link
Contributor

@bradfordwetmore bradfordwetmore Aug 5, 2022

Choose a reason for hiding this comment

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

That works also, as the API allows for these values to be set/reset to null. Can't do the same for inputName, as that can be set later.

@@ -43,7 +43,7 @@ public class TextInputCallback implements Callback, java.io.Serializable {
* @serial
* @since 1.4
*/
private String prompt;
private final String prompt;
Copy link
Member

Choose a reason for hiding this comment

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

I think you can also mark defaultText final.

Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.

Copy link
Member

Choose a reason for hiding this comment

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

Same comment as above about setting it to a default value in the constructors.

@@ -91,7 +91,7 @@ public final class X500Principal implements Principal, java.io.Serializable {
*
* NOTE: The constructor is package private. It is intended to be accessed
* using privileged reflection from classes in sun.security.*.
* Currently referenced from sun.security.x509.X500Name.asX500Principal().
* Currently, referenced from sun.security.x509.X500Name.asX500Principal().
Copy link
Member

Choose a reason for hiding this comment

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

Change to "Currently, it is referenced from ..."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay.

Copy link
Contributor

@bradfordwetmore bradfordwetmore left a comment

Choose a reason for hiding this comment

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

LMGTM, don't need to rereview, but would appreciate comments on the import style you used.

import java.security.PrivilegedExceptionAction;
import java.security.PrivilegedActionException;
import java.security.ProtectionDomain;
import java.util.*;
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the style convention you're trying to conform to here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm letting IJ optimize imports. I didn't see anything in the style guide.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I see it now. Ctrl+Alt+O. And you can configure from the Settings Import menu.

default:
sm.checkPermission(AuthPermissionHolder.MODIFY_PRIVATE_CREDENTIALS_PERMISSION);
break;
case Subject.PRINCIPAL_SET:
Copy link
Contributor

Choose a reason for hiding this comment

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

The original style guide convention has the switch and case at the same level.

https://www.oracle.com/technetwork/java/codeconventions-150003.pdf

Is this a reformat from IJ (Settings->Editor->Code Style->Java->Wrapping Braces->'switch statement'? IIRC, this is one setting where the default value isn't what we used to do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed my IJ settings: switch and case now at same level.

@@ -42,7 +42,7 @@ public class NameCallback implements Callback, java.io.Serializable {
* @serial
* @since 1.4
*/
private String prompt;
private final String prompt;
Copy link
Contributor

Choose a reason for hiding this comment

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

First constructor doesn't set defaultName (or inputName), so there will be a error "might not have been initialized".

@@ -43,7 +43,7 @@ public class TextInputCallback implements Callback, java.io.Serializable {
* @serial
* @since 1.4
*/
private String prompt;
private final String prompt;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.

import javax.security.auth.AuthPermission;
import javax.security.auth.callback.*;
import javax.security.auth.login.*;
import javax.security.auth.callback.CallbackHandler;
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity, did IJ point this out somehow?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. IJ complained about unused imports and offered to optimize them for me.

Copy link
Contributor

@bradfordwetmore bradfordwetmore Aug 4, 2022

Choose a reason for hiding this comment

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

Ah, so this is how it asked if you wanted to optimize. I could only find the Code-> menu.

@openjdk
Copy link

openjdk bot commented Aug 4, 2022

@mcpowers this pull request can not be integrated into master due to one or more merge conflicts. To resolve these merge conflicts and update this pull request you can run the following commands in the local repository for your personal fork:

git checkout JDK-8290975
git fetch https://git.openjdk.org/jdk master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push

@openjdk openjdk bot added the merge-conflict Pull request has merge conflict with target branch label Aug 4, 2022
@openjdk
Copy link

openjdk bot commented Aug 5, 2022

@mcpowers This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8290975: Minor cleanup could be done in javax.security

Reviewed-by: wetmore, mullan

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 43 new commits pushed to the master branch:

  • 7db5abd: 8282642: vmTestbase/gc/gctests/LoadUnloadGC2/LoadUnloadGC2.java fails intermittently with exit code 1
  • 124fc4a: 8290180: Convert com/sun/management/UnixOperatingSystemMXBean/GetOpenFileDescriptorCount.sh to jtreg java version
  • 4591937: 8290357: Drop HeapRegion::marked_bytes()
  • 7676be8: 8291037: Move PLAB resizing mechanism to G1EvacStats
  • 861cc67: 8291897: TerminatingThreadLocal(s) not registered from virtual thread(s)
  • 8d88be2: 8291459: JVM crash with GenerateOopMap::error_work(char const*, __va_list_tag*)
  • 8a804f6: 8291454: Missing check for JLI C runtime library in CoreLibraries.gmk
  • 5a539e8: 8291893: riscv: remove fence.i used in user space
  • b2f0cbd: 8064787: [macosx] In Nimbus LaF, Ctrl+Alt mnemonic doesn't work
  • 891df21: 8259687: JTabbedPane.setComponentAt doesn't hide previously visible tab component
  • ... and 33 more: https://git.openjdk.org/jdk/compare/aa557b9b01571d7614f54d341c5cd8bf36cdacee...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@bradfordwetmore, @seanjmullan) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added ready Pull request is ready to be integrated and removed merge-conflict Pull request has merge conflict with target branch labels Aug 5, 2022
Copy link
Contributor

@bradfordwetmore bradfordwetmore left a comment

Choose a reason for hiding this comment

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

LGTM.

@mcpowers
Copy link
Contributor Author

mcpowers commented Aug 5, 2022

Thanks Sean and Brad for the review!

@mcpowers
Copy link
Contributor Author

mcpowers commented Aug 8, 2022

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Aug 8, 2022
@openjdk
Copy link

openjdk bot commented Aug 8, 2022

@mcpowers
Your change (at version 2135525) is now ready to be sponsored by a Committer.

@bradfordwetmore
Copy link
Contributor

/sponsor

@openjdk
Copy link

openjdk bot commented Aug 8, 2022

Going to push as commit 08274e6.
Since your change was applied there have been 43 commits pushed to the master branch:

  • 7db5abd: 8282642: vmTestbase/gc/gctests/LoadUnloadGC2/LoadUnloadGC2.java fails intermittently with exit code 1
  • 124fc4a: 8290180: Convert com/sun/management/UnixOperatingSystemMXBean/GetOpenFileDescriptorCount.sh to jtreg java version
  • 4591937: 8290357: Drop HeapRegion::marked_bytes()
  • 7676be8: 8291037: Move PLAB resizing mechanism to G1EvacStats
  • 861cc67: 8291897: TerminatingThreadLocal(s) not registered from virtual thread(s)
  • 8d88be2: 8291459: JVM crash with GenerateOopMap::error_work(char const*, __va_list_tag*)
  • 8a804f6: 8291454: Missing check for JLI C runtime library in CoreLibraries.gmk
  • 5a539e8: 8291893: riscv: remove fence.i used in user space
  • b2f0cbd: 8064787: [macosx] In Nimbus LaF, Ctrl+Alt mnemonic doesn't work
  • 891df21: 8259687: JTabbedPane.setComponentAt doesn't hide previously visible tab component
  • ... and 33 more: https://git.openjdk.org/jdk/compare/aa557b9b01571d7614f54d341c5cd8bf36cdacee...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Aug 8, 2022
@openjdk openjdk bot closed this Aug 8, 2022
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Aug 8, 2022
@openjdk
Copy link

openjdk bot commented Aug 8, 2022

@bradfordwetmore @mcpowers Pushed as commit 08274e6.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@mcpowers mcpowers deleted the JDK-8290975 branch August 22, 2022 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated security security-dev@openjdk.org
Development

Successfully merging this pull request may close these issues.

3 participants