| <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
| <!-- |
| Copyright 2006 Sun Microsystems, Inc. All Rights Reserved. |
| DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| |
| This code is free software; you can redistribute it and/or modify it |
| under the terms of the GNU General Public License version 2 only, as |
| published by the Free Software Foundation. Sun designates this |
| particular file as subject to the "Classpath" exception as provided |
| by Sun in the LICENSE file that accompanied this code. |
| |
| This code is distributed in the hope that it will be useful, but WITHOUT |
| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| version 2 for more details (a copy is included in the LICENSE file that |
| accompanied this code). |
| |
| You should have received a copy of the GNU General Public License version |
| 2 along with this work; if not, write to the Free Software Foundation, |
| Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| |
| Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| CA 95054 USA or visit www.sun.com if you need additional information or |
| have any questions. |
| --> |
| |
| <html> |
| <head> |
| <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"> |
| <meta name="author" content="Jonathan Gibbons"> |
| <link type="text/css" rel=stylesheet href="style.css"> |
| <title>com.sun.tools.javac.comp.Enter</title> |
| </head> |
| <body> |
| |
| <h3>com.sun.tools.javac.comp.Enter</h3> |
| |
| This enters symbols for all encountered definitions into |
| the symbol table. The pass consists of two phases, organized as |
| follows: |
| |
| <ol> |
| <li><p>In the first phase, all class symbols are entered into their |
| enclosing scope, descending recursively down the tree for classes |
| which are members of other classes. The class symbols are given a |
| MemberEnter object as completer.</p></li> |
| |
| <p><a name="package-info"></a>In addition, |
| if any <span class=code>package-info.java</span> files are found, |
| containing package annotations, then the TopLevel tree node for |
| the package-info.java file is put on the "to do" as well. |
| </p> |
| |
| <li><p>In the second phase, classes are completed using |
| MemberEnter.complete(). Completion might occur on demand, but |
| any classes that are not completed that way will be eventually |
| completed by processing the `uncompleted' queue. Completion |
| entails |
| <ul><li>(1) determination of a class's parameters, supertype and |
| interfaces, as well as <li>(2) entering all symbols defined in the |
| class into its scope, with the exception of class symbols which |
| have been entered in phase 1.</li> |
| </ul> |
| (2) depends on (1) having been |
| completed for a class and all its superclasses and enclosing |
| classes. That's why, after doing (1), we put classes in a |
| `halfcompleted' queue. Only when we have performed (1) for a class |
| and all it's superclasses and enclosing classes, we proceed to |
| (2).</p></li> |
| </ol> |
| |
| <p>Whereas the first phase is organized as a sweep through all |
| compiled syntax trees, the second phase is demand. Members of a |
| class are entered when the contents of a class are first |
| accessed. This is accomplished by installing completer objects in |
| class symbols for compiled classes which invoke the member-enter |
| phase for the corresponding class tree.</p> |
| |
| <p>Classes migrate from one phase to the next via queues:</p> |
| |
| <pre> |
| class enter -> (Enter.uncompleted) --> member enter (1) |
| -> (MemberEnter.halfcompleted) --> member enter (2) |
| -> (Todo) --> attribute |
| (only for toplevel classes) |
| </pre> |
| |
| </body> |
| </html> |
| |