Solved

junit java reflection

Posted on 2014-07-17
6
898 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 28

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

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.

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
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…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

636 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