我的代码适用于Eclipse,但无法使用javac编译 - JDK7

时间:2015-01-19 03:00:53

标签: java eclipse ant

我的代码在Eclipse中编译并运行良好。我也出口了.jar。但是当我使用ant和javac在我的构建服务器上编译它时,它会给出一条错误消息并且无法编译。

JList更改为JList<Object>后,会发生这种情况。我改变了它,因为有人说通用原始类型不安全。

我应该再次使用原始类型吗?还是有其他想法?

PS。服务器中的javac版本是1.7.0_72,而我的eclipse版本是4.4.1

我的代码:

public class CheckListManager  extends MouseAdapter implements ListSelectionListener, ActionListener{ 
    private ListSelectionModel selectionModel = new DefaultListSelectionModel(); 
    private JList<Object> list = new JList<Object>();
    int hotspot = new JCheckBox().getPreferredSize().width; 

    public CheckListManager(JList<Object> list) {
        this.list = list; 
        list.setCellRenderer(new CheckListCellRenderer(list.getCellRenderer(), selectionModel)); 
        list.registerKeyboardAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), JComponent.WHEN_FOCUSED); 
        list.addMouseListener(this); 
        selectionModel.addListSelectionListener(this); 
    }

    (... so on)

    private class CheckListCellRenderer extends JPanel implements ListCellRenderer<Object> {
        public CheckListCellRenderer(ListCellRenderer<Object> renderer, ListSelectionModel selectionModel) {

        (...)

        }
    }
}

错误代码:

C:\BuildSite_United\trunk\java\XE Core\src\com\psia\core\view\util\CheckListManager.java:29: error: constructor CheckListCellRenderer in class CheckListManager.CheckListCellRenderer cannot be applied to given types;
        list.setCellRenderer(new CheckListCellRenderer(list.getCellRenderer(), selectionModel));
                             ^
  required: ListCellRenderer<Object>,ListSelectionModel
  found: ListCellRenderer<CAP#1>,ListSelectionModel
  reason: actual argument ListCellRenderer<CAP#1> cannot be converted to ListCellRenderer<Object> by method invocation conversion
  where CAP#1 is a fresh type-variable:
    CAP#1 extends Object super: Object from capture of ? super Object

0 个答案:

没有答案