-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
Conversation
👋 Welcome back mcpowers! A progress list of the required criteria for merging this PR into |
Webrevs
|
@@ -127,7 +127,7 @@ public final class PrivateCredentialPermission extends Permission { | |||
/** | |||
* @serial | |||
*/ | |||
private boolean testing = false; | |||
private final boolean testing = false; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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".
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
There was a problem hiding this comment.
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(). |
There was a problem hiding this comment.
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 ..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay.
There was a problem hiding this 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.*; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
@mcpowers this pull request can not be integrated into 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 |
@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:
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
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Thanks Sean and Brad for the review! |
/integrate |
/sponsor |
Going to push as commit 08274e6.
Your commit was automatically rebased without conflicts. |
@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. |
https://bugs.openjdk.org/browse/JDK-8290975
Progress
Issue
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