javaparser-visited icon indicating copy to clipboard operation
javaparser-visited copied to clipboard

ResolveTypeInContext sample throws an exception

Open peteruhnak opened this issue 4 years ago • 0 comments
trafficstars

The example for ResolveTypeInContext in the book throws an exception

reflectionTypeSolver.setParent(reflectionTypeSolver);

Exception in thread "main" java.lang.IllegalStateException: The parent of this TypeSolver cannot be itself.
	at com.github.javaparser.symbolsolver.resolution.typesolvers.ClassLoaderTypeSolver.setParent(ClassLoaderTypeSolver.java:60)

Presumably the line should be removed (as the parent is overridden anyway from combinedSolver.add(reflectionTypeSolver)

(also in the same example Navigator.findNodeOfGivenClass(cu, FieldDeclaration.class); is deprecated

peteruhnak avatar Oct 24 '21 13:10 peteruhnak