Skip to content

Accessor merging should use the widest visibility level of all accessors #172

@Earthcomputer

Description

@Earthcomputer

Let's say you have two mixins from two mods:

// mod 1
@Mixin(Foo.class)
public interface FooAccessor {
   @Accessor
   Bar getBar(); // public
}

// mod 2
@Mixin(Foo.class)
public abstract class FooMixin {
   @Accessor
   abstract Bar getBar(); // package-private

   void doSomething() {
      Bar bar = getBar();
      // ...
   }
}

it could happen that after accessor merging, the package-private version of the accessor is the one that is created, rather than the public one. This means that when mod 1 tries to use the accessor from a different class, it can generate an IllegalAccessError. Mixin should use the least restrictive visibility level of all accessors when merging them to avoid this issue (or just always make them public).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions