Repository: joernio/joern (scala)

Issue:
Java Parser failing with ERROR on a source file
While using the new Javasrc2cpg frontend on tarpit-java, the Java Parser is failing with following error. 

```
joern> importCode.java("/home/suchakra/Projects/tarpit-java/src", "tarpit-src") 
Creating project `tarpit-src` for code at `/home/suchakra/Projects/tarpit-java/src`
2022-05-11 10:50:43.750 ERROR AstCreator: Parsing file /home/suchakra/Projects/tarpit-java/src/main/java/io/shiftleft/tarpit/Insider.java failed with scala.MatchError: WildcardUsage{type=null, boundedType=null} (of class com.github.javaparser.resolution.types.ResolvedWildcard)
moving cpg.bin.zip to cpg.bin because it is already a database file
Creating working copy of CPG to be safe
```

As a consequence only 3 files are included int eh resulting CPG and much of the graph is missing important nodes. 

### Additional Info
#### Joern Version 
v1.1.796

#### JVM 
```
openjdk version "1.8.0_312"
OpenJDK Runtime Environment (build 1.8.0_312-8u312-b07-0ubuntu1~20.04-b07)
OpenJDK 64-Bit Server VM (build 25.312-b07, mixed mode)
```

Pull request:
Fixes https://github.com/joernio/joern/issues/1385.

Patch:
diff --git a/joern-cli/frontends/javasrc2cpg/src/main/scala/io/joern/javasrc2cpg/util/TypeInfoCalculator.scala b/joern-cli/frontends/javasrc2cpg/src/main/scala/io/joern/javasrc2cpg/util/TypeInfoCalculator.scala
index 29be0c0fa605..6efa91002c1d 100644
--- a/joern-cli/frontends/javasrc2cpg/src/main/scala/io/joern/javasrc2cpg/util/TypeInfoCalculator.scala
+++ b/joern-cli/frontends/javasrc2cpg/src/main/scala/io/joern/javasrc2cpg/util/TypeInfoCalculator.scala
@@ -1,6 +1,6 @@
 package io.joern.javasrc2cpg.util
 
-import com.github.javaparser.ast.`type`.{PrimitiveType, Type}
+import com.github.javaparser.ast.`type`.{PrimitiveType, Type, WildcardType}
 import com.github.javaparser.resolution.SymbolResolver
 import com.github.javaparser.resolution.declarations.{
   ResolvedDeclaration,
@@ -16,19 +16,22 @@ import com.github.javaparser.resolution.types.{
   ResolvedReferenceType,
   ResolvedType,
   ResolvedTypeVariable,
-  ResolvedVoidType
+  ResolvedVoidType,
+  ResolvedWildcard
 }
 import com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserClassDeclaration
 import com.github.javaparser.symbolsolver.model.typesystem.{LazyType, NullType}
 import com.github.javaparser.symbolsolver.reflectionmodel.{ReflectionClassDeclaration, ReflectionTypeParameter}
 import io.joern.javasrc2cpg.util.TypeInfoCalculator.{TypeConstants, TypeNameConstants}
 import io.joern.x2cpg.datastructures.Global
+import org.slf4j.LoggerFactory
 
 import scala.collection.mutable
 import scala.jdk.CollectionConverters._
 import scala.util.Try
 
 class TypeInfoCalculator(global: Global, symbolResolver: SymbolResolver) {
+  private val logger = LoggerFactory.getLogger(this.getClass)
   def name(typ: ResolvedType): String = {
     nameOrFullName(typ, false)
   }
@@ -55,9 +58,23 @@ class TypeInfoCalculator(global: Global, symbolResolver: SymbolResolver) {
         val extendsBoundOption = typeVariable.asTypeParameter().getBounds.asScala.find(_.isExtends)
         extendsBoundOption
           .map(bound => fullName(bound.getType))
-          .getOrElse(if (fullyQualified) TypeConstants.Object else TypeNameConstants.Object)
+          .getOrElse(objectType(fullyQualified))
       case lambdaConstraintType: ResolvedLambdaConstraintType =>
         nameOrFullName(lambdaConstraintType.getBound, fullyQualified)
+      case wildcardType: ResolvedWildcard =>
+        if (wildcardType.isBounded) {
+          nameOrFullName(wildcardType.getBoundedType, fullyQualified)
+        } else {
+          objectType(fullyQualified)
+        }
+    }
+  }
+
+  private def objectType(fullyQualified: Boolean): String = {
+    if (fullyQualified) {
+      TypeConstants.Object
+    } else {
+      TypeNameConstants.Object
     }
   }
 


Test patch:
diff --git a/joern-cli/frontends/javasrc2cpg/src/test/scala/io/joern/javasrc2cpg/querying/TypeTests.scala b/joern-cli/frontends/javasrc2cpg/src/test/scala/io/joern/javasrc2cpg/querying/TypeTests.scala
index 3132b0cae0de..6453c1a5878b 100644
--- a/joern-cli/frontends/javasrc2cpg/src/test/scala/io/joern/javasrc2cpg/querying/TypeTests.scala
+++ b/joern-cli/frontends/javasrc2cpg/src/test/scala/io/joern/javasrc2cpg/querying/TypeTests.scala
@@ -1,11 +1,63 @@
 package io.joern.javasrc2cpg.querying
 
-import io.joern.javasrc2cpg.testfixtures.JavaSrcCodeToCpgFixture
+import io.joern.javasrc2cpg.testfixtures.{JavaSrcCode2CpgFixture, JavaSrcCodeToCpgFixture}
 import io.shiftleft.codepropertygraph.generated.nodes.Identifier
 import io.shiftleft.proto.cpg.Cpg.DispatchTypes
 import io.shiftleft.semanticcpg.language._
 import org.scalatest.Ignore
 
+class NewTypeTests extends JavaSrcCode2CpgFixture {
+  "processing wildcard types should not crash (smoke test)" when {
+    "the type is unbounded" in {
+      val cpg = code("""
+          |import java.net.URLClassLoader;
+          |
+          |class Foo {
+          |  public void foo(URIClassLoader classLoader) {
+          |    Class<?> cls = Class.forName("testName", true, classLoader);
+          |    Object instance = cls.newInstance();
+          |  }
+          |}
+          |""".stripMargin)
+
+      cpg.identifier.name("instance").typeFullName.head shouldBe "java.lang.Object"
+      cpg.call.name("newInstance").head.signature shouldBe "java.lang.Object()"
+    }
+
+    "there is a lower bound" in {
+      val cpg = code("""
+          |import java.net.URLClassLoader;
+          |
+          |class Foo {
+          |  public void foo(URIClassLoader classLoader) {
+          |    Class<? super Integer> cls = Class.forName("testName", true, classLoader);
+          |    Object instance = cls.newInstance();
+          |  }
+          |}
+          |""".stripMargin)
+
+      cpg.identifier.name("instance").typeFullName.head shouldBe "java.lang.Object"
+      cpg.call.name("newInstance").head.signature shouldBe "java.lang.Object()"
+    }
+
+    "there is an upper bound" in {
+      val cpg = code("""
+          |import java.net.URLClassLoader;
+          |
+          |class Foo {
+          |  public void foo(URIClassLoader classLoader) {
+          |    Class<? extends Number> cls = Class.forName("testName", true, classLoader);
+          |    Object instance = cls.newInstance();
+          |  }
+          |}
+          |""".stripMargin)
+
+      cpg.identifier.name("instance").typeFullName.head shouldBe "java.lang.Object"
+      cpg.call.name("newInstance").head.signature shouldBe "java.lang.Object()"
+    }
+  }
+}
+
 class TypeTests extends JavaSrcCodeToCpgFixture {
 
   override val code: String =