Question

I am reading the source code of a decompiled Java software. It is obfuscated, but I think it should also obey the Java's rules. I want this class NK$1 called this.b.a.q() method, but I didn't find anything about the b member, even for a member and its q() method. Why the code is like this?

Hi, based on your answer, I have found b in the outer class, NK. But I still cannot find a, because b is JButton object, I don't think there is an member a in JButton? I have added the outer class code below.

1) Below is the whole file NK$1.class (just like NK$1.java)

package com.xxx;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

class NK$1
  implements ActionListener
{
  NK$1(NK paramNK, NI paramNI) {}

  public void actionPerformed(ActionEvent paramActionEvent)
  {
    this.b.a.q(); ------------------> where is the b?
  }
}

2) Below is the NK.class (Outer class)

package com.xxx;

import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JPanel;

class NK
  extends JPanel
{
  private JButton b; <-------------- this is b, but where is the a in "this.b.a.q()"?

  NK(NI paramNI)
  {
    double[][] arrayOfDouble = { { 5.0D, -1.0D, -2.0D, 10.0D, -2.0D, 10.0D, -2.0D, 10.0D, -2.0D, 10.0D, -2.0D, 5.0D }, { 5.0D, -2.0D, 5.0D } };




    ayI localayI = new ayI(arrayOfDouble);
    setLayout(localayI);

    JButton localJButton = new JButton("Load");
    this.b = localJButton;
    add(localJButton, "8,1,c,c");

    localJButton.setMnemonic(76);
    Icon localIcon = Fi.b();
    if (localIcon != null) {
      localJButton.setIcon(localIcon);
    }
    localJButton.addActionListener(new NK.1(this, paramNI)); <---------Here is the inner class






    localJButton = FJ.d();
    localJButton.setMnemonic(72);
    add(localJButton, "1,1,l,c");

    localJButton.addActionListener(new NK.2(this, paramNI));
    if ((Gr.z() != null) && (!FI.ao()))
    {
      paramNI.h = new JButton("Download updates");
      paramNI.h.setMnemonic(68);
      paramNI.i = new NJ(paramNI);
      add(paramNI.h, "2,1,c,c");

      localIcon = Fi.c("SUITE_DOWNLOAD");
      if (localIcon != null) {
        paramNI.h.setIcon(localIcon);
      }
      paramNI.h.addActionListener(new NK.3(this, paramNI));
    }
    else
    {
      add(localJButton, "2,1,c,c");
    }
    localJButton = new JButton("Refresh");
    add(localJButton, "6,1,c,c");

    localIcon = Fi.c("REFRESH");
    if (localIcon != null) {
      localJButton.setIcon(localIcon);
    }
    localJButton.addActionListener(new NK.4(this, paramNI));






    localJButton = new JButton("Close");
    localJButton.setMnemonic(67);
    add(localJButton, "10,1,c,c");
    localIcon = Fi.d();
    if (localIcon != null) {
      localJButton.setIcon(localIcon);
    }
    localJButton.addActionListener(new NK.5(this, paramNI));
  }

  public JButton a()
  {
    return this.b;
  }
}
Was it helpful?

Solution

Inner classes may reference the variables from their outer class. In the decompiled code, it is not shown. I believe that your this.b.a.q(); refers to something which is in your outer class (= the class where your anonymous class is defined).

See this example. I have written a class like this:

public class ContainsAnonymousInnerClass {
    public String s = "";
    public void m() {
        new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                s.toString();
            }
        };
    }
}

When I decompile the inner class ContainsAnonymousInnerClass$1.class using JAD, I get this:

class ContainsAnonymousInnerClass$1 implements ActionListener {
    public void actionPerformed(ActionEvent e) {
        s.toString(); // Notice this - it is not prefixed by this$0 as one would expect!
    }

    final ContainsAnonymousInnerClass this$0;
    ContainsAnonymousInnerClass$1() {
        this$0 = ContainsAnonymousInnerClass.this; // reference to the outer class
        super();
    }
}

As you can see, just pure s.toString(); without prefixing by this$0. Of course what it calls in fact is this$0.s.toString(); so the decompiled code does not obey the Java rules :)

I obfuscated the same class using ProGuard getting this result:

class ContainsAnonymousInnerClass$1 implements ActionListener {
    public void actionPerformed(ActionEvent e) {
        String _tmp = a.a; // which was originally s.toString();
    }
    private ContainsAnonymousInnerClass a;
}

As you wrote that your class files are obfuscated, I strongly believe it is a call to some of your outer class's member's method. The obfuscator software has a lot of parameters setting how exactly it obfuscates the names so it's difficult to say which exactly. You will have to find it yourself :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top