-
Notifications
You must be signed in to change notification settings - Fork 65
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
Package access fixer fails for protected fields #92
Comments
This is a major pain to handle because it breaks in the verifier, not in the fundamental access rules. JVMS 4.10.1.8 demands " Otherwise, use of a member of an object of type Target requires that Target be assignable to the type of the current class." to access protected (non-static) members. Without that it is as if the member was package private. If I read it correctly the type A conservative estimation mode that treats Target = T could work in practice, but isn't ideal. |
Yep, 5.4.4 also notes:
which seems to imply that Target and T are separate. I took a look at this issue when I originally reported it and it looks like it's not easy to solve with TR's current design since it needs to analyse the stack. See also JLS 6.6.2.1 which is the same rule in source code terms. |
See this reproduction repo: https://github.com/Juuxel/tr-package-access-reproduction
example-code/src/main/java
) contains two classes,example.Parent
andexample.Child
example.Parent
has a protected field that is accessed inexample.Child
's constructorgradlew testWithoutRemapping
to see "hello" when the jar is not remappergradlew testWithRemapping
to see a JVM crashexample.Child
is remapped toexample.child.Child
andexample.Parent
stays intact, the protected access now becomes an error. (Accessing protected fields of another instance from a class not in the same package)protected
modifier from the field and make it package-private. TR fixes that to be public.remapper/src/main/java/remapper/Main.java
This issue also has practical effects when remapping Minecraft to Yarn in environments where all protected accesses are not transformed to be public (FML on Yarn).
The text was updated successfully, but these errors were encountered: