1
當我們使用勺子來分析像Hadoop這樣的大項目的源代碼時,經常會出現問題「xxx已經定義了」,因爲可能存在具有相同類名和相同包目錄的Java類子項目。對於大型項目的源代碼,我們如何處理勺子的源代碼分析中的「xxx類型已被定義」?
當我運行「java -cp xx spoon.Launcher -i〜/ hadoop-0.23.3-src/-p myspoon.CatchProcessor」時,出現以下錯誤。
Exception in thread "main" spoon.compiler.ModelBuildingException: The type JobInProgress is already defined
at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.reportProblem(JDTBasedSpoonCompiler.java:550)
at spoon.support.compiler.jdt.TreeBuilderRequestor.acceptResult(TreeBuilderRequestor.java:37)
at spoon.support.compiler.jdt.TreeBuilderCompiler.buildUnits(TreeBuilderCompiler.java:73)
at spoon.support.compiler.jdt.JDTBatchCompiler.getUnits(JDTBatchCompiler.java:120)
at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.buildUnits(JDTBasedSpoonCompiler.java:410)
at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.buildUnitsAndModel(JDTBasedSpoonCompiler.java:372)
at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.buildSources(JDTBasedSpoonCompiler.java:348)
at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.build(JDTBasedSpoonCompiler.java:119)
at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.build(JDTBasedSpoonCompiler.java:102)
at spoon.Launcher.buildModel(Launcher.java:700)
at spoon.Launcher.run(Launcher.java:651)
at spoon.Launcher.run(Launcher.java:106)
at spoon.Launcher.main(Launcher.java:99)
而且我發現有兩個JobInProgress.java在同一子工程「類Hadoop MapReduce的項目」
./hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/JobInProgress.java
./hadoop-mapreduce-project/src/java/org/apache/hadoop/mapred/JobInProgress.java
那麼如何解決這個問題????? 我已經發現,它似乎我們不能搬走都跑勺分析的一個,因爲它會導致「丟失的文件」
Exception in thread "main" spoon.compiler.ModelBuildingException: The import org.apache.hadoop.conf cannot be resolved at xxx
對這個問題的任何意見的另一個問題?謝謝。
謝謝。這是一個很好的建議。我會試一試。 –