我正在阅读反编译Java软件的源代码。它是混淆的,但我认为它也应该遵守Java的规则。我希望此类NK$1
调用this.b.a.q()
方法,但我找不到有关b
成员的任何内容,即使对于成员及其q()
方法也是如此。为什么代码是这样的?
您好,根据您的回答,我在外层b
找到了NK
。但我仍然找不到a
,因为b
是JButton
对象,我认为a
中没有成员JButton
?我在下面添加了外部类代码。
1)以下是整个文件NK$1.class
(就像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)下面是NK.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;
}
}
答案 0 :(得分:2)
内部类可以引用外部类中的变量。在反编译代码中,未显示。我相信你的this.b.a.q();
指的是你外层的东西(=你的匿名类被定义的类)。
请参阅此示例。我写了一个这样的课:
public class ContainsAnonymousInnerClass {
public String s = "";
public void m() {
new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
s.toString();
}
};
}
}
当我使用JAD反编译内部类ContainsAnonymousInnerClass$1.class
时,我得到了这个:
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();
}
}
正如您所看到的,只有纯s.toString();
没有前缀this$0
。当然它实际上调用的是this$0.s.toString();
,因此反编译的代码不符合Java规则:)
我使用ProGuard对同一个类进行了混淆,得到了这个结果:
class ContainsAnonymousInnerClass$1 implements ActionListener {
public void actionPerformed(ActionEvent e) {
String _tmp = a.a; // which was originally s.toString();
}
private ContainsAnonymousInnerClass a;
}
正如您所写的那样,您的课程文件被混淆了,我坚信这是对您的某些外部成员的方法的调用。混淆器软件有很多参数设置它如何准确地混淆名称,因此很难确切地说出哪些。你必须自己找到它:))