اذا لم تجد ما تبحث عنه يمكنك استخدام كلمات أكثر دقة.
الانعكاس في البرمجة وعلم الحاسوب وهي اختبار البرنامج وتحليله في أثناء تشغيله وتنفيذه .
المثال التالي في لغة C#:
// Without reflection Foo foo = new Foo(); foo.PrintHello(); // With reflection Object foo = Activator.CreateInstance("complete.classpath.and.Foo"); MethodInfo method = foo.GetType().GetMethod("PrintHello"); method.Invoke(foo, null);
المثال التالي في لغة جافا:
// Without reflection Foo foo = new Foo(); foo.hello(); // With reflection Object foo = Class.forName("complete.classpath.and.Foo").newInstance(); // Alternatively: Object foo = Foo.class.newInstance(); Method m = foo.getClass().getDeclaredMethod("hello", new Class<?>[0]); m.invoke(foo);
المثال التالي في لغة بي إتش بي:
// Without reflection $foo = new Foo(); $foo->hello(); // With reflection $reflector = new ReflectionClass('Foo'); $foo = $reflector->newInstance(); $hello = $reflector->getMethod('hello'); $hello->invoke($foo); // using callback $foo = new Foo(); call_user_func(array($foo, 'hello')); // using variable variables syntax $className = 'Foo'; $foo = new $className(); $method = 'hello'; $foo->$method();
المثال التالي في لغة بايثون:
# without reflection obj = Foo() obj.hello() # with reflection class_name = "Foo" method = "hello" obj = globals()[class_name]() getattr(obj, method)() # with eval eval("Foo().hello()")
يستخدم عادة لاختبار النظام وسير عمله كما يستخدم أيضا في رصد مكان الخلل في حالة وجوده ويمكن ملاحظة أن أكثر مستعملي هذه الخاصية هم القراصنة فهم يستخدمونها لرصد الثغرات