1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/classes/com/sun/tools/sjavac/Transformer.java Mon Feb 04 18:08:53 2013 -0500 1.3 @@ -0,0 +1,99 @@ 1.4 +/* 1.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. Oracle designates this 1.11 + * particular file as subject to the "Classpath" exception as provided 1.12 + * by Oracle in the LICENSE file that accompanied this code. 1.13 + * 1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.17 + * version 2 for more details (a copy is included in the LICENSE file that 1.18 + * accompanied this code). 1.19 + * 1.20 + * You should have received a copy of the GNU General Public License version 1.21 + * 2 along with this work; if not, write to the Free Software Foundation, 1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.23 + * 1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.25 + * or visit www.oracle.com if you need additional information or have any 1.26 + * questions. 1.27 + */ 1.28 + 1.29 +package com.sun.tools.sjavac; 1.30 + 1.31 +import java.io.PrintStream; 1.32 +import java.net.URI; 1.33 +import java.util.Set; 1.34 +import java.util.Map; 1.35 + 1.36 +/** 1.37 + * The transform interface is used to transform content inside a package, from one form to another. 1.38 + * Usually the output form is an unpredictable number of output files. (eg class files) 1.39 + * but can also be an unpredictable number of generated source files (eg idl2java) 1.40 + * or a single predictable output file (eg when copying,cleaning or compiling a properties file). 1.41 + * 1.42 + * <p><b>This is NOT part of any supported API. 1.43 + * If you write code that depends on this, you do so at your own 1.44 + * risk. This code and its internal interfaces are subject to change 1.45 + * or deletion without notice.</b></p> 1.46 + */ 1.47 +public interface Transformer 1.48 +{ 1.49 + /** 1.50 + * The transform method takes a set of package names, mapped to their source files and to the 1.51 + * pubapis of the packages. 1.52 + * 1.53 + * The transform implementation must: 1.54 + * store the names of the generated artifacts for each package into package_artifacts 1.55 + * store found dependencies to other packages into the supplied set package_dependencies 1.56 + * store the public api for a package into the supplied set package_pubapis 1.57 + * 1.58 + * Any benign messages as a result of running the transform 1.59 + * are written into stdout, and errors are written to stderr. 1.60 + * 1.61 + * The debug_level can be 0=silent (only warnings and errors) 1=normal 2=verbose 3 or greater=debug 1.62 + * setExtra is used to set the extra information information that can be passed on 1.63 + * the command line to the smart javac wrapper. 1.64 + * 1.65 + * If sjavac is building incrementally from an existing javac_state, the var incremental is true. 1.66 + * 1.67 + * The transformer will only be called if some source in the package (or dependency) has 1.68 + * a modified timestamp. Thus the transformer might get called with many sources, of which 1.69 + * only one has changed. The transformer is allowed to regenerate all artifacts but 1.70 + * a better transformer will only write those artifacts that need updating. 1.71 + * 1.72 + * However the transformer must verify that the existing artifacts really are there! 1.73 + * and it must always update package_artifacts, package_dependencies, and package_pubapis correctly. 1.74 + * This means that at least for Java source, it will always have to recompile the sources. 1.75 + * 1.76 + * The transformer is allowed to put files anywhere in the dest_root. 1.77 + * An example of this is, can be the META-INF transformer that copy files 1.78 + * below META-INF directories to the single META-INF directory below dest_root. 1.79 + * 1.80 + * False is returned if there was an error that prevented the transform. 1.81 + * I.e. something was printed on stderr. 1.82 + * 1.83 + * If num_cores is set to a non-zero value. The transform should attempt to use no more than these 1.84 + * number of threads for heavy work. 1.85 + */ 1.86 + boolean transform(Map<String,Set<URI>> pkgSrcs, 1.87 + Set<URI> visibleSources, 1.88 + Map<URI,Set<String>> visibleClasses, 1.89 + Map<String,Set<String>> oldPackageDependencies, 1.90 + URI destRoot, 1.91 + Map<String,Set<URI>> packageArtifacts, 1.92 + Map<String,Set<String>> packageDependencies, 1.93 + Map<String,String> packagePublicApis, 1.94 + int debugLevel, 1.95 + boolean incremental, 1.96 + int numCores, 1.97 + PrintStream out, 1.98 + PrintStream err); 1.99 + 1.100 + void setExtra(String e); 1.101 + void setExtra(String[] args); 1.102 +}