samedi 29 juillet 2017

Reflection: How to get the value of a field without evaluation?

Playing with java.lang.reflect and was wondering if there is any possibilities to get the assignment value of a java.lang.reflect.Field

Example

public class Dummy {
    String envHttpPort = System.getenv("HTTP_PORT");
}

From java reflection I would like the have the value System.getenv("HTTP_PORT"); returned instead of null as it seems by instantiation of the class, which as far as I know is required to retrieve the values of the Field would be the value of the System.getenv(String) call, which is not what I want.

Is it possible to read the field and value as is?

Wanted output would be the same as the source code.

I hope you guys understand if not please let me know and I will try and rephrase the question.





Aucun commentaire:

Enregistrer un commentaire