-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

これを試して:

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 に答える