-1

我正在尝试使用反射 API 检索同步方法。

下面给出的示例代码片段:

class ABC {
    class XYZ {
        synchronized List methodOfXYZ() {
            System.out.println("Im in Method");
            // do sum stuff
            return <Obj-List>;
        }
    }
}

我得到运行时异常,例如:

java.lang.IllegalAccessException: Class "com.TestReflection" can not access a member of class "com.ABC$XYZ" with modifiers "synchronized".
4

1 回答 1

0

try this:

public Class ABC
{
    public Class XYZ 
    {
       public synchronized List methodOfXYZ()
       {
          System.out.println("Im in Method");
         // do sum stuff
         return <Obj-List>;
        }
     }
 }
于 2013-12-27T15:19:46.290 回答