Unresolved compilation problems: No enclosing instance, Private method from the class is not visible, this$0 cannot be resolved [closed]

StackOverflow https://stackoverflow.com/questions/17311798

  •  01-06-2022
  •  | 
  •  

Question

I have modified java code from jar and after doing compiled, the code I've written doesn't work. I try to decompile and I found the following error it is saying:

Unresolved compilation problems:

No enclosing instance of the type DirectDelivDetail is accessible in scope

this$0 cannot be resolved or is not a field

The method setComments() from the type DirectDelivDetail is not visible

I know there are a ton of threads that discuss about that, but I didn't find a solution. Okay, this is the code:

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;
    }
}

The code change after compiled. This is the following changes.

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;
}
Was it helpful?

Solution

Your first mistake is that you have allowed / told the IDE you are using to run an application that has compilation errors in it.

Don't do that!

Uncheck the preference, or whatever. You need to fix the compilation errors before you attempt to run the program.

If you do that, decompiling won't be necessary ... and you won't see the additional confusing "artefacts" that result from doing that.


The actual compilation errors seem to be saying that DirectDelivDetail.this is not valid. But it looks to be as if it should be. However, it is not clear to me if either the source code or the error messages are real ... or artefacts of decompile / recompile. (Your Question is unclear as to how you got to the point that produced those error messages.) So I think the best thing to do is to show us the original error messages that you got by compiling the original source code ... not stuff that has been reconstructed by a decompiler.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top