About 270,000 results
Open links in new tab
  1. java - What is reflection and why is it useful? - Stack Overflow

    Sep 1, 2008 · What is reflection, and why is it useful? I'm particularly interested in Java, but I assume the principles are the same in any language.

  2. java - How do I access private methods and private data members via ...

    you can access private everything with reflection - methods, constructors, data members, everything. How can I access the private methods and the private data members?

  3. Change private static final field using Java reflection

    Jul 21, 2010 · I have a class with a private static final field that, unfortunately, I need to change it at run-time. Using reflection I get this error: java.lang.IllegalAccessException: Can not set static final

  4. reflection - How do I invoke a Java method when given the method …

    Object obj; String methodName = "getName"; Without knowing the class of obj, how can I call the method identified by methodName on it? The method being called has no parameters, and a String …

  5. java - Is it bad practice to use Reflection in Unit testing? - Stack ...

    Oct 11, 2014 · During the last years I always thought that in Java, Reflection is widely used during Unit testing. Since some of the variables/methods which have to be checked are private, it is somehow …

  6. java - Reflection generic get field value - Stack Overflow

    Nov 15, 2012 · I am trying to obtain a field's value via reflection. The problem is I don't know the field's type and have to decide it while getting the value. This code results with this exception: Can not set...

  7. java - Accessing non-visible classes with reflection - Stack Overflow

    Feb 22, 2013 · I am trying to get an instance of a non-visible class, AKA package private class, using reflection. I was wondering if there was a way to switch the modifiers to make it public and then …

  8. java - Set field value with reflection - Stack Overflow

    Jan 23, 2019 · It's worth reading Oracle Java Tutorial - Getting and Setting Field Values Field#set (Object object, Object value) sets the field represented by this Field object on the specified object …

  9. Java Reflection: Why is it so slow? - Stack Overflow

    It cannot be over emphasized that using reflection is only slow compared to using the equivalent non-reflection code. Reading or writing to the HD or parsing xml or using the network or accessing a …

  10. Java Reflection Performance - Stack Overflow

    Yes - absolutely. Looking up a class via reflection is, by magnitude, more expensive. Quoting Java's documentation on reflection: Because reflection involves types that are dynamically resolved, certain …