/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* The rmic front end. This class contains the "main" method for rmic
* command line invocation.
*
* A Main instance contains the stream to output error messages and
* other diagnostics to.
*
* An rmic compilation batch (for example, one rmic command line
* invocation) is executed by invoking the "compile" method of a Main
* instance.
*
* WARNING: The contents of this source file are not part of any
* supported API. Code that depends on them does so at its own risk:
* they are subject to change or removal without notice.
*
* NOTE: If and when there is a J2SE API for invoking SDK tools, this
* class should be updated to support that API.
*
* NOTE: This class is the front end for a "new" rmic implementation,
* which uses javadoc and the doclet API for reading class files and
* javac for compiling generated source files. This implementation is
* incomplete: it lacks any CORBA-based back end implementations, and
* thus the command line options "-idl", "-iiop", and their related
* options are not yet supported. The front end for the "old",
* oldjavac-based rmic implementation is sun.rmi.rmic.Main.
*
* @author Peter Jones
**/
public class Main {
/*
* Implementation note:
*
* In order to use the doclet API to read class files, much of
* this implementation of rmic executes as a doclet within an
* invocation of javadoc. This class is used as the doclet class
* for such javadoc invocations, via its static "start" and
* "optionLength" methods. There is one javadoc invocation per
* rmic compilation batch.
*
* The only guaranteed way to pass data to a doclet through a
* javadoc invocation is through doclet-specific options on the
* javadoc "command line". Rather than passing numerous pieces of
* individual data in string form as javadoc options, we use a
* single doclet-specific option ("-batchID") to pass a numeric
* identifier that uniquely identifies the rmic compilation batch
* that the javadoc invocation is for, and that identifier can
* then be used as a key in a global table to retrieve an object
* containing all of batch-specific data (rmic command line
* arguments, etc.).
*/
/** guards "batchCount" */
/** number of batches run; used to generated batch IDs */
/** maps batch ID to batch data */
/** stream to output error messages and other diagnostics to */
/** name of this program, to use in error messages */
/**
* Command line entry point.
**/
}
/**
* Creates a Main instance that writes output to the specified
* stream. The specified program name is used in error messages.
**/
}
/**
* Compiles a batch of input classes, as given by the specified
* command line arguments. Protocol-specific generators are
* determined by the choice options on the command line. Returns
* true if successful, or false if an error occurred.
*
* NOTE: This method is retained for transitional consistency with
* previous implementations.
**/
long batchID;
synchronized (batchCountLock) {
}
// process command line
return false; // terminate if error occurred
}
/*
* With the batch data retrievable in the global table, run
* javadoc to continue the rest of the batch's compliation as
* a doclet.
*/
boolean status;
try {
} finally {
}
}
return status;
}
/**
* Prints the specified string to the output stream of this Main
* instance.
**/
}
/**
* Prints an error message to the output stream of this Main
* instance. The first argument is used as a key in rmic's
* resource bundle, and the rest of the arguments are used as
* arguments in the formatting of the resource string.
**/
}
/**
* Prints rmic's usage message to the output stream of this Main
* instance.
*
* This method is public so that it can be used by the "parseArgs"
* methods of Generator implementations.
**/
public void usage() {
}
/**
* Processes rmic command line arguments. Returns a Batch object
* representing the command line arguments if successful, or null
* if an error occurred. Processed elements of the args array are
* set to null.
**/
/*
* Pre-process command line for @file arguments.
*/
try {
} catch (FileNotFoundException e) {
return null;
} catch (IOException e) {
e.printStackTrace(out);
return null;
}
// already processed by a generator
continue;
// we're already using the "new" implementation
// obselete: fail
usage();
return null;
// obselete: warn but tolerate
// obselete: warn but tolerate
// obselete: warn but tolerate
// REMIND: should this fail instead?
{
batch.keepGenerated = true;
batch.keepGenerated = true;
usage();
return null;
}
usage();
return null;
}
usage();
return null;
}
usage();
return null;
}
usage();
return null;
}
usage();
return null;
}
usage();
return null;
}
usage();
return null;
}
usage();
return null;
}
{
// JrmpGenerator only requires base BatchEnvironment class
return null;
}
return null;
// Generator gen = new IiopGenerator();
// batch.generators.add(gen);
// if (!batch.envClass.isAssignableFrom(gen.envClass())) {
// error("rmic.cannot.use.both",
// batch.envClass.getName(), gen.envClass().getName());
// return null;
// }
// batch.envClass = gen.envClass();
// if (!gen.parseArgs(args, this)) {
// return null;
// }
return null;
// see implementation sketch above
return null;
// see implementation sketch above
}
}
/*
* At this point, all that remains non-null in the args
* array are input class names or illegal options.
*/
usage();
return null;
} else {
}
}
}
usage();
return null;
}
/*
* If options did not specify at least one protocol-specific
* generator, then JRMP is the default.
*/
}
return batch;
}
/**
* Doclet class entry point.
**/
/*
* Find batch ID among javadoc options, and retrieve
* corresponding batch data from global table.
*/
long batchID = -1;
try {
} catch (NumberFormatException e) {
throw new AssertionError(e);
}
}
}
/*
* Construct batch environment using class agreed upon by
* generator implementations.
*/
try {
} catch (NoSuchMethodException e) {
throw new AssertionError(e);
} catch (IllegalAccessException e) {
throw new AssertionError(e);
} catch (InstantiationException e) {
throw new AssertionError(e);
} catch (InvocationTargetException e) {
throw new AssertionError(e);
}
/*
* Determine the destination directory (the top of the package
* hierarchy) for the output of this batch; if no destination
* directory was specified on the command line, then the
* default is the current working directory.
*/
}
/*
* Run each input class through each generator.
*/
try {
}
} catch (NullPointerException e) {
/*
* We assume that this means that some class that was
* needed (perhaps even a bootstrap class) was not
* found, and that javadoc has already reported this
* as an error. There is nothing for us to do here
* but try to continue with the next input class.
*
* REMIND: More explicit error checking throughout
* would be preferable, however.
*/
}
}
/*
* Compile any generated source files, if configured to do so.
*/
boolean status = true;
}
/*
* Delete any generated source files, if configured to do so.
*/
if (!batch.keepGenerated) {
}
}
return status;
}
/**
* Doclet class method that indicates that this doclet class
* recognizes (only) the "-batchID" option on the javadoc command
* line, and that the "-batchID" option comprises two arguments on
* the javadoc command line.
**/
return 2;
} else {
return 0;
}
}
/**
* Runs the javadoc tool to invoke this class as a doclet, passing
* command line options derived from the specified batch data and
* indicating the specified batch ID.
*
* NOTE: This method currently uses a J2SE-internal API to run
* javadoc. If and when there is a J2SE API for invoking SDK
* tools, this method should be updated to use that API instead.
**/
// include all types, regardless of language-level access
// inputs are class names, not source files
// reproduce relevant options from rmic invocation
}
}
}
}
// specify batch ID
/*
* Run javadoc on union of rmic input classes and all
* generators' bootstrap classes, so that they will all be
* available to the doclet code.
*/
}
for (String s : classNames) {
javadocArgs.add(s);
}
// run javadoc with our program name and output stream
new PrintWriter(out, true),
new PrintWriter(out, true),
new PrintWriter(out, true),
return status == 0;
}
/**
* Runs the javac tool to compile the specified source files,
* passing command line options derived from the specified batch
* data.
*
* NOTE: This method currently uses a J2SE-internal API to run
* javac. If and when there is a J2SE API for invoking SDK tools,
* this method should be updated to use that API instead.
**/
// rmic never wants to display javac warnings
// reproduce relevant options from rmic invocation
}
}
}
}
}
/*
* For now, rmic still always produces class files that have a
* class file format version compatible with JDK 1.1.
*/
// add source files to compile
}
// run javac with our output stream
new PrintWriter(out, true));
return status == 0;
}
/**
* The data for an rmic compliation batch: the processed command
* line arguments.
**/
private class Batch {
Batch() { }
/**
* Returns the Main instance for this batch.
**/
return Main.this;
}
}
}