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

Method reference to protected method in base class in other package fails with IllegalAccessError #227

Closed
mig35 opened this issue Dec 23, 2016 · 10 comments

Comments

@mig35
Copy link

mig35 commented Dec 23, 2016

Hi.
Same issue as it was here: luontola/retrolambda#89

I'm using RxJava and subscribe method.

.subscribe(aBoolean -> {}, throwable -> doOnError(throwable)) - working
.subscribe(aBoolean -> {}, this::doOnError) - NOT working

using "me.tatarka:gradle-retrolambda:3.2.4"

@akonior
Copy link

akonior commented Dec 30, 2016

For me version 3.3.1 works. The newest version 3.4.0 not working.

@evant
Copy link
Owner

evant commented Jan 1, 2017

See #219

@evant
Copy link
Owner

evant commented Jan 24, 2017

Should be fixed by 3.5.0

@evant evant closed this as completed Jan 24, 2017
@danielesegato
Copy link

I still experience this in 3.6.0. Is it possible?

Android View class, lambda calling the setMeasuredDimension(int, int) protected method:

// the lamnda declaration
measureCallback = this::setMeasuredDimension;

This is the (cleaned up) error I get at runtime:

IllegalAccessError: Method 'View.setMeasuredDimension(int, int)' is inaccessible to class 'MyCustomView$$Lambda$1'

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.0'
        classpath 'me.tatarka:gradle-retrolambda:3.6.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

apply plugin: 'com.android.library'
apply plugin: 'me.tatarka.retrolambda'

android {
   // redacted
}

@dchupov
Copy link

dchupov commented Mar 31, 2017

I'm experiencing this exact issue using 3.5.0. IllegalAccessError when referencing a protected method from the base class which is located in another package.

@Artan1s
Copy link

Artan1s commented May 6, 2017

I'm experiencing this in 3.6.0 too.

@WonderCsabo
Copy link

I am also seeing this. :(

@jpalvarezl
Copy link

I have this issue with 3.6.1 too.

@kassim
Copy link

kassim commented Sep 28, 2017

I have this in 3.7.0

@RuslanKham322
Copy link

I think, i located problem (if author did not do this earlier).
I have this project structure:
-package
--subpackage
---BaseClass.java
--Subclass.java
BaseClass has protected method void someAction():

public class BaseClass {
    protected void someAction() { }
}

Subclass inherits BaseClass and has method public void runSomeAction(), that uses lambda:

public class Subclass extends BaseClass {
    public void runSomeAction() {
        final Runnable runnable = this::someAction;
        runnable.run();
    }
}

After clean run i have this generated class:

final class Subclass$$Lambda$1 implements Runnable {
    private final Subclass arg$1;

    private Subclass$$Lambda$1(Subclass var1) {
        this.arg$1 = var1;
    }

    public void run() {
        Subclass.access$lambda$0(this.arg$1);
    }

    public static Runnable lambdaFactory$(Subclass var0) {
        return new Subclass$$Lambda$1(var0);
    }
}

All works good.

But after making any changes in Subclass and running project, generated class is regenerated:

final class Subclass$$Lambda$1 implements Runnable {
    private final Subclass arg$1;

    private Subclass$$Lambda$1(Subclass var1) {
        this.arg$1 = var1;
    }

    public void run() {
        this.arg$1.someAction();
    }

    public static Runnable lambdaFactory$(Subclass var0) {
        return new Subclass$$Lambda$1(var0);
    }
}

And this.arg$1.someAction(); produces IllegalAccessError.
After clean run all again becomes good.

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

No branches or pull requests

10 participants