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

6201035: Document NPE for passing null insets to constructors and methods of several javax.swing.border.* classes #10740

Closed
wants to merge 7 commits into from

Conversation

prsadhuk
Copy link
Contributor

@prsadhuk prsadhuk commented Oct 18, 2022

The behavior of MatteBorder constructors taking Insets object as a parameter is undocumented. It would throw NPE if null object is passed to it, which should be documented in the spec.


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
  • Change requires a CSR request to be approved

Issues

  • JDK-6201035: Document NPE for passing null insets to constructors and methods of several javax.swing.border.* classes
  • JDK-8295454: Document NPE for passing null insets to constructors and methods of several javax.swing.border.* classes (CSR)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 10740

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

Using diff file

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

@openjdk openjdk bot added the csr Pull request needs approved CSR before integration label Oct 18, 2022
@bridgekeeper
Copy link

bridgekeeper bot commented Oct 18, 2022

👋 Welcome back psadhukhan! 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 openjdk bot added the rfr Pull request is ready for review label Oct 18, 2022
@openjdk
Copy link

openjdk bot commented Oct 18, 2022

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

  • client

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 client client-libs-dev@openjdk.org label Oct 18, 2022
@mlbridge
Copy link

mlbridge bot commented Oct 18, 2022

@mrserb
Copy link
Member

mrserb commented Oct 20, 2022

It seems the same issue exists in other methods, like getBorderInsets?

@prsadhuk
Copy link
Contributor Author

It seems the same issue exists in other methods, like getBorderInsets?

OK. javadoc updated for that method too

Copy link
Member

@aivanov-jdk aivanov-jdk left a comment

Choose a reason for hiding this comment

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

In addition to the comments in the code, could you please update the copyright year and remove Rectangle from imports in EmptyBorder?

@aivanov-jdk
Copy link
Member

Does it make sense to update the subject to “Document NPE for passing null insets” or a similar? It would carry more meaning. At this time, “underfined behavior” sounds frightening.

@prsadhuk prsadhuk changed the title 6201035: Undefined behavior of MatteBorder Ctors 6201035: Document NPE for passing null insets to constructors and methods of several Border classes Oct 31, 2022
@prsadhuk
Copy link
Contributor Author

Changed subject and added more border classes/methods

@prsadhuk prsadhuk changed the title 6201035: Document NPE for passing null insets to constructors and methods of several Border classes 6201035: Document NPE for passing null insets to constructors and methods of several javax.swing.border.* classes Oct 31, 2022
Copy link
Member

@aivanov-jdk aivanov-jdk left a comment

Choose a reason for hiding this comment

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

TitledBorder is to be updated as well.

I wonder why none of the classes uses {@inheritDoc} instead of copying the entire text without modification. And you don't want to use {@inheritDoc} either for the @throws clause without explaining why.

@@ -142,6 +142,8 @@ public void paintBorder(Component c, Graphics g, int x, int y, int width, int he
* Reinitialize the insets parameter with this Border's current Insets.
Copy link
Member

Choose a reason for hiding this comment

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

To be consistent with the superclass:

Suggested change
* Reinitialize the insets parameter with this Border's current Insets.
* Reinitializes the insets parameter with this Border's current Insets.

I guess the entire javadoc can be inherited with {@inheritdoc}, it adds nothing to the text in AbstractBorder.

@@ -137,6 +137,8 @@ public void paintBorder(Component c, Graphics g, int x, int y, int width, int he
* Reinitialize the insets parameter with this Border's current Insets.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* Reinitialize the insets parameter with this Border's current Insets.
* Reinitializes the insets parameter with this Border's current Insets.

The same: the verb at start of a javadoc is in third person singular.

@@ -85,6 +85,8 @@ public Insets getBorderInsets(Component c) {
* @param c the component for which this border insets value applies
* @param insets the object to be reinitialized
* @return the <code>insets</code> object
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* @return the <code>insets</code> object
* @return the {@code insets} object

It makes sense to replace <code> with {@code} as the throws clause uses the new syntax.

@@ -102,6 +104,8 @@ public void paintBorder(Component c, Graphics g, int x, int y, int width, int he
* Reinitialize the insets parameter with this Border's current Insets.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* Reinitialize the insets parameter with this Border's current Insets.
* Reinitializes the insets parameter with this Border's current Insets.

@@ -210,6 +210,8 @@ public void paintBorder(Component c, Graphics g, int x, int y, int width, int he
*
Copy link
Member

Choose a reason for hiding this comment

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

Also add “-s” ending to the verb in the line above.

@@ -174,6 +174,8 @@ public void paintBorder(Component c, Graphics g, int x, int y, int width, int he
*
Copy link
Member

Choose a reason for hiding this comment

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

Also add “-s” ending to the verb in the line above.

@@ -152,6 +152,8 @@ public void paintBorder(Component c, Graphics g, int x, int y, int width, int he
* Reinitialize the insets parameter with this Border's current Insets.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* Reinitialize the insets parameter with this Border's current Insets.
* Reinitializes the insets parameter with this Border's current Insets.

@aivanov-jdk
Copy link
Member

aivanov-jdk commented Nov 2, 2022

TitledBorder is to be updated as well.

/**
* Reinitialize the insets parameter with this Border's current Insets.
* @param c the component for which this border insets value applies
* @param insets the object to be reinitialized
*/
public Insets getBorderInsets(Component c, Insets insets) {

This hasn't been addressed yet. It requires the CSR to be updated.

@aivanov-jdk
Copy link
Member

Before I can approve this PR, I would like to see the javadoc for border classes (those that are modified) updated so that all of them use “Reinitializes” as the first word in the description instead of “Reinitialize”, which aligns with the javadoc style guide:

Use 3rd person (descriptive) not 2nd person (prescriptive).

The description is in 3rd person declarative rather than 2nd person imperative.

Gets the label. (preferred)

Get the label. (avoid)

@openjdk openjdk bot removed the csr Pull request needs approved CSR before integration label Nov 2, 2022
@openjdk
Copy link

openjdk bot commented Nov 2, 2022

@prsadhuk 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:

6201035: Document NPE for passing null insets to constructors and methods of several javax.swing.border.* classes

Reviewed-by: tr, prr, aivanov, serb

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 425 new commits pushed to the master branch:

  • 2f9a94f: 8296824: ProblemList compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/NativeCallTest.java
  • 43ebd96: 8296822: ProblemList jdk/jfr/api/consumer/TestRecordingFileWrite.java
  • 84e1224: 8296496: Overzealous check in sizecalc.h prevents large memory allocation
  • 27527b4: 8296612: CertAttrSet is useless
  • 6b456f7: 8262901: [macos_aarch64] NativeCallTest expected:<-3.8194101E18> but was:<3.02668882E10>
  • e1badb7: 8295871: G1: Use different explicit claim marks for CLDs
  • 9ef7852: 8290714: Make com.sun.jndi.dns.DnsClient virtual threads friendly
  • d6468be: 8293886: The abstract keyword can be removed in AESCipher
  • 54c986e: 8296715: CLDR v42 update for tzdata 2022f
  • 4a68210: 6972078: Can not select single directory with GTKLookAndFeel
  • ... and 415 more: https://git.openjdk.org/jdk/compare/7a194d31a3f2f78211f035f4591845bf2b465aec...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.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Nov 2, 2022
@aivanov-jdk
Copy link
Member

Before I can approve this PR, I would like to see the javadoc for border classes (those that are modified) updated so that all of them use “Reinitializes” as the first word in the description instead of “Reinitialize”, which aligns with the javadoc style guide:

Use 3rd person (descriptive) not 2nd person (prescriptive).
The description is in 3rd person declarative rather than 2nd person imperative.
Gets the label. (preferred)
Get the label. (avoid)

Per the comment in JBS, addressing this is deferred to a separate issue… However, I still think it would've been more efficient to handle it here. Anyway, it's approved now.

@prsadhuk
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Nov 23, 2022

Going to push as commit 412b436.
Since your change was applied there have been 617 commits pushed to the master branch:

  • faf48e6: 8296329: jar validator doesn't account for minor class file version
  • 09f70da: 8296265: Use modern HTML in the JVMTI spec
  • e661c5a: 8296323: JVMTI can_support_virtual_threads not available for agents loaded into running VM
  • 974cb83: 8297310: Remove unimplemented HeapInspection::iterate_over_heap
  • e174558: 8296742: Illegal X509 Extension should not be created
  • a6c418e: 8297168: Provide a bulk OopHandle release mechanism with the ServiceThread
  • 4a544bb: 8297091: New langtools test jdk/javadoc/doclet/testValueTag/TestValueFormats.java fails on machines with unexpected number format
  • b6dddf4: 8239801: [macos] java/awt/Focus/UnaccessibleChoice/AccessibleChoiceTest.java fails
  • 260e4dc: 8295011: EC point multiplication improvement for secp256r1
  • fb6c992: 8296957: One more cast in SAFE_SIZE_NEW_ARRAY2
  • ... and 607 more: https://git.openjdk.org/jdk/compare/7a194d31a3f2f78211f035f4591845bf2b465aec...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Nov 23, 2022
@openjdk openjdk bot closed this Nov 23, 2022
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Nov 23, 2022
@prsadhuk prsadhuk deleted the JDK-6201035 branch November 23, 2022 03:21
@openjdk
Copy link

openjdk bot commented Nov 23, 2022

@prsadhuk Pushed as commit 412b436.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client client-libs-dev@openjdk.org integrated Pull request has been integrated
5 participants