langtools/src/share/opensource/javac/doc/javac_lifecycle/Enter.html
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 10 06bc494ca11e
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
06bc494ca11e Initial load
duke
parents:
diff changeset
     2
<!--
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
Copyright 2006 Sun Microsystems, Inc.  All Rights Reserved.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     7
under the terms of the GNU General Public License version 2 only, as
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
published by the Free Software Foundation.  Sun designates this
06bc494ca11e Initial load
duke
parents:
diff changeset
     9
particular file as subject to the "Classpath" exception as provided
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
by Sun in the LICENSE file that accompanied this code.
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    21
06bc494ca11e Initial load
duke
parents:
diff changeset
    22
Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
06bc494ca11e Initial load
duke
parents:
diff changeset
    23
CA 95054 USA or visit www.sun.com if you need additional information or
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
have any questions.
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
-->
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
<html>
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
    <head>
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
        <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
        <meta name="author" content="Jonathan Gibbons">
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
        <link type="text/css" rel=stylesheet href="style.css">
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
        <title>com.sun.tools.javac.comp.Enter</title>
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
    </head>
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
    <body>
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
        <h3>com.sun.tools.javac.comp.Enter</h3>
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
        This enters symbols for all encountered definitions into
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
        the symbol table. The pass consists of two phases, organized as
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
        follows:
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
        <ol>
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
            <li><p>In the first phase, all class symbols are entered into their
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
            enclosing scope, descending recursively down the tree for classes
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
            which are members of other classes. The class symbols are given a
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
            MemberEnter object as completer.</p></li>
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
  
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
            <p><a name="package-info"></a>In addition, 
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
                if any <span class=code>package-info.java</span> files are found, 
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
                containing package annotations, then the TopLevel tree node for 
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
                the package-info.java file is put on the "to do" as well.
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
            </p>
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
            <li><p>In the second phase, classes are completed using
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
            MemberEnter.complete().  Completion might occur on demand, but
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
            any classes that are not completed that way will be eventually
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
            completed by processing the `uncompleted' queue.  Completion
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
            entails 
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
            <ul><li>(1) determination of a class's parameters, supertype and
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
                interfaces, as well as <li>(2) entering all symbols defined in the
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
                class into its scope, with the exception of class symbols which
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
                have been entered in phase 1.</li>
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
            </ul>
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
            (2) depends on (1) having been
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
            completed for a class and all its superclasses and enclosing
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
            classes. That's why, after doing (1), we put classes in a
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
            `halfcompleted' queue. Only when we have performed (1) for a class
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
            and all it's superclasses and enclosing classes, we proceed to
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
            (2).</p></li>
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
        </ol>
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
 
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
        <p>Whereas the first phase is organized as a sweep through all
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
        compiled syntax trees, the second phase is demand. Members of a
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
        class are entered when the contents of a class are first
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
        accessed. This is accomplished by installing completer objects in
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
        class symbols for compiled classes which invoke the member-enter
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
        phase for the corresponding class tree.</p>
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
 
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
        <p>Classes migrate from one phase to the next via queues:</p>
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
 
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
        <pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
    class enter -> (Enter.uncompleted)         --> member enter (1)
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
 		-> (MemberEnter.halfcompleted) --> member enter (2)
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
 		-> (Todo)	               --> attribute
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
 						(only for toplevel classes)
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
        </pre>
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
    </body>
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
</html>
06bc494ca11e Initial load
duke
parents:
diff changeset
    90