Re: Literature about reflection

Eric Marsden <>
24 Sep 1999 22:56:37 -0400

          From comp.compilers

Related articles
Literature about reflection (Daniel Vogelheim) (1999-09-10)
Re: Literature about reflection (Eric Marsden) (1999-09-11)
Re: Literature about reflection (Daniel Vogelheim) (1999-09-20)
Re: Literature about reflection (Eric Marsden) (1999-09-24)
| List of all articles for this month |

From: Eric Marsden <>
Newsgroups: comp.compilers
Date: 24 Sep 1999 22:56:37 -0400
Organization: LAAS-CNRS
References: 99-09-028 99-09-039 99-09-072
Keywords: Java

>>>>> "dv" == Daniel Vogelheim <> writes:

    [categorization of reflection capabilities]

    dv> 1) The baselevel gets read only access to the metalevel. This
    dv> means, the base level can find out about it's own structure and
    dv> state. E.g., an object can enumerate it's own member variables,
    dv> and possibly print their values.
    dv> 2) The base gets access to the metalevel, which can observe and
    dv> change the baselevel. E.g., the program can find out about the
    dv> variables of another object and change their values through the
    dv> metalevel. It could also find the constructors for a class, call
    dv> them, and thereby create new baselevel objects through the
    dv> metalevel.
    dv> 3) The baselevel gets full access to the metalevel and can
    dv> change the metalevel. This means, a program could create new
    dv> classes, or change the meaning of e.g. inheritance or member
    dv> variable access.
    dv> I thought the Java Reflection API provides 1) and 2).

You are confusing metainformation (the structure and state of the
baselevel program) and the metalevel (those parts of the program which
manipulate the metainformation). Any part of your program which uses
the Java Reflective API is in the metalevel. The distinction is
important, since inherent in the concept of reflexivity is
metacircularity: the metaprogram can itself be observed/controlled by
a meta-metaprogram, and thus be part of both the metalevel and the
baselevel [1].

The JavaReflAPI only allows the metalevel to _observe_ the baselevel
(listing the variables of a class and obtaining their values, for
example), and provides no _control_ mechanisms (eg. adding/ removing/
modifying member functions). Thus in your classification, only 1. is
possible (you might argue that the ability to modify the value of a
variable in a class that you have introspected counts as 2., but you
are really only using a baselevel mechanism).

    dv> 3) is not directly supported in Java, but could be implemented
    dv> through dynamic class loaders that change the JVM Bytecodes at
    dv> run time.

yes, there has been a significant amount of research work on adding
more reflexive features to Java:

    * OpenJava [2] is an open compiler which allows a class to be
        associated with a metaclass which will control the way in which it
        is compiled (this work is similar in philosophy to version 2 of the
        OpenC++ compiler [3], which provides compile-time reflection for

    * Dalang [4] uses modified class loaders to provide behavioural
        reflection for Java (as you suggest)

    * Javassist [5] is a project similar to Dalang which I believe
        provides higher level abstractions for the metaprogrammer

[1] @Article{Chiba:1996:ACM,
          author = "S. Chiba and G. Kiczales and J. Lamping",
          title = "Avoiding Confusion in Metacircularity: The
          journal = "Lecture Notes in Computer Science",
          volume = "1049",
          pages = "157--??",
          year = "1996",
          coden = "LNCSD9",
          ISSN = "0302-9743",
          bibdate = "Sat May 11 13:45:32 MDT 1996",
          acknowledgement = ack-nhfb,
[2] <URL:>
[3] <URL:>
[4] <URL:>
[5] <URL:>

Eric Marsden

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.