Search in sources :

Example 1 with JrmpGenerator

use of sun.rmi.rmic.newrmic.jrmp.JrmpGenerator in project jdk8u_jdk by JetBrains.

the class Main method parseArgs.

/**
     * 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.
     **/
private Batch parseArgs(String[] args) {
    Batch batch = new Batch();
    /*
         * Pre-process command line for @file arguments.
         */
    try {
        args = CommandLine.parse(args);
    } catch (FileNotFoundException e) {
        error("rmic.cant.read", e.getMessage());
        return null;
    } catch (IOException e) {
        e.printStackTrace(out);
        return null;
    }
    for (int i = 0; i < args.length; i++) {
        if (args[i] == null) {
            // already processed by a generator
            continue;
        } else if (args[i].equals("-Xnew")) {
            // we're already using the "new" implementation
            args[i] = null;
        } else if (args[i].equals("-show")) {
            // obselete: fail
            error("rmic.option.unsupported", args[i]);
            usage();
            return null;
        } else if (args[i].equals("-O")) {
            // obselete: warn but tolerate
            error("rmic.option.unsupported", args[i]);
            args[i] = null;
        } else if (args[i].equals("-debug")) {
            // obselete: warn but tolerate
            error("rmic.option.unsupported", args[i]);
            args[i] = null;
        } else if (args[i].equals("-depend")) {
            // obselete: warn but tolerate
            // REMIND: should this fail instead?
            error("rmic.option.unsupported", args[i]);
            args[i] = null;
        } else if (args[i].equals("-keep") || args[i].equals("-keepgenerated")) {
            batch.keepGenerated = true;
            args[i] = null;
        } else if (args[i].equals("-g")) {
            batch.debug = true;
            args[i] = null;
        } else if (args[i].equals("-nowarn")) {
            batch.noWarn = true;
            args[i] = null;
        } else if (args[i].equals("-nowrite")) {
            batch.noWrite = true;
            args[i] = null;
        } else if (args[i].equals("-verbose")) {
            batch.verbose = true;
            args[i] = null;
        } else if (args[i].equals("-Xnocompile")) {
            batch.noCompile = true;
            batch.keepGenerated = true;
            args[i] = null;
        } else if (args[i].equals("-bootclasspath")) {
            if ((i + 1) >= args.length) {
                error("rmic.option.requires.argument", args[i]);
                usage();
                return null;
            }
            if (batch.bootClassPath != null) {
                error("rmic.option.already.seen", args[i]);
                usage();
                return null;
            }
            args[i] = null;
            batch.bootClassPath = args[++i];
            assert batch.bootClassPath != null;
            args[i] = null;
        } else if (args[i].equals("-extdirs")) {
            if ((i + 1) >= args.length) {
                error("rmic.option.requires.argument", args[i]);
                usage();
                return null;
            }
            if (batch.extDirs != null) {
                error("rmic.option.already.seen", args[i]);
                usage();
                return null;
            }
            args[i] = null;
            batch.extDirs = args[++i];
            assert batch.extDirs != null;
            args[i] = null;
        } else if (args[i].equals("-classpath")) {
            if ((i + 1) >= args.length) {
                error("rmic.option.requires.argument", args[i]);
                usage();
                return null;
            }
            if (batch.classPath != null) {
                error("rmic.option.already.seen", args[i]);
                usage();
                return null;
            }
            args[i] = null;
            batch.classPath = args[++i];
            assert batch.classPath != null;
            args[i] = null;
        } else if (args[i].equals("-d")) {
            if ((i + 1) >= args.length) {
                error("rmic.option.requires.argument", args[i]);
                usage();
                return null;
            }
            if (batch.destDir != null) {
                error("rmic.option.already.seen", args[i]);
                usage();
                return null;
            }
            args[i] = null;
            batch.destDir = new File(args[++i]);
            assert batch.destDir != null;
            args[i] = null;
            if (!batch.destDir.exists()) {
                error("rmic.no.such.directory", batch.destDir.getPath());
                usage();
                return null;
            }
        } else if (args[i].equals("-v1.1") || args[i].equals("-vcompat") || args[i].equals("-v1.2")) {
            Generator gen = new JrmpGenerator();
            batch.generators.add(gen);
            // JrmpGenerator only requires base BatchEnvironment class
            if (!gen.parseArgs(args, this)) {
                return null;
            }
        } else if (args[i].equalsIgnoreCase("-iiop")) {
            error("rmic.option.unimplemented", args[i]);
            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;
        // }
        } else if (args[i].equalsIgnoreCase("-idl")) {
            error("rmic.option.unimplemented", args[i]);
            return null;
        // see implementation sketch above
        } else if (args[i].equalsIgnoreCase("-xprint")) {
            error("rmic.option.unimplemented", args[i]);
            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.
         */
    for (int i = 0; i < args.length; i++) {
        if (args[i] != null) {
            if (args[i].startsWith("-")) {
                error("rmic.no.such.option", args[i]);
                usage();
                return null;
            } else {
                batch.classes.add(args[i]);
            }
        }
    }
    if (batch.classes.isEmpty()) {
        usage();
        return null;
    }
    /*
         * If options did not specify at least one protocol-specific
         * generator, then JRMP is the default.
         */
    if (batch.generators.isEmpty()) {
        batch.generators.add(new JrmpGenerator());
    }
    return batch;
}
Also used : JrmpGenerator(sun.rmi.rmic.newrmic.jrmp.JrmpGenerator) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) File(java.io.File) JrmpGenerator(sun.rmi.rmic.newrmic.jrmp.JrmpGenerator)

Aggregations

File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 JrmpGenerator (sun.rmi.rmic.newrmic.jrmp.JrmpGenerator)1