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

Add strict record checking. #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add strict record checking. #13

wants to merge 1 commit into from

Conversation

modmuss50
Copy link
Member

Record classes cannot be made extendable.
Record fields that match a component cannot be made mutable.

I added this an option (on by default) to allow disabling this check incase the record components do not match the field names + desc.

AccessWidener.Access classAccess = accessWidener.getClassAccess(name);

if (strictRecords && "java/lang/Record".equals(superName) && AccessWidener.ClassAccess.isExtendable(classAccess)) {
throw new UnsupportedOperationException(String.format("Cannot modify record (%s) access to be extendable", name));
Copy link

Choose a reason for hiding this comment

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

Should we fail explicitly or simply ignore these, like what we are doing with interface static fields? non-final interface static fields cause classfile format errors when loaded by jvm, but record violations apparently won't hurt the jvm class loading.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think ingore now 👍Crashing like this now would really need a major version bump. With v3 we can possibly have something this strict.

Loom's validator should really fail on both of this situations (and possibly more): https://github.com/FabricMC/fabric-loom/blob/dev/0.12/src/main/java/net/fabricmc/loom/task/ValidateAccessWidenerTask.java#L97

I tottaly forgot about this PR.

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.

None yet

2 participants