---
title: "[Java] IllegalArgumentException of method inflection"
author: "SilverRing"
date: "2010-10-19T15:04:56Z"
tags: []
categories: ["编程语言"]
slug: "java-illegalargumentexception-of-method-inflection"
draft: false
lastmod: "2010-10-19T15:04:56Z"
id: 788561
url: "https://silverring.iteye.com/blog/788561"
---

If this exception is encountered:


```java

java.lang.IllegalArgumentException: object is not an instance of declaring class

```


Check whether the object instance is correct:


```java

Method method = invoker.getClass().getMethod("testMethod");
method.invoke(invoker); // must be invoker, don't set "this"

```


invoker is the instance of the object that testMethod is defined in.