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

Tue, 24 Dec 2013 09:17:37 -0800

author
ksrini
date
Tue, 24 Dec 2013 09:17:37 -0800
changeset 2227
998b10c43157
parent 1504
22e417cdddee
child 2525
2eb010b6cb22
permissions
-rw-r--r--

8029230: Update copyright year to match last edit in jdk8 langtools repository for 2013
Reviewed-by: ksrini
Contributed-by: steve.sides@oracle.com

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

mercurial