我正在尝试编组一个将 Thread 扩展为 XML 的类,代码如下:
@XmlRootElement
public class TransitionXML extends Thread {
ArcXML[] preArcs;
ArcXML[] postArcs;
int[] preArcTokens;
int[] postArcTokens;
int leastTime;
int longestTime;
String name;
//some methods
//a lot of get-set
@Override
public void run() {
while (true) {
if (this.postTransition() & this.preTransition()) {
//We take out the tokens.
this.executePreTranstion();
this.checkPreTransition();
try {
this.sleep(1000 * this.getTimeToPass());
} catch (InterruptedException ex) {
Logger.getLogger(TransitionXML.class.getName()).log(Level.SEVERE, null, ex);
}
//We see if we can put them in.
if (this.postTransition()) {
this.executePostTranstion();
this.checkPostTransition();
}
} else {
try {
this.sleep(2000);
} catch (InterruptedException ex) {
Logger.getLogger(TransitionXML.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
}
public TransitionXML()
{
}
}
}
这导致我出现这个错误:com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
java.lang.Thread$UncaughtExceptionHandler is an interface, and JAXB can't handle interfaces. ... java.lang.Thread$UncaughtExceptionHandler does not have a no-arg default constructor.
如果我正确理解这一点,它扩展 Thread 的事实会导致这个问题,但我还没有在网上看到解决方案。
除了使类成为实现可运行的对象之外,有没有人知道解决方案或解决方法?