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

[java] Fix #5283 - inner class has public private modifiers #5310

Merged
merged 2 commits into from
Nov 22, 2024

Conversation

oowekyala
Copy link
Member

@oowekyala oowekyala commented Nov 4, 2024

Describe the PR

To summarize, the problem is that the scala 2.12 compiler emits an inner class with modifier public in its class file, and private in the InnerClasses structure of its outer class. This is still conformant to JVM spec as the InnerClasses structure is only there as metadata for the compiler, but isn't used by the VM at runtime, or verified. It is also a pattern that the javac compiler emits for eg protected inner classes.

This PR fixes the modifier cleanup behavior to avoid having both public and private modifiers in the JClassSymbol.

Note that at least since version 3.5, scalac does not emit bytecode with this structure for private inner classes of interfaces. It emits a public modifier in both the class file and the InnerClasses structure.

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)

@pmd-test
Copy link

pmd-test commented Nov 4, 2024

1 Message
📖 Compared to main:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
Download full report as build artifact
Compared to main:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
Download full report as build artifact

Generated by 🚫 Danger

@oowekyala oowekyala force-pushed the issue5283-public-private branch from 8be7658 to 97ac566 Compare November 18, 2024 10:10
@oowekyala oowekyala marked this pull request as ready for review November 18, 2024 10:17
@oowekyala oowekyala added this to the 7.8.0 milestone Nov 18, 2024
Copy link
Member

@adangel adangel left a comment

Choose a reason for hiding this comment

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

Thanks!

@adangel adangel merged commit 97ac566 into pmd:main Nov 22, 2024
3 checks passed
adangel added a commit that referenced this pull request Nov 22, 2024
adangel added a commit that referenced this pull request Nov 22, 2024
Merge pull request #5310 from oowekyala:issue5283-public-private
@oowekyala oowekyala deleted the issue5283-public-private branch November 22, 2024 10:25
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.

[java] AssertionError "this should be unreachable" with scala library
3 participants