我重新编写了我的程序,它刚刚爆炸了。所有我改变的是一些String.format()返回并恢复这些更改并没有使这个错误消失。当我研究错误时,它似乎与Maven有关?但我使用ANT来构建项目。
Exception in thread "Thread-2" java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file InHouseLeague/Workers/BotListener
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at org.schwering.irc.moep.MoepIRC.run(MoepIRC.java:831)
at java.lang.Thread.run(Thread.java:722)
它引用的代码(我几周没碰过)
public void run() {
updateTab(Util.CONSOLEWINDOWINDEX, "# Trying to connect to "+ host,
serverColor);
enableConnectMenuItem(false);
username = username.toLowerCase();
if (!useSSL) {
conn = new BotConnection(host, portMin, portMax, password, nickname,
username, realname);
} else {
BotSSLConnection sslconn = new BotSSLConnection(host, portMin, portMax,
password, nickname, username, realname);
if (!autoAcceptSSLCerts)
sslconn.addTrustManager(new AskTrustManager());
conn = sslconn;
}
conn.addIRCEventListener(new BotListener(this)); //ERROR POINTS TO HERE
conn.setColors(true);
conn.setPong(false);
conn.setDaemon(true);
try {
conn.connect();
this.isConnected = conn.isConnected();
} catch (Exception exc) {
String reason = "";
if (exc.getMessage() != null) {
reason = ": "+ exc.getMessage();
}
updateTab(Util.CONSOLEWINDOWINDEX, "# Couldn't connect"+ reason,
serverColor);
enableConnectMenuItem(true);
exc.printStackTrace();
this.isConnected = false;
}
}
在此之前我所做的更改发生了:
自:
@Override
public String toString() {
String returnStr = String.format("%s(ELO: %d):", getTeamName(), teamELO);
for (IPlayer player : roster) {
returnStr = String.format("%s %s", returnStr, player.getUserName());
}
return returnStr;
}
要
public String toString() {
String returnStr = String.format("%s[%d]:", getTeamName(), teamELO);
for (IPlayer player : roster) {
returnStr = String.format("%s %s;", returnStr, player.getUserName());
}
return returnStr;
}
答案 0 :(得分:0)
诊断是:
在类文件中不是本机或抽象的方法中的Absent Code属性InHouseLeague / Workers / BotListener
您没有说过代码更改是否在InHouseLeague.Workers.BotListener类中,或者它是一个库类。无论如何,通常任何代码更改都不能使编译器生成没有代码attrubute的方法。类文件以另一种方式被破坏,例如,它是硬件设备错误。