# V6100. An object is used as an argument to its own method. Consider checking the first actual argument of the 'Foo' method.

The analyzer detected a method call in which an object is used as an argument to its own method. Most likely, this is erroneous code and the method should be passed another object.

Consider the example:

    a.foo(a);

Due to a typo the incorrect variable name is used here. The fixed version of this code should look like this:

    a.foo(b);

or this:

    b.foo(a);

And here's an example from a real application:

    public class ByteBufferBodyConsumer {
      private ByteBuffer byteBuffer;
      ....
      public void consume(ByteBuffer byteBuffer) {
        byteBuffer.put(byteBuffer);
      }
    }

Here they are trying to insert its own values into the 'byteBuffer'.

Fixed code:

    public class ByteBufferBodyConsumer {
      private ByteBuffer byteBuffer;
      ....
      public void consume(ByteBuffer byteBuffer) {
        this.byteBuffer.put(byteBuffer);
      }
    }

This diagnostic is classified as:

CWE-688

You can look at examples of errors detected by the V6100 diagnostic.