1

I am experiencing a strange behavior with YGuard obfuscation in Java 11. I have a class which comprises some private fields and methods and inner classes as below.

public class TestClass {

    private int age;

    public void accessInnerClassVaiable() {
    InnerClass innerClz = new InnerClass();
    
    // Below lines throw java.lang.IllegalAccessError after obfuscation.
    System.out.println("Inner Class variable value:" + innerClz.innerVar);
    innerClz.accessAge();

    }

    class InnerClass {
    private int innerVar = 10;

    public void accessAge() {
        // Below line throws java.lang.IllegalAccessError after obfuscation.
        innerVar = age;
    }
    }
}

If I compile and run the program, it works fine.

But after obfuscated my class files using YGuard (3.0.0), while running the program the lines mentioned above throws java.lang.IllegalAccessError as

  1. The outer class access the private fields/ methods present in the inner class

  2. The inner class access the private fields/ methods present in the outer class.

Can anyone shed some light on how to overcome this issue?

Thanks in advance.

Kather
  • 95
  • 8
  • After obfuscating your `TestClass` with yGuard 3.0.0, I do not get any errors when calling the obfuscated `accessInnerClassVariable` method. If this is still an issue, I suggest creating a complete test case and opening a corresponding issue at https://github.com/yWorks/yGuard/issues – Thomas Behr Mar 24 '22 at 10:01

0 Answers0