[ACCEPTED]-Java implementation - Meta classes-metaclass

Accepted answer
Score: 17

In Java there's a single metaclass: the 4 instances of the class Class are used to represent 3 the types of classes and interfaces. The 2 constructors are defined at the class level, not 1 at the metaclass level.

Score: 9

Your question targets nothing special about 20 constructors: From the point of describing 19 classes on a metalevel there is the same 18 concept for constructors, "normal methods" and 17 fields.

So think of it this way:

  • Each class in 16 Java is described by a certain set of informations:

    • Name of the class
    • the superclass
    • the implemented interfaces
    • a list of constructors and their signatures
    • a list of (static and non-static) methods and their signatures
    • a list of (static and non-static) fields and their types
  • For 15 your convenience this information is available 14 to you during runtime - this is the "reflection 13 API".

  • Since the same type of information 12 is available for each class loaded by the 11 JVM, this is bundled in a own class named 10 java.lang.Class.

  • So one instance of the class Class describes the class 9 java.lang.String, another instance of Class describes my.own.class.Foo.

  • java.lang.Class itself is of 8 course also a class - therefore there also 7 exists an instance of Class describing the class Class. And 6 I think that's where things get recursive 5 somehow.

Summary: There is only one metaclass: java.lang.Class. Multiple 4 instances (meta-instance?) of the metaclass 3 describe individual classes - including 2 the metaclass itself. Constructor descriptions are part 1 of the instances of the metaclass.

More Related questions