Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SourcePosition from unexpected compilation unit #3133

Closed
moraispgsi opened this issue Sep 30, 2019 · 13 comments
Closed

SourcePosition from unexpected compilation unit #3133

moraispgsi opened this issue Sep 30, 2019 · 13 comments

Comments

@moraispgsi
Copy link

Hi there,

This is my first time posting an issue in this repository. I have been using Spoon for some time and it has been an enjoyable activity. I am currently using it in my master's thesis. I have reached a problem that I cannot solve by myself, so I require your assistance. A little bit of context... I am in the middle of the process o creating a gradle plugin to refactor android applications, powered by Spoon of course. In this particular experiment I used Slide an open-source android project. I gathered the dependencies automatically and give them to the spoon launcher classpath. When I try to run the launcher I get different errors depending on the PrettyPrinter that I use (I want to use SniperJavaPrettyPrinter).

Stacktrace with SniperJavaPrettyPrinter:

spoon.SpoonException: SourcePosition from unexpected compilation unit: (/repositories/Slide/app/src/main/java/me/ccrama/redditslide/UserSubscriptions.java:288) expected is: (/repositories/Slide/app/src/main/java/me/ccrama/redditslide/Activities/MainActivity.java:180)
	at spoon.support.sniper.internal.ElementSourceFragment.addChild(ElementSourceFragment.java:225)
	at spoon.support.sniper.internal.ElementSourceFragment.access$000(ElementSourceFragment.java:44)
	at spoon.support.sniper.internal.ElementSourceFragment$1.enter(ElementSourceFragment.java:145)
	at spoon.reflect.visitor.CtScanner.visitCtTypeReference(CtScanner.java:762)
	at spoon.support.reflect.reference.CtTypeReferenceImpl.accept(CtTypeReferenceImpl.java:73)
	at spoon.reflect.visitor.EarlyTerminatingScanner.doScan(EarlyTerminatingScanner.java:143)
	at spoon.reflect.visitor.EarlyTerminatingScanner.scan(EarlyTerminatingScanner.java:119)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:165)
	at spoon.reflect.visitor.EarlyTerminatingScanner.scan(EarlyTerminatingScanner.java:104)
	at spoon.reflect.visitor.CtScanner.visitCtFieldReference(CtScanner.java:447)
	at spoon.support.reflect.reference.CtFieldReferenceImpl.accept(CtFieldReferenceImpl.java:50)
	at spoon.reflect.visitor.EarlyTerminatingScanner.doScan(EarlyTerminatingScanner.java:143)
	at spoon.reflect.visitor.EarlyTerminatingScanner.scan(EarlyTerminatingScanner.java:119)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:165)
	at spoon.reflect.visitor.EarlyTerminatingScanner.scan(EarlyTerminatingScanner.java:104)
	at spoon.reflect.visitor.CtScanner.visitCtImport(CtScanner.java:903)
	at spoon.support.reflect.declaration.CtImportImpl.accept(CtImportImpl.java:68)
	at spoon.reflect.visitor.EarlyTerminatingScanner.doScan(EarlyTerminatingScanner.java:143)
	at spoon.reflect.visitor.EarlyTerminatingScanner.scan(EarlyTerminatingScanner.java:119)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:165)
	at spoon.reflect.visitor.EarlyTerminatingScanner.scan(EarlyTerminatingScanner.java:104)
	at spoon.reflect.visitor.EarlyTerminatingScanner.scan(EarlyTerminatingScanner.java:81)
	at spoon.reflect.visitor.EarlyTerminatingScanner.visitCtCompilationUnit(EarlyTerminatingScanner.java:154)
	at spoon.support.reflect.declaration.CtCompilationUnitImpl.accept(CtCompilationUnitImpl.java:406)
	at spoon.reflect.visitor.EarlyTerminatingScanner.doScan(EarlyTerminatingScanner.java:143)
	at spoon.reflect.visitor.EarlyTerminatingScanner.scan(EarlyTerminatingScanner.java:119)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:165)
	at spoon.reflect.visitor.EarlyTerminatingScanner.scan(EarlyTerminatingScanner.java:104)
	at spoon.support.sniper.internal.ElementSourceFragment.addTreeOfSourceFragmentsOfElement(ElementSourceFragment.java:169)
	at spoon.support.reflect.declaration.CtCompilationUnitImpl.getOriginalSourceFragment(CtCompilationUnitImpl.java:358)
	at spoon.support.modelobs.SourceFragmentCreator.onChange(SourceFragmentCreator.java:29)
	at spoon.support.modelobs.ChangeCollector$ChangeListener.onListDeleteAll(ChangeCollector.java:197)
	at spoon.support.util.ModelList.clear(ModelList.java:157)
	at spoon.support.util.ModelList.set(ModelList.java:53)
	at spoon.support.reflect.code.CtBlockImpl.setStatements(CtBlockImpl.java:161)
	at spoon.support.reflect.code.CtStatementImpl$InsertType$1.insertFromFirstStatement(CtStatementImpl.java:180)
	at spoon.support.reflect.code.CtStatementImpl$InsertVisitor.visitCtBlock(CtStatementImpl.java:92)
	at spoon.support.reflect.code.CtBlockImpl.accept(CtBlockImpl.java:55)
	at spoon.reflect.visitor.CtInheritanceScanner.scan(CtInheritanceScanner.java:173)
	at spoon.support.reflect.code.CtStatementImpl.insertBefore(CtStatementImpl.java:74)
	at spoon.support.reflect.code.CtStatementImpl.insertBefore(CtStatementImpl.java:55)
	at spoon.support.reflect.code.CtStatementImpl.insertBefore(CtStatementImpl.java:247)
	at com.leafactor.cli.rules.RecycleRefactoringRule.recycleVariableReassigned(RecycleRefactoringRule.java:238)
	at com.leafactor.cli.rules.RecycleRefactoringRule.processCase(RecycleRefactoringRule.java:308)
	at com.leafactor.cli.engine.Iteration.iterateBlock(Iteration.java:177)
	at com.leafactor.cli.rules.RecycleRefactoringRule.refactor(RecycleRefactoringRule.java:315)
	at com.leafactor.cli.rules.RecycleRefactoringRule.process(RecycleRefactoringRule.java:323)
	at com.leafactor.cli.rules.RecycleRefactoringRule.process(RecycleRefactoringRule.java:20)
	at spoon.support.visitor.ProcessingVisitor.scan(ProcessingVisitor.java:70)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:165)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:139)
	at spoon.reflect.visitor.CtScanner.visitCtPackage(CtScanner.java:641)
	at spoon.support.reflect.declaration.CtPackageImpl.accept(CtPackageImpl.java:87)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:173)
	at spoon.support.visitor.ProcessingVisitor.scan(ProcessingVisitor.java:66)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:165)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:139)
	at spoon.reflect.visitor.CtScanner.visitCtPackage(CtScanner.java:640)
	at spoon.support.reflect.declaration.CtPackageImpl.accept(CtPackageImpl.java:87)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:173)
	at spoon.support.visitor.ProcessingVisitor.scan(ProcessingVisitor.java:66)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:165)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:139)
	at spoon.reflect.visitor.CtScanner.visitCtPackage(CtScanner.java:640)
	at spoon.support.reflect.declaration.CtPackageImpl.accept(CtPackageImpl.java:87)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:173)
	at spoon.support.visitor.ProcessingVisitor.scan(ProcessingVisitor.java:66)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:165)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:139)
	at spoon.reflect.visitor.CtScanner.visitCtPackage(CtScanner.java:640)
	at spoon.support.reflect.declaration.CtPackageImpl.accept(CtPackageImpl.java:87)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:173)
	at spoon.support.visitor.ProcessingVisitor.scan(ProcessingVisitor.java:66)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:165)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:139)
	at spoon.reflect.visitor.CtScanner.visitCtPackage(CtScanner.java:640)
	at spoon.support.reflect.declaration.CtPackageImpl.accept(CtPackageImpl.java:87)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:173)
	at spoon.support.visitor.ProcessingVisitor.scan(ProcessingVisitor.java:66)
	at spoon.support.QueueProcessingManager.process(QueueProcessingManager.java:118)
	at spoon.support.QueueProcessingManager.process(QueueProcessingManager.java:137)
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.process(JDTBasedSpoonCompiler.java:186)
	at spoon.Launcher.process(Launcher.java:775)
	at spoon.Launcher.run(Launcher.java:719)
	at com.leafactor.cli.engine.CompilationUnitGroup.run(CompilationUnitGroup.java:152)
	at com.leafactor.gradle.plugin.Refactor.task(Refactor.java:140)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
	at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:46)
	at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
	at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
	at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:801)
	at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:768)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:131)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
	at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:120)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:99)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:77)
	at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
	at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:59)
	at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
	at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:59)
	at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101)
	at org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44)
	at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:91)
	at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62)
	at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:59)
	at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
	at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
	at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.run(EventFiringTaskExecuter.java:51)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
	at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:46)
	at org.gradle.execution.taskgraph.LocalTaskInfoExecutor.execute(LocalTaskInfoExecutor.java:42)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:277)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:262)
	at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:135)
	at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:130)
	at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.execute(DefaultTaskPlanExecutor.java:200)
	at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.executeWithWork(DefaultTaskPlanExecutor.java:191)
	at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.run(DefaultTaskPlanExecutor.java:130)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
	at java.lang.Thread.run(Thread.java:748)

Stacktrace without SniperJavaPrettyPrinter (I believe there is an similar closed issue that was closed prematurely, not sure if it is the same one. #2441):

spoon.SpoonException: spoon.SpoonException: Cannot create MethodTypingContext for method declared in different ClassTypingContext
	at spoon.Launcher.prettyprint(Launcher.java:785)
	at spoon.Launcher.run(Launcher.java:721)
	at com.leafactor.cli.engine.CompilationUnitGroup.run(CompilationUnitGroup.java:152)
	at com.leafactor.gradle.plugin.Refactor.task(Refactor.java:140)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
	at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:46)
	at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
	at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
	at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:801)
	at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:768)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:131)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
	at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:120)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:99)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:77)
	at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
	at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:59)
	at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
	at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:59)
	at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101)
	at org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44)
	at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:91)
	at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62)
	at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:59)
	at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
	at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
	at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.run(EventFiringTaskExecuter.java:51)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
	at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:46)
	at org.gradle.execution.taskgraph.LocalTaskInfoExecutor.execute(LocalTaskInfoExecutor.java:42)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:277)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:262)
	at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:135)
	at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:130)
	at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.execute(DefaultTaskPlanExecutor.java:200)
	at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.executeWithWork(DefaultTaskPlanExecutor.java:191)
	at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.run(DefaultTaskPlanExecutor.java:130)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
	at java.lang.Thread.run(Thread.java:748)
Caused by: spoon.SpoonException: Cannot create MethodTypingContext for method declared in different ClassTypingContext
	at spoon.support.visitor.MethodTypingContext.setMethod(MethodTypingContext.java:63)
	at spoon.support.visitor.ClassTypingContext.isSameSignature(ClassTypingContext.java:628)
	at spoon.support.visitor.ClassTypingContext.isSameSignature(ClassTypingContext.java:303)
	at spoon.support.reflect.declaration.CtTypeImpl$2.accept(CtTypeImpl.java:915)
	at spoon.support.reflect.declaration.CtTypeImpl$2.accept(CtTypeImpl.java:911)
	at spoon.reflect.visitor.chain.CtQueryImpl$OutputFunctionWrapper._accept(CtQueryImpl.java:459)
	at spoon.reflect.visitor.chain.CtQueryImpl$AbstractStep.accept(CtQueryImpl.java:307)
	at spoon.reflect.visitor.filter.AllTypeMembersFunction$1.accept(AllTypeMembersFunction.java:96)
	at spoon.reflect.visitor.filter.AllTypeMembersFunction$1.accept(AllTypeMembersFunction.java:79)
	at spoon.reflect.visitor.chain.CtQueryImpl$OutputFunctionWrapper._accept(CtQueryImpl.java:459)
	at spoon.reflect.visitor.chain.CtQueryImpl$AbstractStep.accept(CtQueryImpl.java:307)
	at spoon.reflect.visitor.filter.SuperInheritanceHierarchyFunction.sendResult(SuperInheritanceHierarchyFunction.java:360)
	at spoon.reflect.visitor.filter.SuperInheritanceHierarchyFunction.sendResultWithListener(SuperInheritanceHierarchyFunction.java:312)
	at spoon.reflect.visitor.filter.SuperInheritanceHierarchyFunction.visitSuperInterfaces(SuperInheritanceHierarchyFunction.java:299)
	at spoon.reflect.visitor.filter.SuperInheritanceHierarchyFunction.visitSuperClasses(SuperInheritanceHierarchyFunction.java:268)
	at spoon.reflect.visitor.filter.SuperInheritanceHierarchyFunction.apply(SuperInheritanceHierarchyFunction.java:250)
	at spoon.reflect.visitor.filter.SuperInheritanceHierarchyFunction.apply(SuperInheritanceHierarchyFunction.java:36)
	at spoon.reflect.visitor.chain.CtQueryImpl$LazyFunctionWrapper._accept(CtQueryImpl.java:492)
	at spoon.reflect.visitor.chain.CtQueryImpl$AbstractStep.accept(CtQueryImpl.java:307)
	at spoon.reflect.visitor.chain.CtQueryImpl.forEach(CtQueryImpl.java:93)
	at spoon.reflect.visitor.filter.AllTypeMembersFunction.apply(AllTypeMembersFunction.java:79)
	at spoon.reflect.visitor.filter.AllTypeMembersFunction.apply(AllTypeMembersFunction.java:28)
	at spoon.reflect.visitor.chain.CtQueryImpl$LazyFunctionWrapper._accept(CtQueryImpl.java:492)
	at spoon.reflect.visitor.chain.CtQueryImpl$AbstractStep.accept(CtQueryImpl.java:307)
	at spoon.reflect.visitor.chain.CtQueryImpl.forEach(CtQueryImpl.java:93)
	at spoon.support.reflect.declaration.CtTypeImpl.getAllMethods(CtTypeImpl.java:911)
	at spoon.reflect.visitor.ImportScannerImpl.isInCollisionWithLocalMethod(ImportScannerImpl.java:637)
	at spoon.reflect.visitor.ImportScannerImpl.addMethodImport(ImportScannerImpl.java:660)
	at spoon.reflect.visitor.ImportScannerImpl.visitCtExecutableReference(ImportScannerImpl.java:101)
	at spoon.support.reflect.reference.CtExecutableReferenceImpl.accept(CtExecutableReferenceImpl.java:75)
	at spoon.reflect.visitor.ImportScannerImpl.scan(ImportScannerImpl.java:138)
	at spoon.reflect.visitor.ImportScannerImpl.visitCtInvocation(ImportScannerImpl.java:262)
	at spoon.support.reflect.code.CtInvocationImpl.accept(CtInvocationImpl.java:44)
	at spoon.reflect.visitor.ImportScannerImpl.scan(ImportScannerImpl.java:138)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:165)
	at spoon.reflect.visitor.CtScanner.visitCtForEach(CtScanner.java:467)
	at spoon.support.reflect.code.CtForEachImpl.accept(CtForEachImpl.java:28)
	at spoon.reflect.visitor.ImportScannerImpl.scan(ImportScannerImpl.java:138)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:165)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:139)
	at spoon.reflect.visitor.CtScanner.visitCtBlock(CtScanner.java:294)
	at spoon.support.reflect.code.CtBlockImpl.accept(CtBlockImpl.java:55)
	at spoon.reflect.visitor.ImportScannerImpl.scan(ImportScannerImpl.java:138)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:165)
	at spoon.reflect.visitor.CtScanner.visitCtMethod(CtScanner.java:551)
	at spoon.support.reflect.declaration.CtMethodImpl.accept(CtMethodImpl.java:56)
	at spoon.reflect.visitor.ImportScannerImpl.scan(ImportScannerImpl.java:138)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:165)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:139)
	at spoon.reflect.visitor.CtScanner.visitCtClass(CtScanner.java:330)
	at spoon.reflect.visitor.ImportScannerImpl.visitCtClass(ImportScannerImpl.java:248)
	at spoon.support.reflect.declaration.CtClassImpl.accept(CtClassImpl.java:56)
	at spoon.reflect.visitor.ImportScannerImpl.scan(ImportScannerImpl.java:138)
	at spoon.reflect.visitor.ImportScannerImpl.computeImports(ImportScannerImpl.java:301)
	at spoon.reflect.visitor.DefaultJavaPrettyPrinter.computeImports(DefaultJavaPrettyPrinter.java:318)
	at spoon.reflect.visitor.DefaultJavaPrettyPrinter.calculate(DefaultJavaPrettyPrinter.java:1982)
	at spoon.support.JavaOutputProcessor.createJavaFile(JavaOutputProcessor.java:114)
	at spoon.support.JavaOutputProcessor.process(JavaOutputProcessor.java:150)
	at spoon.support.JavaOutputProcessor.process(JavaOutputProcessor.java:35)
	at spoon.support.visitor.ProcessingVisitor.scan(ProcessingVisitor.java:63)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:165)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:139)
	at spoon.reflect.visitor.CtScanner.visitCtPackage(CtScanner.java:641)
	at spoon.support.reflect.declaration.CtPackageImpl.accept(CtPackageImpl.java:87)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:173)
	at spoon.support.visitor.ProcessingVisitor.scan(ProcessingVisitor.java:66)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:165)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:139)
	at spoon.reflect.visitor.CtScanner.visitCtPackage(CtScanner.java:640)
	at spoon.support.reflect.declaration.CtPackageImpl.accept(CtPackageImpl.java:87)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:173)
	at spoon.support.visitor.ProcessingVisitor.scan(ProcessingVisitor.java:66)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:165)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:139)
	at spoon.reflect.visitor.CtScanner.visitCtPackage(CtScanner.java:640)
	at spoon.support.reflect.declaration.CtPackageImpl.accept(CtPackageImpl.java:87)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:173)
	at spoon.support.visitor.ProcessingVisitor.scan(ProcessingVisitor.java:66)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:165)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:139)
	at spoon.reflect.visitor.CtScanner.visitCtPackage(CtScanner.java:640)
	at spoon.support.reflect.declaration.CtPackageImpl.accept(CtPackageImpl.java:87)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:173)
	at spoon.support.visitor.ProcessingVisitor.scan(ProcessingVisitor.java:66)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:165)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:139)
	at spoon.reflect.visitor.CtScanner.visitCtPackage(CtScanner.java:640)
	at spoon.support.reflect.declaration.CtPackageImpl.accept(CtPackageImpl.java:87)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:173)
	at spoon.support.visitor.ProcessingVisitor.scan(ProcessingVisitor.java:66)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:165)
	at spoon.reflect.visitor.CtScanner.visitCtModule(CtScanner.java:915)
	at spoon.reflect.factory.ModuleFactory$CtUnnamedModule.accept(ModuleFactory.java:94)
	at spoon.reflect.visitor.CtScanner.scan(CtScanner.java:173)
	at spoon.support.visitor.ProcessingVisitor.scan(ProcessingVisitor.java:66)
	at spoon.support.QueueProcessingManager.process(QueueProcessingManager.java:118)
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.generateProcessedSourceFilesUsingTypes(JDTBasedSpoonCompiler.java:480)
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.generateProcessedSourceFiles(JDTBasedSpoonCompiler.java:201)
	at spoon.Launcher.prettyprint(Launcher.java:783)
	... 55 more

Any help would be appreciated, thank you.

@monperrus
Copy link
Collaborator

monperrus commented Sep 30, 2019 via email

@moraispgsi
Copy link
Author

I have tried with 7.6.0-beta-4 and 7.5.0 from the maven repository. Yes, I can try.

@moraispgsi
Copy link
Author

Well, the master branch is on 7.6.0-beta-4 so I guess it failed.

@moraispgsi
Copy link
Author

Anything else I can do?

@tdurieux
Copy link
Collaborator

Can you try the snapshot version?

<dependencies>
    <dependency>
        <groupId>fr.inria.gforge.spoon</groupId>
        <artifactId>spoon-core</artifactId>
        <version>7.6.0-SNAPSHOT</version>
    </dependency>
</dependencies>
<repositories>
    <repository>
      <id>maven.inria.fr-snapshot</id>
      <name>Maven Repository for Spoon Snapshots</name>
      <url>http://maven.inria.fr/artifactory/spoon-public-snapshot</url>
    </repository>
</repositories>

I also faced a lot of problem with SniperJavaPrettyPrinter, it does not surprise me that you face this problem.

@moraispgsi
Copy link
Author

I will try, thanks for the suggestion.

@moraispgsi
Copy link
Author

Now I am getting another error:

spoon.SpoonException: Missing SourceFragmentContext
	at spoon.support.sniper.SniperJavaPrettyPrinter.onPrintEvent(SniperJavaPrettyPrinter.java:214)
	at spoon.support.sniper.SniperJavaPrettyPrinter.scan(SniperJavaPrettyPrinter.java:186)
	at spoon.support.sniper.SniperJavaPrettyPrinter.scan(SniperJavaPrettyPrinter.java:44)
	at spoon.support.reflect.declaration.CtElementImpl.toString(CtElementImpl.java:312)
	at java.lang.String.valueOf(String.java:2994)
	at java.lang.StringBuilder.append(StringBuilder.java:131)
	at spoon.support.compiler.jdt.JDTTreeBuilderHelper.handleImplicit(JDTTreeBuilderHelper.java:519)
	at spoon.support.compiler.jdt.JDTTreeBuilderHelper.handleImplicit(JDTTreeBuilderHelper.java:484)
	at spoon.support.compiler.jdt.ReferenceBuilder.getTypeReference(ReferenceBuilder.java:508)
	at spoon.support.compiler.jdt.ReferenceBuilder.buildTypeReference(ReferenceBuilder.java:130)
	at spoon.support.compiler.jdt.ReferenceBuilder.buildTypeReference(ReferenceBuilder.java:124)
	at spoon.support.compiler.jdt.ReferenceBuilder.buildTypeReference(ReferenceBuilder.java:142)
	at spoon.support.compiler.jdt.JDTTreeBuilder.visit(JDTTreeBuilder.java:1511)
	at org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference.traverse(QualifiedTypeReference.java:212)
	at org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression.traverse(QualifiedAllocationExpression.java:682)
	at org.eclipse.jdt.internal.compiler.ast.MessageSend.traverse(MessageSend.java:1107)
	at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.traverse(MethodDeclaration.java:365)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.traverse(TypeDeclaration.java:1415)
	at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse(CompilationUnitDeclaration.java:812)
	at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.traverse(CompilationUnitDeclaration.java:773)
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.lambda$buildModel$0(JDTBasedSpoonCompiler.java:423)
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.forEachCompilationUnit(JDTBasedSpoonCompiler.java:448)
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.buildModel(JDTBasedSpoonCompiler.java:421)
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.buildUnitsAndModel(JDTBasedSpoonCompiler.java:365)
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.buildSources(JDTBasedSpoonCompiler.java:330)
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.build(JDTBasedSpoonCompiler.java:113)
	at spoon.support.compiler.jdt.JDTBasedSpoonCompiler.build(JDTBasedSpoonCompiler.java:96)
	at spoon.Launcher.buildModel(Launcher.java:770)
	at spoon.Launcher.run(Launcher.java:721)
	at com.leafactor.cli.engine.CompilationUnitGroup.run(CompilationUnitGroup.java:152)
	at com.leafactor.gradle.plugin.Refactor.task(Refactor.java:140)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
	at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:46)
	at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
	at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
	at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:801)
	at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:768)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:131)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
	at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:120)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:99)
	at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:77)
	at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
	at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:59)
	at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
	at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:59)
	at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101)
	at org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44)
	at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:91)
	at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62)
	at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:59)
	at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
	at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
	at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.run(EventFiringTaskExecuter.java:51)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174)
	at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
	at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
	at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:46)
	at org.gradle.execution.taskgraph.LocalTaskInfoExecutor.execute(LocalTaskInfoExecutor.java:42)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:277)
	at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:262)
	at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:135)
	at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:130)
	at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.execute(DefaultTaskPlanExecutor.java:200)
	at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.executeWithWork(DefaultTaskPlanExecutor.java:191)
	at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.run(DefaultTaskPlanExecutor.java:130)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
	at java.lang.Thread.run(Thread.java:748)

@moraispgsi
Copy link
Author

Are there any other suggestions? I really need to get this fixed. I am making myself available to help if necessary.

@monperrus
Copy link
Collaborator

would you be able to create a pull-request that reproduces the problem in a small test case? that would be super useful!

@moraispgsi
Copy link
Author

I will try to create it in the weekend.

@monperrus
Copy link
Collaborator

monperrus commented Oct 2, 2019 via email

moraispgsi pushed a commit to TQRG/spoon that referenced this issue Oct 5, 2019
@moraispgsi
Copy link
Author

I was able to make the PR. I had a problem trying to catch the error, it shows in the console, however, I am not able to try-catch it.

@monperrus
Copy link
Collaborator

closed per #3137

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants