src/share/classes/com/sun/tools/sjavac/Transformer.java

changeset 1570
f91144b7da75
parent 1504
22e417cdddee
child 2227
998b10c43157
equal deleted inserted replaced
1569:475eb15dfdad 1570:f91144b7da75
1 /*
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package com.sun.tools.sjavac;
27
28 import java.io.PrintStream;
29 import java.net.URI;
30 import java.util.Set;
31 import java.util.Map;
32
33 /**
34 * The transform interface is used to transform content inside a package, from one form to another.
35 * Usually the output form is an unpredictable number of output files. (eg class files)
36 * but can also be an unpredictable number of generated source files (eg idl2java)
37 * or a single predictable output file (eg when copying,cleaning or compiling a properties file).
38 *
39 * <p><b>This is NOT part of any supported API.
40 * If you write code that depends on this, you do so at your own
41 * risk. This code and its internal interfaces are subject to change
42 * or deletion without notice.</b></p>
43 */
44 public interface Transformer
45 {
46 /**
47 * The transform method takes a set of package names, mapped to their source files and to the
48 * pubapis of the packages.
49 *
50 * The transform implementation must:
51 * store the names of the generated artifacts for each package into package_artifacts
52 * store found dependencies to other packages into the supplied set package_dependencies
53 * store the public api for a package into the supplied set package_pubapis
54 *
55 * Any benign messages as a result of running the transform
56 * are written into stdout, and errors are written to stderr.
57 *
58 * The debug_level can be 0=silent (only warnings and errors) 1=normal 2=verbose 3 or greater=debug
59 * setExtra is used to set the extra information information that can be passed on
60 * the command line to the smart javac wrapper.
61 *
62 * If sjavac is building incrementally from an existing javac_state, the var incremental is true.
63 *
64 * The transformer will only be called if some source in the package (or dependency) has
65 * a modified timestamp. Thus the transformer might get called with many sources, of which
66 * only one has changed. The transformer is allowed to regenerate all artifacts but
67 * a better transformer will only write those artifacts that need updating.
68 *
69 * However the transformer must verify that the existing artifacts really are there!
70 * and it must always update package_artifacts, package_dependencies, and package_pubapis correctly.
71 * This means that at least for Java source, it will always have to recompile the sources.
72 *
73 * The transformer is allowed to put files anywhere in the dest_root.
74 * An example of this is, can be the META-INF transformer that copy files
75 * below META-INF directories to the single META-INF directory below dest_root.
76 *
77 * False is returned if there was an error that prevented the transform.
78 * I.e. something was printed on stderr.
79 *
80 * If num_cores is set to a non-zero value. The transform should attempt to use no more than these
81 * number of threads for heavy work.
82 */
83 boolean transform(Map<String,Set<URI>> pkgSrcs,
84 Set<URI> visibleSources,
85 Map<URI,Set<String>> visibleClasses,
86 Map<String,Set<String>> oldPackageDependencies,
87 URI destRoot,
88 Map<String,Set<URI>> packageArtifacts,
89 Map<String,Set<String>> packageDependencies,
90 Map<String,String> packagePublicApis,
91 int debugLevel,
92 boolean incremental,
93 int numCores,
94 PrintStream out,
95 PrintStream err);
96
97 void setExtra(String e);
98 void setExtra(String[] args);
99 }

mercurial