Re: How to access a member constant by FQN



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 = ?

.



Relevant Pages

  • Re: A question in the objects size.
    ... > int id; ... > String name; ... then the order in which the base and derived members occur could ... leeway in deciding how to arrange the member variables. ...
    (comp.lang.java.programmer)
  • Re: why use the sealed ?
    ... > I'll want to add functionality to something at a later date. ... > I sortof wish you could add functionality to (or replace members of) ... > exceeds past the end of the string. ... > application to be a Remoting Client. ...
    (microsoft.public.dotnet.languages.csharp)
  • Type conversions question
    ... MyCollection) wherein I can control the types of objects being added to the ... members as types of object IMyObject, i.e. it has the ability to convert the ... external members wish to access members of the collection ... access the member back as a string. ...
    (microsoft.public.dotnet.languages.csharp)
  • Struts 1.2 - HTML:SELECT problem
    ... So the attribute members has data. ... private String staff_number; ... Session session = null; ...
    (comp.lang.java.programmer)
  • Re: Insert recordset list into e-mail message
    ... It looks like you are already setting up a SQL string to return ... you a recordset of the family members, but you are not using it. ... Then you have a list of members, one per line, that you can insert into your ... Graham Mandeno ...
    (microsoft.public.access.formscoding)