How to use spoon to compile Hadoop projects

180 views Asked by At

I am a new user of Spoon and Astor. Recently I am using Astor(SpoonLabs/astor) to do some automated bug repair work.

The Astor will firstly use Spoon library to compile and analyze the project source code. Now I can use Spoon to synthesize small projects successfully, but it cannot successfully compile Hadoop submodule (e.g. hadoop/hadoop-common-project/hadoop-auth).

I found Spoon has problems in compiling the model. Seems that Spoon can NOT get the declared type from package-info.java file. Is there anyone knowing how to fix this issue? Thanks a lot!

the log information is listed below:

2017-08-30 17:59:15,128 INFO main - building model: /Users/someone/git/astor/./outputMutation/AstorMain-11859hadp//src//default, compliance level: 8
2017-08-30 17:59:15,136 INFO main - Classpath for building SpoonModel [too long to list all of them]
2017-08-30 17:59:16,885 ERROR main - Problem compiling the model with compliance level 8
2017-08-30 17:59:16,885 ERROR main - inconsistent compilation unit: '/Users/someone/git/astor/outputMutation/AstorMain-11859hadp/src/default/org/apache/hadoop/security/authentication/server/package-info.java': declared types are []
2017-08-30 17:59:16,885 INFO main - building model: /Users/someone/git/astor/./outputMutation/AstorMain-11859hadp//src//default, compliance level: 7
2017-08-30 17:59:16,887 INFO main - Classpath for building SpoonModel [too long to list all of them]
Exception in thread "main" java.lang.RuntimeException: inconsistent compilation unit: '/Users/someone/git/astor/outputMutation/AstorMain-11859hadp/src/default/org/apache/hadoop/security/authentication/server/package-info.java': declared types are []
    at spoon.support.reflect.cu.CompilationUnitImpl.getMainType(CompilationUnitImpl.java:68)
    at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.generateProcessedSourceFilesUsingCUs(JDTBasedSpoonCompiler.java:498)
    at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.generateProcessedSourceFiles(JDTBasedSpoonCompiler.java:203)
    at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.generateProcessedSourceFiles(JDTBasedSpoonCompiler.java:192)
    at fr.inria.astor.core.manipulation.MutationSupporter.buildModel(MutationSupporter.java:90)
    at fr.inria.astor.core.manipulation.MutationSupporter.buildModel(MutationSupporter.java:71)
    at fr.inria.astor.approaches.jgenprog.JGenProg.initModel(JGenProg.java:152)
    at fr.inria.astor.approaches.jgenprog.JGenProg.createInitialPopulation(JGenProg.java:62)
    at fr.inria.main.evolution.AstorMain.createEngine(AstorMain.java:97)
    at fr.inria.main.evolution.AstorMain.run(AstorMain.java:142)
    at fr.inria.main.AbstractMain.executeExample(AbstractMain.java:708)
    at fr.inria.main.evolution.AstorMain.execute(AstorMain.java:209)
    at fr.inria.main.evolution.AstorMain.main(AstorMain.java:199)
    at fr.inria.main.evolution.MainjGenProg.main(MainjGenProg.java:14)

The package-info.java file:

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * Provides the server-side framework for authentication.
 */
@InterfaceAudience.LimitedPrivate({ "HBase", "HDFS", "MapReduce" })
@InterfaceStability.Evolving
package org.apache.hadoop.security.authentication.server;

import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
1

There are 1 answers

1
Simon Urli On

I don't think stackoverflow is the right place for your problem here: it's either a bug in Spoon or in Astor. I suggest you to open the issue in Astor (https://github.com/SpoonLabs/astor/issues) first and we'll see if it's related to Astor or Spoon. If you can, when you'll create the issue provide the full command line argument you used with Astor so I'll be able to replicate easily your bug.