Solved

junit java reflection

Posted on 2014-07-17
6
858 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 26

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This video teaches viewers about errors in exception handling.

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now