请求大虾帮助,还原下面的方法,不胜感激!public void run()
{
ThreadPoolExecutor threadpoolexecutor;
init();
threadpoolexecutor = getRunner();
lastIdleTime = System.currentTimeMillis();
_L3:
boolean flag;
flag = false;
if(udpSocket == null)
{
synchronized(this)
{
running = false;
}
break; /* Loop/switch isn't completed */
}
try
{
label0:
{
byte abyte0[] = new byte[maxPacketSize];
DatagramPacket datagrampacket = new DatagramPacket(abyte0, abyte0.length);
udpSocket.receive(datagrampacket);
long l1 = System.currentTimeMillis();
int i = datagrampacket.getLength();
if(i > 0)
{
lastIdleTime = l1;
threadpoolexecutor.execute(new LoadBalancerListenerHandler(abyte0, 0, i));
}
synchronized(this)
{
if(!quit)
{
break label0;
}
running = false;
}
break; /* Loop/switch isn't completed */
}
}
catch(SocketTimeoutException sockettimeoutexception)
{
label1:
{
synchronized(this)
{
if(!quit)
{
break label1;
}
running = false;
}
break; /* Loop/switch isn't completed */
}
}
catch(Exception exception1)
{
label2:
{
synchronized(this)
{
if(!quit)
{
break label2;
}
running = false;
}
break; /* Loop/switch isn't completed */
}
}
loadbalancerlistener4;
JVM INSTR monitorexit ;
break MISSING_BLOCK_LABEL_237;
exception3;
throw exception3;
loadbalancerlistener2;
JVM INSTR monitorexit ;
goto _L1
exception4;
throw exception4;
_L1:
flag = true;
break MISSING_BLOCK_LABEL_237;
loadbalancerlistener3;
JVM INSTR monitorexit ;
break MISSING_BLOCK_LABEL_237;
exception5;
throw exception5;
if(flag)
{
long l = System.currentTimeMillis();
if(l - lastIdleTime > (long)idleInterval)
{
lastIdleTime = l;
threadpoolexecutor.execute(new LoadBalancerListenerIdler());
}
}
if(true) goto _L3; else goto _L2
_L2:
try
{
synchronized(this)
{
if(udpSocket != null)
{
udpSocket.close();
}
udpSocket = null;
}
}
catch(Exception exception) { }
killRunner();
shutdown();
return;
}
{
ThreadPoolExecutor threadpoolexecutor;
init();
threadpoolexecutor = getRunner();
lastIdleTime = System.currentTimeMillis();
_L3:
boolean flag;
flag = false;
if(udpSocket == null)
{
synchronized(this)
{
running = false;
}
break; /* Loop/switch isn't completed */
}
try
{
label0:
{
byte abyte0[] = new byte[maxPacketSize];
DatagramPacket datagrampacket = new DatagramPacket(abyte0, abyte0.length);
udpSocket.receive(datagrampacket);
long l1 = System.currentTimeMillis();
int i = datagrampacket.getLength();
if(i > 0)
{
lastIdleTime = l1;
threadpoolexecutor.execute(new LoadBalancerListenerHandler(abyte0, 0, i));
}
synchronized(this)
{
if(!quit)
{
break label0;
}
running = false;
}
break; /* Loop/switch isn't completed */
}
}
catch(SocketTimeoutException sockettimeoutexception)
{
label1:
{
synchronized(this)
{
if(!quit)
{
break label1;
}
running = false;
}
break; /* Loop/switch isn't completed */
}
}
catch(Exception exception1)
{
label2:
{
synchronized(this)
{
if(!quit)
{
break label2;
}
running = false;
}
break; /* Loop/switch isn't completed */
}
}
loadbalancerlistener4;
JVM INSTR monitorexit ;
break MISSING_BLOCK_LABEL_237;
exception3;
throw exception3;
loadbalancerlistener2;
JVM INSTR monitorexit ;
goto _L1
exception4;
throw exception4;
_L1:
flag = true;
break MISSING_BLOCK_LABEL_237;
loadbalancerlistener3;
JVM INSTR monitorexit ;
break MISSING_BLOCK_LABEL_237;
exception5;
throw exception5;
if(flag)
{
long l = System.currentTimeMillis();
if(l - lastIdleTime > (long)idleInterval)
{
lastIdleTime = l;
threadpoolexecutor.execute(new LoadBalancerListenerIdler());
}
}
if(true) goto _L3; else goto _L2
_L2:
try
{
synchronized(this)
{
if(udpSocket != null)
{
udpSocket.close();
}
udpSocket = null;
}
}
catch(Exception exception) { }
killRunner();
shutdown();
return;
}
1)由于楼主没有同时提供.class文件[提供了.class文件,可以完全准确还原],楼主所提供的还原代码有部分信息丢失,还好由于程序简单,已正确判读还原了。
2)还原代码如下:
(1)楼主虽然只提供了这个run()方法的代码,但从代码中,已正确判读出该方法所在的类,类名一定叫“ LoadBalancerListener”,这是从代码中第一个判读还原出来的。
(2)代码中看起来混乱的部分实际上是由try()catch{}造句产生的,其实对经常判读class代码的程序员,它是很清楚的,一点也不混乱的。
(3)还原的代码:public void run()
{
ThreadPoolExecutor threadpoolexecutor;
init();
threadpoolexecutor = getRunner();
lastIdleTime = System.currentTimeMillis(); while(true){
boolean flag;
flag = false;
if(udpSocket == null)
{
synchronized(this)
{
running = false;
break;
}
}
try
{
byte abyte0[] = new byte[maxPacketSize];
DatagramPacket datagrampacket = new DatagramPacket(abyte0, abyte0.length);
udpSocket.receive(datagrampacket);
long l1 = System.currentTimeMillis();
int i = datagrampacket.getLength();
if(i > 0)
{
lastIdleTime = l1;
threadpoolexecutor.execute(new LoadBalancerListenerHandler(abyte0, 0, i));
}
synchronized(this)
{
if(quit)
{
running = false;
break;
}
}
}
catch(SocketTimeoutException sockettimeoutexception)
{
synchronized(this)
{
if(quit)
{
running = false;
break;
}
}
flag=true;
}
catch(Exception exception1)
{
synchronized(this)
{
if(quit)
{
running = false;
break;
}
}
}
if(flag)
{
long l = System.currentTimeMillis();
if(l - lastIdleTime > (long)idleInterval)
{
lastIdleTime = l;
threadpoolexecutor.execute(new LoadBalancerListenerIdler());
}
} }//while(true)
try
{
synchronized(this)
{
if(udpSocket != null)
{
udpSocket.close();
}
udpSocket = null;
}
}
catch(Exception exception) { }
killRunner();
shutdown();
return;
}
(4)由于楼主没有提供.class文件,如何验证判读的结果是正确的?
将它编译成.class文件后,再用JAVA反编译程序反编译出代码,楼主可看到,结果[run()的反编译代码与楼主提供的是一模一样的]
//以下是对还原后的代码,编译成.class文件后,再用JAVA反编译程序反编译代码[与楼主的代码反编译代码相对比]
说明:为了程序能正确编译,加补了正确的类名,及程序中引用到的其它方法与变量。// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3)
// Source File Name: LoadBalancerListener.javaimport java.net.*;
import java.util.concurrent.ThreadPoolExecutor;public class LoadBalancerListener
{
public void run()
{
init();
ThreadPoolExecutor threadpoolexecutor = getRunner();
lastIdleTime = System.currentTimeMillis();
_L3:
boolean flag;
flag = false;
if(udpSocket == null)
{
synchronized(this)
{
running = false;
}
break; /* Loop/switch isn't completed */
}
try
{
label0:
{
byte abyte0[] = new byte[maxPacketSize];
DatagramPacket datagrampacket = new DatagramPacket(abyte0, abyte0.length);
udpSocket.receive(datagrampacket);
long l1 = System.currentTimeMillis();
int i = datagrampacket.getLength();
if(i > 0)
lastIdleTime = l1;
synchronized(this)
{
if(!quit)
break label0;
running = false;
}
break; /* Loop/switch isn't completed */
}
}
catch(SocketTimeoutException sockettimeoutexception)
{
label1:
{
synchronized(this)
{
if(!quit)
break label1;
running = false;
}
break; /* Loop/switch isn't completed */
}
}
catch(Exception exception1)
{
label2:
{
synchronized(this)
{
if(!quit)
break label2;
running = false;
}
break; /* Loop/switch isn't completed */
}
}
loadbalancerlistener4;
JVM INSTR monitorexit ;
break MISSING_BLOCK_LABEL_218;
exception3;
throw exception3;
loadbalancerlistener2;
JVM INSTR monitorexit ;
goto _L1
exception4;
throw exception4;
_L1:
flag = true;
break MISSING_BLOCK_LABEL_218;
loadbalancerlistener3;
JVM INSTR monitorexit ;
break MISSING_BLOCK_LABEL_218;
exception5;
throw exception5;
long l;
if(flag)
l = System.currentTimeMillis();
if(true) goto _L3; else goto _L2
_L2:
try
{
synchronized(this)
{
if(udpSocket != null)
udpSocket.close();
udpSocket = null;
}
}
catch(Exception exception) { }
killRunner();
shutdown();
return;
}
//以下是加被的空的方法与变量名,目的是:能够正确通过编译。
public LoadBalancerListener()
{
udpSocket = null;
running = false;
maxPacketSize = 0;
} void init()
{
} void killRunner()
{
} void shutdown()
{
} ThreadPoolExecutor getRunner()
{
return null;
}
long lastIdleTime;
DatagramSocket udpSocket;
boolean running;
boolean quit;
int maxPacketSize;
}
一个建议:以后楼主不要只提供反编译的代码,要提供.class文件,这样好完全准确还原[而不用对还原后的代码,再次进行编译.class后,再反编译后与你原来的反编译代码进行对比。]
import java.net.*;class LoadBalancerListenerHandler
{}//空,用于通过编译public class LoadBalancerListener {
public void run()
{
ThreadPoolExecutor threadpoolexecutor;
init();
threadpoolexecutor = getRunner();
lastIdleTime = System.currentTimeMillis(); while(true){
boolean flag;
flag = false;
if(udpSocket == null)
{
synchronized(this)
{
running = false;
break;
}
}
try
{
byte abyte0[] = new byte[maxPacketSize];
DatagramPacket datagrampacket = new DatagramPacket(abyte0, abyte0.length);
udpSocket.receive(datagrampacket);
long l1 = System.currentTimeMillis();
int i = datagrampacket.getLength();
if(i > 0)
{
lastIdleTime = l1;
// threadpoolexecutor.execute(new LoadBalancerListenerHandler(abyte0, 0, i));
}
synchronized(this)
{
if(quit)
{
running = false;
break;
}
}
}
catch(SocketTimeoutException sockettimeoutexception)
{
synchronized(this)
{
if(quit)
{
running = false;
break;
}
}
flag=true;
}
catch(Exception exception1)
{
synchronized(this)
{
if(quit)
{
running = false;
break;
}
}
}
if(flag)
{
long l = System.currentTimeMillis();
// if(l - lastIdleTime > (long)idleInterval)
// {
// lastIdleTime = l;
// threadpoolexecutor.execute(new LoadBalancerListenerIdler());
// }
}
}//while(true)
try
{
synchronized(this)
{
if(udpSocket != null)
{
udpSocket.close();
}
udpSocket = null;
}
}
catch(Exception exception) { }
killRunner();
shutdown();
return;
}//以下是人为加上的内容,以便通过编译。
void init(){}
void killRunner(){}
void shutdown(){}
ThreadPoolExecutor getRunner(){return null;}
long lastIdleTime;
DatagramSocket udpSocket=null;
boolean running=false,quit;
int maxPacketSize=0;
}
对上述代码进行编译.class文件后,再次反编译,看run()反编译代码与楼主的反编译代码对比,以进行验证。还是最好提供.class文件,这样可不用再次验证了。