anon-iclr-submission/benchname-bug-localization huggingface dataset:
Repository: fraunhofer-aisec/cpg
Issue: Bug in ExpressionHandler::handleMethodCallExpression

[...] I just tried CPG version 3.3.1. There, another error occurred to me:
```
 Unable to calculate the type of a parameter of a method call. Method call: addParameter("label", findString(label)), Parameter: findString(label)
```

The function is indeed not defined but this wasn't an issue with CPG version 3.2.0 (I guess that's because of the updated JavaParser). 
Could the flag "failOnError" in the TranslationConfiguration Class perhaps be used to circumvent this issue in the future?

Nevertheless, after removing the undefined methods, the CFG pass is still stuck with CPG version 3.3.1 . 
Strangely as before, the removal of the Setters causes the CFG pass to terminate.

_Originally posted by @anon767 in https://github.com/Fraunhofer-AISEC/cpg/issues/307#issuecomment-763588895_

Changed files:
src/main/java/de/fraunhofer/aisec/cpg/frontends/java/ExpressionHandler.java

diff --git a/src/main/java/de/fraunhofer/aisec/cpg/frontends/java/ExpressionHandler.java b/src/main/java/de/fraunhofer/aisec/cpg/frontends/java/ExpressionHandler.java
index 0d49a9f43..536403945 100644
--- a/src/main/java/de/fraunhofer/aisec/cpg/frontends/java/ExpressionHandler.java
+++ b/src/main/java/de/fraunhofer/aisec/cpg/frontends/java/ExpressionHandler.java
@@ -670,7 +670,10 @@ public class ExpressionHandler extends Handler<Statement, Expression, JavaLangua
       resolved = methodCallExpr.resolve();
       isStatic = resolved.isStatic();
       typeString = resolved.getReturnType().describe();
-    } catch (UnsolvedSymbolException | NoClassDefFoundError ignored) {
+    } catch (NoClassDefFoundError | RuntimeException ignored) {
+      // Unfortunately, JavaParser also throws a simple RuntimeException instead of an
+      // UnsolvedSymbolException within resolve() if it fails to resolve it under certain
+      // circumstances, we catch all that and continue on our own
       log.debug("Could not resolve method {}", methodCallExpr);
     }
Repository: fraunhofer-aisec/cpg
Issue: Nodes referring to Java fields are missing parent and location 

The following snippet instantiates a field `cipher` in an incorrect/unsafe way. However, the node referring to `cipher` does not have a `parent`, nor a `range` and consequently no `location`.

```
public class SealObject {
    private final Cipher cipher;

    public SealObject(String Password) throws Exception  {
        cipher = Cipher.getInstance("SomeUnsafeCipher");
    }
}
```

Changed files:
src/main/java/de/fraunhofer/aisec/cpg/frontends/java/ExpressionHandler.java

diff --git a/src/main/java/de/fraunhofer/aisec/cpg/frontends/java/ExpressionHandler.java b/src/main/java/de/fraunhofer/aisec/cpg/frontends/java/ExpressionHandler.java
index 716907aaf..ea638a22f 100644
--- a/src/main/java/de/fraunhofer/aisec/cpg/frontends/java/ExpressionHandler.java
+++ b/src/main/java/de/fraunhofer/aisec/cpg/frontends/java/ExpressionHandler.java
@@ -492,7 +492,11 @@ public class ExpressionHandler
         if (!field.isStatic()) {
           // convert to FieldAccessExpr
           FieldAccessExpr fieldAccessExpr = new FieldAccessExpr(new ThisExpr(), field.getName());
+          expr.getRange().ifPresent(fieldAccessExpr::setRange);
+          expr.getTokenRange().ifPresent(fieldAccessExpr::setTokenRange);
+          expr.getParentNode().ifPresent(fieldAccessExpr::setParentNode);
           expr.replace(fieldAccessExpr);
+          fieldAccessExpr.getParentNode().ifPresent(expr::setParentNode);
 
           // handle it as a field expression
           return (de.fraunhofer.aisec.cpg.graph.Expression) handle(fieldAccessExpr);
@@ -500,7 +504,11 @@ public class ExpressionHandler
           FieldAccessExpr fieldAccessExpr =
               new FieldAccessExpr(
                   new NameExpr(field.declaringType().getClassName()), field.getName());
+          expr.getRange().ifPresent(fieldAccessExpr::setRange);
+          expr.getTokenRange().ifPresent(fieldAccessExpr::setTokenRange);
+          expr.getParentNode().ifPresent(fieldAccessExpr::setParentNode);
           expr.replace(fieldAccessExpr);
+          fieldAccessExpr.getParentNode().ifPresent(expr::setParentNode);
 
           // handle it as a field expression
           return (de.fraunhofer.aisec.cpg.graph.Expression) handle(fieldAccessExpr);