INRIA / spoon

Spoon is a metaprogramming library to analyze and transform Java source code. :spoon: is made with :heart:, :beers: and :sparkles:. It parses source files to build a well-designed AST with powerful analysis and transformation API.
http://spoon.gforge.inria.fr/
Other
1.74k stars 348 forks source link

The type package-info is already defined #2454

Closed nharrand closed 6 years ago

nharrand commented 6 years ago

Problem

Spoon seems to take package-info.java as containing a type definition, and as the project contains many modules, it takes it (and other package-info.java) as multiple conflicting type definitions.

Reproduction steps

On project aws-sdk-java

git clone https://github.com/aws/aws-sdk-java.git
cd aws-sdk-java
# realease 1.11.368
git reset --hard d28a35b

When trying to build a spoon model:

File pom = new File("path/to/aws-sdk-java/pom.xml");
MavenLauncher launcher = new MavenLauncher(pom.getParentFile().getAbsolutePath(), MavenLauncher.SOURCE_TYPE.APP_SOURCE);
launcher.getEnvironment().setAutoImports(true);
launcher.buildModel();
CtModel model = launcher.getModel();

I get the following problem:

Filename :path/to/aws-sdk-java/aws-java-sdk-cloudwatchmetrics/src/main/java/com/amazonaws/metrics/package-info.java
COMPILED type(s)    
1 PROBLEM(s) detected 
     - Pb(323) The type package-info is already defined

The offending file contains:

/*
 * Copyright 2014-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *  http://aws.amazon.com/apache2.0
 *
 * or in the "license" file accompanying this file. This file 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.
 */
package com.amazonaws.metrics;

but weirdly enough it seems to be interpreted as an interface declaration. Here is the String value of the corresponding CompilationUnitDeclaration:

package com.amazonaws.metrics;
/**
 */
interface package-info {
}
nharrand commented 6 years ago

Nevermind. package com.amazonaws.metrics was indeed declared twice... :-(