我已经从 jar 中修改了 java 代码,编译后,我编写的代码不起作用。我尝试反编译,发现它说的是以下错误:
未解决的编译问题:
范围内无法访问 DirectDelivDetail 类型的封闭实例
this$0 无法解析或不是字段
DirectDelivDetail 类型的方法setComments()不可见
我知道有很多讨论这个问题的线程,但我没有找到解决方案。好的,这是代码:
public class DirectDelivDetail extends CMSApplet implements
    LookupHandler {
    private MultiLineEditor comments = null;
    private CMSShipment shipment = null;
    private void setComments() {
        try {
            if (this.shipment != null) {
                this.shipment.setComments(this.comments.getText());
            }
        } catch (BusinessRuleException bre) {
            JOptionPane.showMessageDialog(null, res.getString(bre.getMessage()));
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    DirectDelivDetail.this.comments.requestFocus();
                }
            });
        } finally {
            checkFields();
        }
    }
    private JPanel createDetailPanel() {
        this.comments = new MultiLineEditor();
        this.comments.addFocusListener(new FocusAdapter() {
            public void focusLost(FocusEvent e) {
                if (!e.isTemporary()) {
                    DirectDelivDetail.this.setComments();
                }
            }
        });
        return detailPanel;
    }
}
编译后代码更改。这是以下变化。
private JPanel createDetailPanel() {
    this.comments = new MultiLineEditor();
    this.comments.addFocusListener(new FocusAdapter() {
        public void focusLost(FocusEvent e) {
            throw new Error("Unresolved compilation problems: \n\tNo enclosing instance of the type DirectDelivDetail is accessible in scope\n\tThe method checkCancelCommand(FocusEvent) from the type DirectDelivDetail is not visible\n\tthis$0 cannot be resolved or is not a field\n\tNo enclosing instance of the type DirectDelivDetail is accessible in scope\n\tThe method setComments() from the type DirectDelivDetail is not visible\n");
        }
    });
    return detailPanel;
}