[java] Fix #5283 - inner class has public private modifiers #5310
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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, andprivate
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?
./mvnw clean verify
passes (checked automatically by github actions)