junit java reflection

Hi,

What is the relation between

junit java reflection

I have not clearly understood what and why java reflection is useful. Is java reflection is new from jdk7?
Please advise with simple complete examples?
LVL 7
gudii9Asked:
Who is Participating?
 
CPColinSenior Java ArchitectCommented:
I have not clearly understood what and why java reflection is useful. Is java reflection is new from jdk7?

You've asked these questions before:

http://www.experts-exchange.com/Programming/Languages/Java/Q_28375199.html

The answers are still the same.

Do you have a more specific question or situation in mind? I expect that JUnit uses reflection so it can work with whatever code you throw at it, without having to know how your code is structured.
0
 
dpearsonCommented:
Reflection is not new.

It is very rarely needed.  It's only used in complex situations where you need to gather information about a program that for some reason the compiler cannot provide.

E.g. You could write a program where you type in the name of a method and have the program execute that method.
That's a pretty unusual situation.

I'd suggest you avoid it for now unless you have a specific problem in mind that you cannot solve.

Doug
0
 
gudii9Author Commented:
I see some architects keep talking about it quite a lot in my project. I wonder if they know lot of technology or they are trying to use it unnecessarily
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
CPColinSenior Java ArchitectCommented:
The easiest way to find out is to ask them. You could tell them you're interested in learning more about reflection and ask them to give you an overview of what they're working on.
0
 
gudii9Author Commented:
I expect that JUnit uses reflection so it can work with whatever code you throw at it, without having to know how your code is structured.

Structured meaning which method comes after which method like flow? or what is written inside the method curly braces{}
Please advise
0
 
CPColinSenior Java ArchitectCommented:
JUnit needs to work with whatever class you throw at it, without knowing what fields and methods it has ahead of time. That's what I meant by "how your code is structured."
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.