【问题标题】:Source not found message while debugging调试时找不到源消息
【发布时间】:2012-08-03 21:24:03
【问题描述】:

有人在我的代码中看到什么奇怪的东西吗? 这是存储解析器实例的解析器工厂类。我在文本文件中保存了数据库中的信息对象,通常格式为

/table/something/something
nameoftablecolumn/info/info/...

etc.

我有解析这个文本文件的类,解析器可以解析不同的行。例如,如果行开始 /table/ 我将选择调用 getParser("table") 的表解析器。 当我想解析视图时,我遇到了一些问题。我试图通过在 Eclipse 中调试来找到它,但它告诉我 找不到源 并在调试中的操作列表中显示类未找到异常..但程序中没有异常..

当我按 F5 跳转到 ParserFactory 的构造函数时会发生这种情况。
有这个类的代码:

/**
 * 
 */
package appInspector.input.parser;

import java.util.HashMap;


import appInspector.input.parser.database.SourceParser;
import appInspector.input.parser.database.TableParser;
import appInspector.input.parser.database.ViewParser;
import appInspector.input.parser.filesystem.DirectoryParser;
import appInspector.input.parser.filesystem.FileParser;

/**
 *     
 */
public class ParserFactory {


    private HashMap<String, IParser> parsers = new HashMap<String, IParser>();

    private ParserFactory() {
        //filesystem
        parsers.put("directory", new DirectoryParser());
        parsers.put("file", new FileParser());
        //table
        parsers.put("table", new TableParser());
        //view
        parsers.put("view", new ViewParser());
        //source
        parsers.put("source", new SourceParser());
    }

    public static ParserFactory newInstance(){
        return new ParserFactory();
    }

    public IParser getParser(String key) {
        IParser parser = parsers.get(key);
        if(parser == null ){
            System.out.println("Nepodporovaný objekt");

        }
        return parser;
    }
}

编辑: 我有类似的问题(类似的输出 - 意味着找不到源)。 Eclipse debugging "source not found"

【问题讨论】:

    标签: java eclipse debugging singleton factory-pattern


    【解决方案1】:

    我尝试在我的 Eclipse 版本上复制该问题,但未能成功。我在 Eclipse JUNO,OSX Mountain Lion。

    我修改了你的代码来测试它:

    package com.aj.spring;
    
    import java.util.HashMap;
    
    /**
     *  *  
     */
    public class ParserFactory {
    
        private HashMap<String, IParser> parsers = new HashMap<String, IParser>();
    
        private ParserFactory() {
            parsers.put("directory", new FileParser());
            parsers.put("file", new FileParser());
            parsers.put("table", new FileParser());
            parsers.put("view", new FileParser());
            parsers.put("source", new FileParser());
        }
    
        public static ParserFactory newInstance() {
            return new ParserFactory();
        }
    
        public IParser getParser(String key) {
            IParser parser = parsers.get(key);
            if (parser == null) {
                System.out.println("Nepodporovan objekt");
    
            }
            return parser;
        }
    
        public static void main(String[] args) {
            ParserFactory.newInstance();
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-04
      • 1970-01-01
      • 2012-03-17
      • 2010-12-29
      • 2012-07-04
      • 1970-01-01
      相关资源
      最近更新 更多