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

8283700: Add final or sealed modifier to appropriate java.awt API classes #7998

Closed
wants to merge 1 commit into from

Conversation

prrace
Copy link
Contributor

@prrace prrace commented Mar 28, 2022

JDK 17 delivered JEP 409: Sealed Classes : https://openjdk.java.net/jeps/409
In essence this JEP allows a class to limit which classes can subclass it.
If a class has no subclasses and cannot be subclassed outside the JDK it can also be made final.
Suitable classes across the JDK are being retro-fitted to be sealed (or made final) where it can be done compatibly.
This fix takes care of several AWT classes which were identified.
If later we need to remove sealed or make a class non-final that will also be a compatible change,
so we aren't locking ourselves into this.

All our automated regression tests - plus JCK tests have been run.

This will require a CSR


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed
  • Change requires a CSR request to be approved

Issues

  • JDK-8283700: Add final or sealed modifier to appropriate java.awt API classes
  • JDK-8283813: Add final or sealed modifier to appropriate java.awt API classes (CSR)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/7998/head:pull/7998
$ git checkout pull/7998

Update a local copy of the PR:
$ git checkout pull/7998
$ git pull https://git.openjdk.java.net/jdk pull/7998/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 7998

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/7998.diff

@prrace
Copy link
Contributor Author

prrace commented Mar 28, 2022

/csr

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 28, 2022

👋 Welcome back prr! 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 rfr Pull request is ready for review csr Pull request needs approved CSR before integration labels Mar 28, 2022
@openjdk
Copy link

openjdk bot commented Mar 28, 2022

@prrace has indicated that a compatibility and specification (CSR) request is needed for this pull request.
@prrace please create a CSR request for issue JDK-8283700. This pull request cannot be integrated until the CSR request is approved.

@openjdk
Copy link

openjdk bot commented Mar 28, 2022

@prrace 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 Mar 28, 2022
@mlbridge
Copy link

mlbridge bot commented Mar 28, 2022

Webrevs

@mrserb
Copy link
Member

mrserb commented Mar 28, 2022

I wonder do we have some javac checks which may show some warnings related to these updated classes like not all subclasses are covered by the switch/unnecessary default branch/etc?

@forax
Copy link
Member

forax commented Mar 28, 2022

@mrserb, you mean to detect that you can not add a new subclass without breaking the source backward compatibility.
You can add a test that switch over all the cases with no "default", if a new subclass is added, the test will not compile anymore.

@prrace
Copy link
Contributor Author

prrace commented Mar 29, 2022

I think Sergey is asking how javac identifies classes that are sub-classing the sealed class but not listed in the permits clause ?

@jddarcy
Copy link
Member

jddarcy commented Mar 29, 2022

I think Sergey is asking how javac identifies classes that are sub-classing the sealed class but not listed in the permits clause ?

If a sealed class does not have a permits clause, the allowed subclasses must be in the same file as the class in question, e.g. nested classes that were also subclasses or auxiliary classes. This is described in the JEP.

@mrserb
Copy link
Member

mrserb commented Mar 29, 2022

Thank you for clarification

@prrace
Copy link
Contributor Author

prrace commented Mar 29, 2022

The CSR is now ready for review : https://bugs.openjdk.java.net/browse/JDK-8283813

Copy link
Contributor

@prsadhuk prsadhuk left a comment

Choose a reason for hiding this comment

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

Suitable classes across the JDK are being retro-fitted to be sealed

How does this "suitability" check done? Are these exhaustive or more awt classes will be added?
Do we need to do the same for swing classes too?

@jddarcy
Copy link
Member

jddarcy commented Mar 29, 2022

Suitable classes across the JDK are being retro-fitted to be sealed

How does this "suitability" check done? Are these exhaustive or more awt classes will be added? Do we need to do the same for swing classes too?

I wrote an annotation processor to look for candidates to make sealed (public classes with no public or protected constructors and at least one package access constructor). Phil has filed bugs for swing (JDK-8283706) and other client areas.

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

openjdk bot commented Mar 30, 2022

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

8283700: Add final or sealed modifier to appropriate java.awt API classes

Reviewed-by: darcy, aivanov, serb, psadhukhan

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

  • d066856: 8282162: [vector] Optimize integral vector negation API
  • bfd9c2b: 8283015: Create a test for JDK-4715496
  • 8cdabea: 8207025: JvmtiEnv::SetSystemProperty() does not handle OOM
  • 272d653: 8283889: Fix Typo in open/src/java.sql/share/classes/java/sql/package-info.java
  • a9a9b90: 8283723: Update Visual Studio 2022 to version 17.1.0 for Oracle builds on Windows
  • 489b27d: 8282776: Bad NullPointerException message when invoking an interface MethodHandle on a null receiver
  • 072f2c4: 8283782: Redundant verification of year in LocalDate::ofEpochDay
  • 2fef5d4: 8281853: serviceability/sa/ClhsdbThreadContext.java failed with NullPointerException: Cannot invoke "sun.jvm.hotspot.gc.shared.GenCollectedHeap.getGen(int)" because "this.heap" is null
  • f9f439a: 8283717: vmTestbase/nsk/jdi/ThreadStartEvent/thread/thread001 failed due to SocketTimeoutException
  • 9591306: 8283772: Make sun.net.dns.ResolverConfiguration sealed
  • ... and 26 more: https://git.openjdk.java.net/jdk/compare/c2c0cb2a4372d78658326461562363de9a1a194f...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 Mar 30, 2022
@prrace
Copy link
Contributor Author

prrace commented Mar 30, 2022

/integrate

@openjdk
Copy link

openjdk bot commented Mar 30, 2022

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

  • ec9ab55: 8282374: Java_sun_awt_X11_XlibWrapper_XSynchronize is wrong and unused
  • a625bfd: 8283903: GetContainerCpuLoad does not return the correct result in share mode
  • 97c7298: 8282046: Create a regression test for JDK-8000326
  • ae57258: 8283715: Update ObjectStreamClass to be final
  • d9d19e9: 8284015: ProblemList containers/docker/TestJcmd.java on linux-x64
  • a3223cb: 8283999: Update JMH devkit to 1.35
  • e8e9b8d: 8282926: AArch64: Optimize out WHILELO with PTRUE
  • 720e751: 8283937: riscv: RVC: Fix c_beqz to c_bnez
  • 51c05e8: 8282764: AArch64: compiler/vectorapi/reshape/TestVectorCastNeon.java failed with incorrect result
  • b82b009: 8283737: riscv: MacroAssembler::stop() should emit fixed-length instruction sequence
  • ... and 43 more: https://git.openjdk.java.net/jdk/compare/c2c0cb2a4372d78658326461562363de9a1a194f...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Mar 30, 2022

@prrace Pushed as commit e85fa2f.

💡 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
Development

Successfully merging this pull request may close these issues.

6 participants