Re: How to access a member constant by FQN
- From: Sideswipe <christian.bongiorno@xxxxxxxxx>
- Date: Wed, 05 Sep 2007 21:40:17 -0000
Hmm, ok, let me try this:
Class.forName("com.whatever.mycompany.MyConstants");
// MyConstants is now loaded and the static members initialized
MY_CONST is now an Integer instance floating around in the JVM. So, I
don't NEED a new instance of it, but I want to access it by a fully
qualified name.
When I do: Class.newInstance() <-- object is returned but if I am
given the string: "com.whatever.mycompany.MyConstants.MY_CONST" I am
not being given a FQN to a class, I am being given a FQN to a static
final member of a Class.
Another way to say it, how do I make an assignment to this instance
based on the FQN as a String. This is all runtime/reflection -- not
compile time so I have no way to know what will be referenced. If I
knew the Outter class I could use reflection to get the fields and
discover it by name, but I can't know that the String given to me
represents a class and not one of it's members.
Object someConst = ?
.
- Follow-Ups:
- Re: How to access a member constant by FQN
- From: Joshua Cranmer
- Re: How to access a member constant by FQN
- References:
- How to access a member constant by FQN
- From: Sideswipe
- Re: How to access a member constant by FQN
- From: Eric Sosman
- How to access a member constant by FQN
- Prev by Date: Re: READ THIS MESSAGE UNTIL THE END!
- Next by Date: Class file parsers
- Previous by thread: Re: How to access a member constant by FQN
- Next by thread: Re: How to access a member constant by FQN
- Index(es):
Relevant Pages
|