This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes metaclass? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "metaclass?" Watch "metaclass?" New topic
Author

metaclass?

Marium Hasan
Greenhorn

Joined: Oct 03, 2001
Posts: 12

Metaclass is automatically loaded when a Class is loaded
but how do we get the information in metaclass?
Iain Lowe
Greenhorn

Joined: Sep 07, 2001
Posts: 12
Not quite sure what you mean by Metaclass. Could you elaborate?
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
If you use the Class class (don't you love it )
Class myC = new Class("WhateverClass");
Then you can use the methods of Class to get at some MetaData.
For instance:
Field[] classFields = myC.getFields();

"JavaRanch, where the deer and the Certified play" - David O'Meara
Marium Hasan
Greenhorn

Joined: Oct 03, 2001
Posts: 12

Can we get on fields( variables ) as well as Methods ( static
& non-static ) by exploring Class class methods & using
Field class array.?

Originally posted by Cindy Glass:
If you use the Class class (don't you love it )
Class myC = new Class("WhateverClass");
Then you can use the methods of Class to get at some MetaData.
For instance:
Field[] classFields = myC.getFields();

Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
I have not a clue what you are asking. Read the API for Class.
http://java.sun.com/j2se/1.3/docs/api/index.html
William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 984

There doesn't seem to be a class called "metaclass". The "Class" class Cindy refered to lives in java.lang

Can we get on fields( variables )

If you are asking if you can get the names of variables the class "Class" has a method called "getFields()" which is defined as "Returns an array containing Field objects reflecting all the accessible public fields of the class or interface represented by this Class object."

as well as Methods

That same class has a method called "getMethods()" which looks like what you want.

Please ignore post, I have no idea what I am talking about.
Marium Hasan
Greenhorn

Joined: Oct 03, 2001
Posts: 12


Thanks Christopher and Cindy for your great help!
With Regards
Marium

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: metaclass?
 
Similar Threads
static member variable of a class
Intercepting Constructors and The Calling Original Constructor
I need metaClass advice for Groovy
object Vs instance
Java MetaClass?