All Questions
Tagged with java reflection
21 questions
1
vote
7
answers
488
views
How do I cleanly keep track of the type of various objects implementing a common interface without reflection?
In my multiplayer game I keep track of each player's inventory. I have a class for each inventory action that extends the abstract class InventoryItem. I then polymorphically call use() on the ...
1
vote
1
answer
168
views
Good approaches when one needs to access private variables in production systems
At my company we needed access to some variable to call a method on it, this variable is hidden about 6 layers down of different libraries code and each time it is behind a private variables (that ...
2
votes
2
answers
1k
views
Java: Is reflection bad for AOP situations?
Imagine the following situation:
1. Consume a 3rd party WSDL, out comes thousands of classes.
2. There's an opportunity to optimize performance by using a custom paralleled implementation.
3. Wsdl ...
2
votes
3
answers
4k
views
How to build rest calls dynamically to interface with different APIs?
Lets say I am building an application where clients can book bus tickets. The only thing they do is select, origin, destination and the type of service (express or standard). The system will then book ...
51
votes
4
answers
19k
views
Why is it a bad idea to create a generic setter and getter with reflection?
A while back I wrote this answer to a question on how to avoid having a getter and setter for every mutable variable. At the time, I had only a hard-to-verbalize gut feeling that this is a Bad Idea, ...
1
vote
2
answers
93
views
Why 'Package' type does not inherit 'AccessibleObject' type?
Below are the relevant types(in java) for annotation processing,
In addition to Field & Method types, Package type is also used in context of annotations with reflection, because these types ...
0
votes
1
answer
392
views
Is using Java reflection to map frontend actions to the actual db methods by name bad practice?
I have used java reflection with a static map to map actions(removeElements, getLatest ...) from the front end to the corresponding database methods by name in multiple web applications now.
I was ...
0
votes
2
answers
7k
views
Annotation to define values for method argument
In a project, I have a task scheduling service, which is allowed to execute certain public methods from other services. Each service decides itself, which methods it want to make available for the ...
6
votes
6
answers
894
views
In creating a "registry", which is worse: using reflection or violating open/closed principle?
In my current software engineering course, my team is working on a library management system that is essentially a command-line/REPL environment with a half dozen commands, e.g. checkout, search, etc. ...
0
votes
2
answers
2k
views
Set data in multi-level objects (may be using Java Reflection)
I want to possibly use Java Reflection to set some data at RunTime. My problem is I can't figure out how do I get sub-classes information and use as a part of reflection.
I want to use Reflection to ...
2
votes
1
answer
3k
views
How can I make an object/class inaccessible to Reflection
I am building an API for minecraft called the Quantum API. We all know that reflection can be used to do some nasty stuff to classes, and even cause undefined behavior if used without care.
Is there ...
0
votes
1
answer
124
views
Reflection performance in this iteration of a (probably) large excel file
I'm wondering the performance of reflection in this situation. I'm iterating a (probably) large excel file (let's say 3000 max) which it's going to be done from time to time, and the implementation ...
3
votes
1
answer
927
views
Debugging xml and annotations
By now, most web containers have an annotation variant of their xml configurations for Java EE. I'm guessing this is because it's better to keep things in Java where they can be managed, coded with ...
3
votes
2
answers
3k
views
Reason for a reflection error
I’m working on an Eclipse plug-in project.
Using this plug-in, users can create Eclipse Java projects with some specificities. For example, they can add Java classes’ names which will be saved in a ...
1
vote
4
answers
1k
views
Using Java Reflection to decouple code modules
I'm involved in a project with several modules. I found that programmers have designed one module to be easily decoupled from its dependent modules using Java Reflection. If other modules need to call ...