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

NPE in CtTypeReferenceImpl#isInSamePackage in noclasspath #2845

Closed
tdurieux opened this issue Dec 20, 2018 · 3 comments · Fixed by #3032
Closed

NPE in CtTypeReferenceImpl#isInSamePackage in noclasspath #2845

tdurieux opened this issue Dec 20, 2018 · 3 comments · Fixed by #3032
Labels

Comments

@tdurieux
Copy link
Collaborator

tdurieux commented Dec 20, 2018

Version 7.2.0 and 7.3.0-SNAPSHOT

I receive this exception when I try to run Spoon in noclasspath:

Exception in thread "main" spoon.SpoonException: Printing of spoon.support.reflect.code.CtThisAccessImpl on path 
	CtClassImpl:InCondition
	CtConstructorImpl:<init>
	CtBlockImpl
	CtAssignmentImpl
	CtFieldWriteImpl
	CtThisAccessImpl
at position (/home/tdurieux/git/patch-clustering/Expression.java:348) failed
	at spoon.reflect.visitor.DefaultJavaPrettyPrinter.scan(DefaultJavaPrettyPrinter.java:354)
	at add.features.detector.repairpatterns.CopyPasteDetector$1.scan(CopyPasteDetector.java:67)
	at spoon.reflect.visitor.DefaultJavaPrettyPrinter.printCtFieldAccess(DefaultJavaPrettyPrinter.java:871)
	at spoon.reflect.visitor.DefaultJavaPrettyPrinter.visitCtFieldWrite(DefaultJavaPrettyPrinter.java:804)
	at spoon.support.reflect.code.CtFieldWriteImpl.accept(CtFieldWriteImpl.java:27)
	at spoon.reflect.visitor.DefaultJavaPrettyPrinter.scan(DefaultJavaPrettyPrinter.java:345)
	at add.features.detector.repairpatterns.CopyPasteDetector$1.scan(CopyPasteDetector.java:59)
	at spoon.reflect.visitor.DefaultJavaPrettyPrinter.visitCtAssignment(DefaultJavaPrettyPrinter.java:494)
	at spoon.support.reflect.code.CtAssignmentImpl.accept(CtAssignmentImpl.java:55)
	at spoon.reflect.visitor.DefaultJavaPrettyPrinter.scan(DefaultJavaPrettyPrinter.java:345)
	at add.features.detector.repairpatterns.CopyPasteDetector$1.scan(CopyPasteDetector.java:67)
	at spoon.reflect.visitor.ElementPrinterHelper.writeStatement(ElementPrinterHelper.java:182)
	at spoon.reflect.visitor.DefaultJavaPrettyPrinter.visitCtBlock(DefaultJavaPrettyPrinter.java:526)
	at spoon.support.reflect.code.CtBlockImpl.accept(CtBlockImpl.java:48)
	at spoon.reflect.visitor.DefaultJavaPrettyPrinter.scan(DefaultJavaPrettyPrinter.java:345)
	at add.features.detector.repairpatterns.CopyPasteDetector$1.scan(CopyPasteDetector.java:67)
	at spoon.reflect.visitor.DefaultJavaPrettyPrinter.visitCtConstructor(DefaultJavaPrettyPrinter.java:704)
	at spoon.support.reflect.declaration.CtConstructorImpl.accept(CtConstructorImpl.java:57)
	at spoon.reflect.visitor.DefaultJavaPrettyPrinter.scan(DefaultJavaPrettyPrinter.java:345)
	at add.features.detector.repairpatterns.CopyPasteDetector$1.scan(CopyPasteDetector.java:67)
	at spoon.reflect.visitor.ElementPrinterHelper.writeElementList(ElementPrinterHelper.java:196)
	at spoon.reflect.visitor.DefaultJavaPrettyPrinter.visitCtClass(DefaultJavaPrettyPrinter.java:622)
	at spoon.support.reflect.declaration.CtClassImpl.accept(CtClassImpl.java:68)
	at spoon.reflect.visitor.DefaultJavaPrettyPrinter.scan(DefaultJavaPrettyPrinter.java:345)
	at add.features.detector.repairpatterns.CopyPasteDetector$1.scan(CopyPasteDetector.java:67)
	at add.features.detector.repairpatterns.CopyPasteDetector.detect(CopyPasteDetector.java:75)
	at add.features.detector.repairpatterns.RepairPatternDetector.analyze(RepairPatternDetector.java:45)
	at add.features.detector.repairpatterns.RepairPatternDetector.analyze(RepairPatternDetector.java:15)
	at add.main.Launcher.execute(Launcher.java:154)
	at add.main.Launcher.main(Launcher.java:167)
Caused by: java.lang.NullPointerException
	at spoon.support.reflect.reference.CtTypeReferenceImpl.isInSamePackage(CtTypeReferenceImpl.java:665)
	at spoon.support.reflect.reference.CtTypeReferenceImpl.canAccess(CtTypeReferenceImpl.java:656)
	at spoon.support.reflect.reference.CtTypeReferenceImpl.getAccessType(CtTypeReferenceImpl.java:691)
	at spoon.reflect.visitor.DefaultJavaPrettyPrinter.visitCtTypeReference(DefaultJavaPrettyPrinter.java:1824)
	at spoon.reflect.visitor.DefaultJavaPrettyPrinter.visitCtTypeReferenceWithoutGenerics(DefaultJavaPrettyPrinter.java:1808)
	at spoon.reflect.visitor.DefaultJavaPrettyPrinter.visitCtThisAccess(DefaultJavaPrettyPrinter.java:948)
	at spoon.support.reflect.code.CtThisAccessImpl.accept(CtThisAccessImpl.java:28)
	at spoon.reflect.visitor.DefaultJavaPrettyPrinter.scan(DefaultJavaPrettyPrinter.java:345)
	... 29 more
@monperrus
Copy link
Collaborator

It seems it is an error happening while calling toString.

Do you call toString at /home/tdurieux/git/patch-clustering/Expression.java:348?

@tdurieux
Copy link
Collaborator Author

It is hard to say because the file/home/tdurieux/git/patch-clustering/Expression.java:348 does not exist and I have no file called Expression in my project.
But it is maybe related to me useage of the DefaultJavaPrettyPrinter : https://github.com/lascam-UFU/automatic-diff-dissection/blob/master/src/main/java/add/features/detector/repairpatterns/CopyPasteDetector.java#L39

@monperrus monperrus added the bug label Feb 19, 2019
@monperrus
Copy link
Collaborator

do you have an option to reproduce it in CI?

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

Successfully merging a pull request may close this issue.

2 participants