Menu

#579 Lambda and internal interface - java.lang.NoClassDefFoundError

v5.2
closed-fixed
None
5
2016-10-23
2015-07-29
No

I have a problem with lambda expression and internal interfaces.
I use java 1.8.0_45 and ProGuard 5.2.1
My 4 java sources:

LambdaTest.java:

package proguard;
public class LambdaTest {
    public static void main(String[] args) {
        Integer i = NumberCreate.getNumber();
        System.out.println(i == null ? "i == null" : "i != null");
    }
}

NumberCreate.java:

package proguard;
public final class NumberCreate {
    public static Integer getNumber() {
        return DataKey.createDataKey(()->createData());
    }
    public static DataAndIntefrace.Data createData() {
        return new DataAndIntefrace.Data();
    }
}

DataAndIntefrace.java:

package proguard;
public class DataAndIntefrace {
    public static class Data {
    }
    public static interface IData {
        public Data getData();
    }
}

DataKey.java:

package proguard;
import proguard.DataAndIntefrace.IData;
public final class DataKey {
    public static Integer createDataKey(final IData iDane) {
        return null;
    }
}

After obfuscation, when the program starts, java throws an error:

Exception in thread "main" java.lang.NoClassDefFoundError: proguard/DataAndIntefrace$Data
        at proguard.a.a(Unknown Source)
        at proguard.LambdaTest.main(Unknown Source)
Caused by: java.lang.ClassNotFoundException: proguard.DataAndIntefrace$Data
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 2 more

Thanks
Adam

Discussion

  • Eric Lafortune

    Eric Lafortune - 2015-07-29

    Thank your for your detailed report. The sample allowed me to reproduce the problem. ProGuard didn't update lambda method types properly when merging classes in which they occurred. I have now fixed it for the upcoming ProGuard 5.3. For the time being you should be able to avoid the issue by disabling class merging:

    -optimizations !class/merging/*
    
     
  • Eric Lafortune

    Eric Lafortune - 2015-07-29
    • status: open --> open-fixed
     
  • Adam Bartoszewicz

    Thank you for quick reply

     
  • Eric Lafortune

    Eric Lafortune - 2016-10-23
    • Status: open-fixed --> closed-fixed
     

Log in to post a comment.