java local variable unavailable

2019-07-30 15:14发布

问题:

I'm getting the following error from the eclipse debugger: local variable unavailable. Tried to trim the code as much as possible. The problem is pretty simple, I have to use the DivisiveUI UpdateLog() method, from the Divise class, using variables from the Cluster class. The Divise has a list containing all of the clusters. Divisive and DivisiveUI has a reference to each other. How can I get access to the variables: sumDistance, avgDistance from the Divisive class? Tried writing a method in the Divisive class, still couldn't access the needed variables :| Thank you!

Error crops at log.append(text+"\n"); Source Not Found.

Divisive:

   package clusters;

        import java.util.LinkedList;

        public class Divisive implements Runnable
        {
            LinkedList<Record> mainTable;
            LinkedList<Cluster> clusterList;
            int meassureType;
        DivisiveUI parent;
        int clusterCount;

        Divisive(LinkedList<Record> mainTable, DivisiveUI parent)
        {
            this.parent=parent;
            this.mainTable=new LinkedList<Record>(mainTable);
            setMeassureType(0);
        }

    }

DivisiveUI:

 package clusters;



@SuppressWarnings("serial")
public class DivisiveUI extends JPanel implements Runnable{

    ClusteringSelection parent;
    Divisive divisive;
    JTextField clusterCount;
    JTextArea log;

    public void UpdateLog(String text)
    {
        log.append(text+"\n");
        log.setCaretPosition(log.getDocument().getLength());
    }
}

Cluster:

 package clusters;


public class Cluster 
{
    LinkedList<Record> table;
    LinkedList<MatrixRow> matrix;

    LinkedList<Double> center;
    double sumDistance;
    double avgDistance;

    int meassureType;
}

回答1:

If the debugger can't acces the local variable, that means that the code hasn't been compiled with the option adding the local variable debugging information from the bytecode.

Check how you're compiling the classes, and make sure this information is in the compiled classes. If javac is used, add the -g option to ad all the debugging information.