简体   繁体   中英

Issue in method anonymous class in GWT

I am making a GWT framework similar to Swing framework.

In GWT, I have one method in which I am making a anonymous class in method, but the problem is when this method executes, the execution control does not go to anonymous class instead it skips over it.

After this method executes completely, the control is transfered to the anonymous class. And this thing is working perfectly fine in Swing.

public void model(){
    System.out.println("This line is executing");
    DataListModel model = new DataListModel() {
        public void setRecords(List records) {
            System.out.println("I see this line after model() executes completely");
            int i = 0;
            records = new LinkedList(records);
        }
    }
    System.out.println("this line is executed without executing DataListModel.setRecords()");
}   

The problem is that the DataListModel model = new DataListModel... line doesn't actually execute anything. It creates a new instance, but unless either the DataListModel constructor calls setRecords (which it probably doesn't) or you use the model variable in some way that calls setRecords , setRecords will never be called.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM