Skip to content

[BUG]: "this" becomes "super" after Spoon analysis #2381

@MingWEN-CS

Description

@MingWEN-CS

I have encountered an strange bug when using Spoon, either with version 6.2 or 7.0

The source code I am analyzing is https://github.com/apache/commons-math/blob/master/src/main/java/org/apache/commons/math4/linear/ArrayRealVector.java

After building the model using the following code on the above source file:

Launcher launcher = new Launcher();
launcher.addInputResource(targetClassLocation);
launcher.setSourceOutputDirectory(location + File.separator + "spoon");
launcher.getEnvironment().setSourceClasspath(classPath.split("::"));
launcher.buildModel();
List<CtElement> originalClasses = launcher.getFactory().Package().getRootPackage() .getElements(new TypeFilter(CtClass.class));
WriteLinesToFile.writeToFiles(originalClasses.get(0).toString(), "ArrayRealVector.java");

The output file "ArrayRealVector.java" is different with the original source file "ArrayRealVector.java".
The key work this becomes super.

Original:
image

Analyzed:

image

I do not know how this would happen, which seems to be a serious bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions