# "this" reference

\*\*\*\* **NOTE: BLOG MOVED TO** [**https://cmrodriguez.me/**](https://cmrodriguez.me/) **\*\*\*\***

In Java (and a lot of other languages as well) there is always a special variable called **this** that references the object which is running the method. In Frida, whenever someone is rewriting a method, he has access to the "this" parameter. Check the following script as an example:

```javascript
BasicTypes.addTwoInts.implementation = function (var1,var2) {
    console.log("the method is being called");
    return this.addTwoInts(var1,var2);
}
```

In this case the "this" references the class **BasicTypes**. So by calling the "this.addTwoInts" we are calling the original implementation of the method, instead of reimplementing it. This feature is useful for many use cases as:

* know if a method is being called (as shown in the example above)
* print the input values to know what is being received by the function.
* print the stack trace to know where it is being called.

In all these cases the idea is not to change the workflow of the methods, just trace or debug the functionality.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://neo-geo2.gitbook.io/adventures-on-security/frida-scripting-guide/this-reference.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
