Menu

#526 java.lang.NoClassDefFoundError when obfucating Java 8 lambda expression referencing "this"

v5.0
closed-fixed
8
2014-08-24
2014-05-07
No

I don't know if you're already accepting Bug Reports for the 5.0 Beta but here's what I ran into:

When you obfuscate Java 8 code containing a lambda expression that uses the "this" reference, a java.lang.NoClassDefFoundError is thrown when you try to run the program.

Here's a sample code that reproduces the error:

public class Main {
    public static void main(String[] args) {
        new Test().test();
    }
}

public class Test {
    public void test() {
        List<Integer> l = new ArrayList<>();
        l.add(1);
        l.add(2);
        l.add(3);
        l.add(4);
        l.forEach((num) -> System.out.println(this));
    }
}

Stacktrace:
Exception in thread "main" java.lang.NoClassDefFoundError: Test
at Main.main(Unknown Source)
Caused by: java.lang.ClassNotFoundException: Test
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
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)
... 1 more

I've also attached the ProGuard config file I was using.

1 Attachments

Discussion

  • Fabyan Alexander Belz Hesse

    Sorry, wrote a wrong answer.

     

    Last edit: Fabyan Alexander Belz Hesse 2014-05-08
  • Eric Lafortune

    Eric Lafortune - 2014-05-13

    Thanks for your concise report. I can reproduce the problem. I'll fix it for the upcoming ProGuard 5.0 beta2.

     
  • Eric Lafortune

    Eric Lafortune - 2014-05-13
    • status: open --> open-accepted
    • assigned_to: Eric Lafortune
    • Priority: 5 --> 8
     
  • Eric Lafortune

    Eric Lafortune - 2014-05-13
    • Group: v4.11 --> v5.0
     
  • Eric Lafortune

    Eric Lafortune - 2014-08-05
    • status: open-accepted --> open-fixed
     
  • Eric Lafortune

    Eric Lafortune - 2014-08-19
    • Status: open-fixed --> closed-fixed
     

Log in to post a comment.