Skip to content

[java] Update rule DontImportSun#3391

Merged
adangel merged 1 commit into
pmd:pmd/7.0.xfrom
oowekyala:update-DontImportSun
Jul 16, 2021
Merged

[java] Update rule DontImportSun#3391
adangel merged 1 commit into
pmd:pmd/7.0.xfrom
oowekyala:update-DontImportSun

Conversation

@oowekyala

Copy link
Copy Markdown
Member

Describe the PR

sun.misc.Signal is not ignored anymore. This struck me as very peculiar, since there's nothing special about Signal that makes it less unstable than eg sun.misc.Unsafe... The way I see it, the goal of the rule is not to forbid using Unsafe or Signal or whatever, but to avoid doing it everywhere, and to confine those dependencies to small scopes, in which the rule can be suppressed. This applies to Signal as well and it weakens the rule to make an exception for it.

Related issues

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by github actions)
  • Added (in-code) documentation (if needed)

Do not special case sun.misc.Signal anymore
@ghost

ghost commented Jul 11, 2021

Copy link
Copy Markdown
2 Messages
📖 Compared to pmd/7.0.x:
This changeset changes 0 violations,
introduces 1727 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
Full report
📖 Compared to master:
This changeset changes 30191 violations,
introduces 32705 new violations, 3 new errors and 0 new configuration errors,
removes 23643 violations, 8 errors and 3 configuration errors.
Full report

Generated by 🚫 Danger

@adangel

adangel commented Jul 16, 2021

Copy link
Copy Markdown
Member

sun.misc.Signal is not ignored anymore. This struck me as very peculiar, since there's nothing special about Signal that makes it less unstable than eg sun.misc.Unsafe... The way I see it, the goal of the rule is not to forbid using Unsafe or Signal or whatever, but to avoid doing it everywhere, and to confine those dependencies to small scopes, in which the rule can be suppressed. This applies to Signal as well and it weakens the rule to make an exception for it.

Yes, it makes no sense to handle sun.misc.Signal any different. The problem with using those internal JDK classes is, that it won't work out of the box since java9+ and these classes will be probably hidden completely away with later versions - which means, your application is not compatible with java...

These classes were a big topic when Java 9 introduced the module system. You can still enable access to these classes I think, but they are not available by default anymore.

@adangel adangel merged commit 9ec7848 into pmd:pmd/7.0.x Jul 16, 2021
@oowekyala oowekyala deleted the update-DontImportSun branch July 16, 2021 10:08
@adangel adangel mentioned this pull request Jan 23, 2023
55 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants