Re: Literature about reflection

Eric Marsden <emarsden@mail.dotcom.fr>
24 Sep 1999 22:56:37 -0400

          From comp.compilers

Related articles
Literature about reflection Daniel.Vogelheim@post.rwth-aachen.de (Daniel Vogelheim) (1999-09-10)
Re: Literature about reflection emarsden@mail.dotcom.fr (Eric Marsden) (1999-09-11)
Re: Literature about reflection Daniel.Vogelheim@post.rwth-aachen.de (Daniel Vogelheim) (1999-09-20)
Re: Literature about reflection emarsden@mail.dotcom.fr (Eric Marsden) (1999-09-24)
| List of all articles for this month |
From: Eric Marsden <emarsden@mail.dotcom.fr>
Newsgroups: comp.compilers
Date: 24 Sep 1999 22:56:37 -0400
Organization: LAAS-CNRS http://www.laas.fr/
References: 99-09-028 99-09-039 99-09-072
Keywords: Java

>>>>> "dv" == Daniel Vogelheim <Daniel.Vogelheim@post.rwth-aachen.de> 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>
    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>
    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>
    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
        C++)


    * 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
                                        Meta-Helix",
          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:http://www.hlla.is.tsukuba.ac.jp/~mich/English/openjava/>
[3] <URL:http://www.hlla.is.tsukuba.ac.jp/~chiba/openc++.html>
[4] <URL:http://www.cs.ncl.ac.uk/people/i.s.welch/home.formal/dalang/>
[5] <URL:http://www.hlla.is.tsukuba.ac.jp/~chiba/javassist/>


--
Eric Marsden


Post a followup to this message

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