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

[javasrc2cpg] Fix UnsupportedOperationException when getting type of SingleMemberAnnotationExpr #4911

Open
johannescoetzee opened this issue Sep 11, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@johannescoetzee
Copy link
Contributor

From logs for creating a CPG for JavaParser (but the same happens for many projects):

[DEBUG] tryWithFailureLogging encountered exception
java.lang.UnsupportedOperationException: com.github.javaparser.ast.expr.SingleMemberAnnotationExpr
	at com.github.javaparser.symbolsolver.javaparsermodel.DefaultVisitorAdapter.visit(DefaultVisitorAdapter.java:309) ~[com.github.javaparser.javaparser-symbol-solver-core-3.26.2.jar:?]
	at com.github.javaparser.symbolsolver.javaparsermodel.DefaultVisitorAdapter.visit(DefaultVisitorAdapter.java:36) ~[com.github.javaparser.javaparser-symbol-solver-core-3.26.2.jar:?]
	at com.github.javaparser.ast.expr.SingleMemberAnnotationExpr.accept(SingleMemberAnnotationExpr.java:69) ~[com.github.javaparser.javaparser-core-3.26.2.jar:?]
	at com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFacade.getTypeConcrete(JavaParserFacade.java:533) ~[com.github.javaparser.javaparser-symbol-solver-core-3.26.2.jar:?]
	at com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFacade.getType(JavaParserFacade.java:394) ~[com.github.javaparser.javaparser-symbol-solver-core-3.26.2.jar:?]
	at com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFacade.getType(JavaParserFacade.java:359) ~[com.github.javaparser.javaparser-symbol-solver-core-3.26.2.jar:?]
	at com.github.javaparser.symbolsolver.JavaSymbolSolver.calculateType(JavaSymbolSolver.java:443) ~[com.github.javaparser.javaparser-symbol-solver-core-3.26.2.jar:?]
	at com.github.javaparser.ast.expr.Expression.calculateResolvedType(Expression.java:578) ~[com.github.javaparser.javaparser-core-3.26.2.jar:?]
	at io.joern.javasrc2cpg.astcreation.AstCreator.$anonfun$6(AstCreator.scala:311) ~[io.joern.javasrc2cpg-4.0.69+2-1ddddd18+20240911-1301.jar:4.0.69+2-1ddddd18+20240911-1301]
	at scala.util.Try$.apply(Try.scala:210) ~[org.scala-lang.scala-library-2.13.12.jar:?]
	at io.joern.javasrc2cpg.astcreation.AstCreator.tryWithSafeStackOverflow(AstCreator.scala:255) ~[io.joern.javasrc2cpg-4.0.69+2-1ddddd18+20240911-1301.jar:4.0.69+2-1ddddd18+20240911-1301]
	at io.joern.javasrc2cpg.astcreation.AstCreator.expressionReturnTypeFullName(AstCreator.scala:311) ~[io.joern.javasrc2cpg-4.0.69+2-1ddddd18+20240911-1301.jar:4.0.69+2-1ddddd18+20240911-1301]
	at io.joern.javasrc2cpg.astcreation.declarations.AstForTypeDeclsCreator.astForAnnotationExpr(AstForTypeDeclsCreator.scala:458) ~[io.joern.javasrc2cpg-4.0.69+2-1ddddd18+20240911-1301.jar:4.0.69+2-1ddddd18+20240911-1301]
	at io.joern.javasrc2cpg.astcreation.declarations.AstForTypeDeclsCreator.astForAnnotationExpr$(AstForTypeDeclsCreator.scala:90) ~[io.joern.javasrc2cpg-4.0.69+2-1ddddd18+20240911-1301.jar:4.0.69+2-1ddddd18+20240911-1301]
	at io.joern.javasrc2cpg.astcreation.AstCreator.astForAnnotationExpr(AstCreator.scala:85) ~[io.joern.javasrc2cpg-4.0.69+2-1ddddd18+20240911-1301.jar:4.0.69+2-1ddddd18+20240911-1301]
	at io.joern.javasrc2cpg.astcreation.declarations.AstForTypeDeclsCreator.$anonfun$6(AstForTypeDeclsCreator.scala:179) ~[io.joern.javasrc2cpg-4.0.69+2-1ddddd18+20240911-1301.jar:4.0.69+2-1ddddd18+20240911-1301]
	at scala.collection.StrictOptimizedIterableOps.map(StrictOptimizedIterableOps.scala:100) ~[org.scala-lang.scala-library-2.13.12.jar:?]
	at scala.collection.StrictOptimizedIterableOps.map$(StrictOptimizedIterableOps.scala:87) ~[org.scala-lang.scala-library-2.13.12.jar:?]
	at scala.collection.convert.JavaCollectionWrappers$JListWrapper.map(JavaCollectionWrappers.scala:138) ~[org.scala-lang.scala-library-2.13.12.jar:?]
	at io.joern.javasrc2cpg.astcreation.declarations.AstForTypeDeclsCreator.astForTypeDeclaration(AstForTypeDeclsCreator.scala:179) ~[io.joern.javasrc2cpg-4.0.69+2-1ddddd18+20240911-1301.jar:4.0.69+2-1ddddd18+20240911-1301]
	at io.joern.javasrc2cpg.astcreation.declarations.AstForTypeDeclsCreator.astForTypeDeclaration$(AstForTypeDeclsCreator.scala:90) ~[io.joern.javasrc2cpg-4.0.69+2-1ddddd18+20240911-1301.jar:4.0.69+2-1ddddd18+20240911-1301]
	at io.joern.javasrc2cpg.astcreation.AstCreator.astForTypeDeclaration(AstCreator.scala:85) ~[io.joern.javasrc2cpg-4.0.69+2-1ddddd18+20240911-1301.jar:4.0.69+2-1ddddd18+20240911-1301]
	at io.joern.javasrc2cpg.astcreation.AstCreator.$anonfun$4(AstCreator.scala:215) ~[io.joern.javasrc2cpg-4.0.69+2-1ddddd18+20240911-1301.jar:4.0.69+2-1ddddd18+20240911-1301]
	at scala.collection.StrictOptimizedIterableOps.map(StrictOptimizedIterableOps.scala:100) [org.scala-lang.scala-library-2.13.12.jar:?]
	at scala.collection.StrictOptimizedIterableOps.map$(StrictOptimizedIterableOps.scala:87) [org.scala-lang.scala-library-2.13.12.jar:?]
	at scala.collection.convert.JavaCollectionWrappers$JListWrapper.map(JavaCollectionWrappers.scala:138) [org.scala-lang.scala-library-2.13.12.jar:?]
	at io.joern.javasrc2cpg.astcreation.AstCreator.astForTranslationUnit(AstCreator.scala:215) [io.joern.javasrc2cpg-4.0.69+2-1ddddd18+20240911-1301.jar:4.0.69+2-1ddddd18+20240911-1301]
	at io.joern.javasrc2cpg.astcreation.AstCreator.createAst(AstCreator.scala:114) [io.joern.javasrc2cpg-4.0.69+2-1ddddd18+20240911-1301.jar:4.0.69+2-1ddddd18+20240911-1301]
	at io.joern.javasrc2cpg.passes.AstCreationPass.runOnPart(AstCreationPass.scala:66) [io.joern.javasrc2cpg-4.0.69+2-1ddddd18+20240911-1301.jar:4.0.69+2-1ddddd18+20240911-1301]
	at io.joern.javasrc2cpg.passes.AstCreationPass.runOnPart(AstCreationPass.scala:51) [io.joern.javasrc2cpg-4.0.69+2-1ddddd18+20240911-1301.jar:4.0.69+2-1ddddd18+20240911-1301]
	at io.shiftleft.passes.ForkJoinParallelCpgPass$$anon$2.accept(CpgPass.scala:129) [io.shiftleft.codepropertygraph_3-1.7.8.jar:1.7.8]
	at io.shiftleft.passes.ForkJoinParallelCpgPass$$anon$2.accept(CpgPass.scala:128) [io.shiftleft.codepropertygraph_3-1.7.8.jar:1.7.8]
	at java.util.stream.ReduceOps$4ReducingSink.accept(ReduceOps.java:220) [?:?]
	at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:1024) [?:?]
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) [?:?]
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) [?:?]
	at java.util.stream.ReduceOps$ReduceTask.doLeaf(ReduceOps.java:960) [?:?]
	at java.util.stream.ReduceOps$ReduceTask.doLeaf(ReduceOps.java:934) [?:?]
	at java.util.stream.AbstractTask.compute(AbstractTask.java:327) [?:?]
	at java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:754) [?:?]
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387) [?:?]
	at java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312) [?:?]
	at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843) [?:?]
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808) [?:?]
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188) [?:?]

I'm creating an issue here since I'm not yet sure if it's a JavaParser limitation or whether we're using it wrong.

@johannescoetzee johannescoetzee added the bug Something isn't working label Sep 11, 2024
@johannescoetzee johannescoetzee self-assigned this Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant