What parts of reflection are ineffective?

Possible duplicate:
Why is reflection slow?

Some parts of the reflection are said to not work very well. Is this true and what parts of it are considered slow?

Reference Information. I am currently experimenting with a self-adjusting resistance level using reflection. I haven’t done anything yet. I just need to know where the possible optimization points are located so that I can develop the program well.

+3
source share
5 answers

Most frameworks that use reflection reflect the results of reflective operations, so they don’t need to repeat them. So in fact, everything happens once at startup.

- "". API . - . 1- .

+3

. Class.getMethod(), Class.getField(), Class.getDeclaredMethod() .. Class.forName() ( , ).

, , .

Method m = Class.getMethod("foo"); // do it once

// now invoke it as many times as you want

m.invoke(obj);
+3

- , , . , , .

, , . , - .

" ", . . . . Java generics , . . , "" , " ", , .

, . - , , . , , ; , . :

mv "1bill and fred(kfjw0f3).jpg" "1 - bill and fred.jpg"
mv "2sam and kim(g02fsgsg).jpg" "2 - sam and kim.jpg"
.
.
.

Ruby, mv, .

0

,

( , ).

, JIT, . , , , , , ..

, . , , , . .


:

: , , , .

: , , .

, ""!!!!!!!! - , - !!!!!

: ! , , - ~ 20%, ~ 80% , . , java , , , . , , .: D

-1

Source: https://habr.com/ru/post/1786792/


All Articles