src/hotspot/share/prims/jvmtiEnvFill.java
author dcubed
Wed, 22 Nov 2017 17:54:50 -0800
changeset 48105 8d15b1369c7a
parent 47216 71c04702a3d5
permissions -rw-r--r--
8167108: inconsistent handling of SR_lock can lead to crashes Summary: Add Thread Safe Memory Reclamation (Thread-SMR) mechanism. Reviewed-by: coleenp, dcubed, dholmes, eosterlund, gthornbr, kbarrett, rehn, sspitsyn, stefank Contributed-by: daniel.daugherty@oracle.com, erik.osterlund@oracle.com, robbin.ehn@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
     2
 * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
import java.io.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
import java.util.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
class jvmtiEnvFill {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
    public static void main(String[] args) throws IOException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
        if (args.length != 3) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
            System.err.println("usage: <filledFile> <stubFile> <resultFile>");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
            System.exit(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
        String filledFN = args[0];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
        String stubFN = args[1];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
        String resultFN = args[2];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
        SourceFile filledSF = new SourceFile(filledFN);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
        SourceFile stubSF = new SourceFile(stubFN);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
        stubSF.fill(filledSF);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
        PrintWriter out = new PrintWriter(new FileWriter(resultFN));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
        stubSF.output(out);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
        out.close();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
class SourceFile {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
    static final String endFilePrefix = "// end file prefix";
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
    static final String functionPrefix = "JvmtiEnv::";
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
    final String fn;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
    LineNumberReader in;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
    String line;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
    List<String> top = new ArrayList<String>();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
    List<String> before = new ArrayList<String>();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
    boolean inFilePrefix = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
    List<Function> functions = new ArrayList<Function>();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
    Map<String, Function> functionMap = new HashMap<String, Function>();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
    class Function {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
      String name;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
      String args;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
      String compareArgs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
      List comment;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
      List<String> body = new ArrayList<String>();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
      Function() throws IOException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
        line = in.readLine();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
        String trimmed = line.trim();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
        if (!trimmed.startsWith(functionPrefix)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
            error("expected '" + functionPrefix + "'");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
        int index = trimmed.indexOf('(', functionPrefix.length());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
        if (index == -1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
            error("missing open paren");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
        name = trimmed.substring(functionPrefix.length(), index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
        int index2 = trimmed.indexOf(')', index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
        if (index2 == -1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
            error("missing close paren - must be on same line");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
        args = trimmed.substring(index+1, index2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
        compareArgs = args.replaceAll("\\s", "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
        String tail = trimmed.substring(index2+1).trim();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
        if (!tail.equals("{")) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
            error("function declaration first line must end with open bracket '{', instead got '" +
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
                   tail + "'");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
        while(true) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
            line = in.readLine();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
            if (line == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
                line = ""; // so error does not look wierd
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
                error("unexpected end of file");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
            if (line.startsWith("}")) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
                break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
            body.add(line);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
        String expected = "} /* end " + name + " */";
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
        trimmed = line.replaceAll("\\s","");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
        if (!trimmed.equals(expected.replaceAll("\\s",""))) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
            error("function end is malformed - should be: " + expected);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
        // copy over the comment prefix
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
        comment = before;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
        before = new ArrayList<String>();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
      void remove() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
        functionMap.remove(name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
      String fileName() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
        return fn;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
      void fill(Function filledFunc) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
        if (filledFunc == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
            System.err.println("Warning: function " + name + " missing from filled file");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
            body.add(0, "    /*** warning: function added and not filled in ***/");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
            int fbsize = filledFunc.body.size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
            int bsize = body.size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
            if (fbsize > bsize  || !body.subList(bsize-fbsize,bsize).equals(filledFunc.body)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
                // it has actually been filled in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
                body = filledFunc.body;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
                if (!compareArgs.equals(filledFunc.compareArgs)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
                    System.err.println("Warning: function " + name +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
                                       ": filled and stub arguments differ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
                    System.err.println("  old (filled): " + filledFunc.args);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
                    System.err.println("  new (stub): " + args);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
                    body.add(0, "    /*** warning: arguments changed, were: " +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
                             filledFunc.args + " ***/");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
            filledFunc.remove();  // mark used
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
      void output(PrintWriter out) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
            Iterator it = comment.iterator();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
            while (it.hasNext()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
                out.println(it.next());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
            out.println("jvmtiError");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
            out.print(functionPrefix);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
            out.print(name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
            out.print('(');
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
            out.print(args);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
            out.println(") {");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
            it = body.iterator();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
            while (it.hasNext()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
                out.println(it.next());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
            out.print("} /* end ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
            out.print(name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
            out.println(" */");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
    SourceFile(String fn) throws IOException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
        this.fn = fn;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
        Reader reader = new FileReader(fn);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
        in = new LineNumberReader(reader);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
        while (readGaps()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
            Function func = new Function();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
            functionMap.put(func.name, func);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
            functions.add(func);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
        in.close();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
    void error(String msg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
        System.err.println("Fatal error parsing file: " + fn);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
        System.err.println("Line number: " + in.getLineNumber());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
        System.err.println("Error message: " + msg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
        System.err.println("Source line: " + line);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
        System.exit(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
    boolean readGaps() throws IOException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
        while(true) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
            line = in.readLine();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
            if (line == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
                return false; // end of file
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
            if (!inFilePrefix && line.startsWith("}")) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
                error("unexpected close bracket in first column, outside of function.\n");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
            String trimmed = line.trim();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
            if (line.startsWith("jvmtiError")) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
                if (trimmed.equals("jvmtiError")) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
                    if (inFilePrefix) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
                        error("unexpected 'jvmtiError' line in file prefix.\n" +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
                              "is '" + endFilePrefix + "'... line missing?");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
                    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
                    return true; // beginning of a function
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
                } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
                    error("extra characters at end of 'jvmtiError'");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
            if (inFilePrefix) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
                top.add(line);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
            } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
                trimmed = line.trim();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
                if (!trimmed.equals("") && !trimmed.startsWith("//") && !trimmed.startsWith("#")) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
                    error("only comments and blank lines allowed between functions");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
                before.add(line);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
            if (line.replaceAll("\\s","").toLowerCase().startsWith(endFilePrefix.replaceAll("\\s",""))) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
                if (!inFilePrefix) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
                    error("excess '" + endFilePrefix + "'");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
                inFilePrefix = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
    void fill(SourceFile filledSF) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
        // copy beginning of file straight from filled file
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
        top = filledSF.top;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
        // file in functions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
        Iterator it = functions.iterator();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
        while (it.hasNext()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
            Function stubFunc = (Function)(it.next());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
            Function filledFunc = (Function)filledSF.functionMap.get(stubFunc.name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
            stubFunc.fill(filledFunc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
        if (filledSF.functionMap.size() > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
            System.err.println("Warning: the following functions were present in the " +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
                                "filled file but missing in the stub file and thus not copied:");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
            it  = filledSF.functionMap.values().iterator();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
            while (it.hasNext()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
                System.err.println("        " + ((Function)(it.next())).name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
    void output(PrintWriter out) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
        Iterator it = top.iterator();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
        while (it.hasNext()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
            out.println(it.next());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
        it = functions.iterator();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
        while (it.hasNext()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
            Function stubFunc = (Function)(it.next());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
            stubFunc.output(out);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
}