langtools/src/share/opensource/javac/doc/javac_lifecycle/ToDo.html
author yan
Wed, 23 Apr 2008 14:35:26 +0400
changeset 450 be95c1c0efcf
parent 10 06bc494ca11e
permissions -rw-r--r--
6627324: Alt Graph doesnot generate any key event when pressing in German locale Summary: This Unix only problem solved by mapping XK_ISO_Level3_Shift keysym to Java keycode VK_ALT_GRAPH. Reviewed-by: son
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>JavaCompiler's "to do" list</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.main.JavaCompiler's "to do" list</h3>
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
        <p>
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
            After the source files have been parsed, and their symbols entered 
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
            in the symbol table, the top level classes and some other items end 
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
            up on JavaCompiler's "to do" list.
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
        </p>
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
        <p>
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
            For each entry on the "to do" list, <code>JavaCompiler</code>
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
            processes it as follows:
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
        </p>
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
        <ul>
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
            <li><p>Some parts of the compilation involve modifying the parse tree,
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
                so a copy of the root of the tree is kept prior to such manipulation.
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
            </p>
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
            <p class="note">
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
                Note: this copy is just used to check whether the class is one of those
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
                found in a compilation unit on the command line (i.e. in rootClasses).
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
            </p>
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
            <li><p>The top level classes are "attributed", using
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
                <a href="../../src/share/classes/com/sun/tools/javac/comp/Attr.java" class="code">Attr</a>,
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
                meaning that names and other elements within the parse tree are resolved
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
                and associated with the corresponding types and symbols. Many semantic
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
                errors may be detected here, either by <code>Attr</code>, or by
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
                <a href="../../src/share/classes/com/sun/tools/javac/comp/Check.java" class="code">Check</a>.
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
            </p>
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
                <p>While attributing the tree, class files will be read as necessary.
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
                    In addition, if a class is required, and a source file for the class is found
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
                    that is newer than the class file, the source file will be automatically parsed
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
                    and put on the "to do" list. This is done by registering JavaCompiler as an
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
                    implementation of 
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
                    <a href="../../src/share/classes/com/sun/tools/javac/comp/Attr.java" class="code">Attr</a><span class=code>.SourceCompleter</span>.
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
                </p>
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
                <p class=note>
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
                    Note: there is a hidden option <code>-attrparseonly</code> which can be used to skip
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
                    the rest of the processing for this file. In so doing, it "breaks" the
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
                    protocol use to save and restore the source file used to report error
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
                    messages (Log.useSource). There is a "try finally" block which
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
                    could reasonably be used/extended to restore the source file correctly.
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
                </p>
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
            </li>
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
            <li><p>If there are no errors so far, flow analysis will be done for the class, using
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
                <a href="../../src/share/classes/com/sun/tools/javac/comp/Flow.java" class="code">Flow</a>.
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
                Flow analysis is used to check for definite assignment to variables,
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
                and unreachable statements, which may result in additional errors.
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
            </p>
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
                <p class="note">Note: flow analysis can be suppressed with the hidden
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
                    option <code>-relax</code>.
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
                </p>
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
            </li>
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
            <li>If the "to do" item is a TopLevel tree, it will be the contents of a
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
            <span class="code">package-info.java</span> file, containing annotations for a package.
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
            (See notes for <a href="Enter.html#package-info">Enter</a>.) 
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
            <ul>
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
                <li>Syntactic sugar is processed, using
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
                <a href="../../src/share/classes/com/sun/tools/javac/comp/Lower.java" class="code">Lower</a>.
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
                <code>Lower</code> is defined to return a list of trees for the translated classes
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
                and all the translated inner classes.</li>
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
                <li>If <code>Lower</code> returns a non-empty list, there is an assertion that
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
                    the list has a single element, in which case, code is generated, using 
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
                    <a href="../../src/share/classes/com/sun/tools/javac/jvm/Gen.java" class="code">Gen</a>,
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
                    and the resulting code is written out using 
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
                    <a href="../../src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java" class="code">ClassWriter</a>.
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
                </li>
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
                <li>No further processing is done on this "to do" item.<br>
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
                </li>
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
            </ul>
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
            <p class=note>Note that <a href="Enter.html">Enter</a> will have processed all other TopLevel 
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
                putting the individual classes that it finds there on the "to do" 
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
                (and not the TopLevel node itself.)
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
            </p>
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
            <li>If stub outputs have been requested, with the hidden <code>-stubs</code> option,
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
            <ul>
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
                <li>If the class was one of those mentioned on the command line and is in 
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
                <span class=code>java.lang</span>,
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
                pretty print the source with no method bodies.</li>
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
                <li>No further processing is done on this "to do" item. </li>
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
            </ul>
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
            <li>Code involving generic types is translated to code without generic types, using 
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
                <a href="../../src/share/classes/com/sun/tools/javac/comp/TransTypes.java" class="code">TransTypes</a>.
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
            </li>
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
            <li>If source output has been requested, with the hidden <code>-s</code> option
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
            <ul>
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
                <li>If the original tree was from command line, pretty print the source code
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
                </li>
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
                <li>No further processing is done on this "to do" item.</li>
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
            </ul>
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
            <li>Syntactic sugar is processed, using 
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
            <a href="../../src/share/classes/com/sun/tools/javac/comp/Lower.java" class="code">Lower</a>.
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
            This takes care of inner classes, class literals, assertions, foreach
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
            loops, etc.
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
            <code>Lower</code> is defined to return a list of trees for the translated classes
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
            and all the translated inner classes.</li>
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
            <p class=note>
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
            Note: see also the use of <code>Lower</code> earlier in the loop, when processing
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
            TopLevel trees.</p>
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
            <li>For each class returned by <code>Lower</code><br>
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
            <ul>
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
                <li>If source has been requestion with the hidden <code>-printflat</code>
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
                option, the source of the class is printed.
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
                <li>Otherwise, code for the class is generated, using 
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
                <a href="../../src/share/classes/com/sun/tools/javac/jvm/Gen.java" class="code">Gen</a>,
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
                and the resulting code is written out using 
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
                <a href="../../src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java" class="code">ClassWriter</a>.
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
            </ul>
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
        </ul>
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
        <h4>Issues</h4>
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
        The "to do" list is mostly organized by top level classes, and not by 
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
        compilation units. This means that if a compilation unit contains several 
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
        classes, it is possible for code to be generated for some of the classes 
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
        in the file, at which point at error may be detected for one of the 
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
        remaining classes, preventing code from being generated for that and any 
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
        subsequent classes. This means that the compilation unit will be partially 
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
        compiled, with some but not all of the class files being generated. 
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
        (Bug <a href="http://monaco.sfbay.sun.com/detail.jsf?cr=5011101">5011101</a>)
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
    </body>
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
</html>
06bc494ca11e Initial load
duke
parents:
diff changeset
   167