File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

metaclass?

 
Marium Hasan
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Metaclass is automatically loaded when a Class is loaded
but how do we get the information in metaclass?
 
Iain Lowe
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not quite sure what you mean by Metaclass. Could you elaborate?
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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();
 
Marium Hasan
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Marium Hasan
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic