通过反射

时间:2015-08-17 23:44:11

标签: java android reflection

public class FingerprintManager {

     * @hide
     */
   // this class is hidden 
    public static abstract class EnrollmentCallback {

        public void onEnrollmentError(int errMsgId, CharSequence errString) { }


        public void onEnrollmentHelp(int helpMsgId, CharSequence helpString) { }


        public void onEnrollmentProgress(int remaining) { }
    };
}

隐藏了EnrollmentCallback类。有没有办法通过反射来实例化EnrollmentCallback类,这相当于:

EnrollmentCallback callbackObject = new EnrollmentCallback ()
{
        public void onEnrollmentError(int errMsgId, CharSequence errString) { }


        public void onEnrollmentHelp(int helpMsgId, CharSequence helpString) { }


        public void onEnrollmentProgress(int remaining) { }
};

1 个答案:

答案 0 :(得分:2)

没有。有可能使用字节码操作库(如ASM)来做到这一点,但是如果不扩展它并实现任何缺失({{abstract类,它就无法实例化{{1}}类。 1}})方法。你不能用Java反射做到这一点。