Solved

junit java reflection

Posted on 2014-07-17
6
885 Views
Last Modified: 2014-07-27
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?
0
Comment
Question by:gudii9
  • 3
  • 2
6 Comments
 
LVL 14

Accepted Solution

by:
CPColin earned 250 total points
ID: 40203043
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
 
LVL 27

Assisted Solution

by:dpearson
dpearson earned 250 total points
ID: 40203910
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
 
LVL 7

Author Comment

by:gudii9
ID: 40218017
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Expert Comment

by:CPColin
ID: 40218028
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
 
LVL 7

Author Comment

by:gudii9
ID: 40218029
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
 
LVL 14

Expert Comment

by:CPColin
ID: 40218051
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question