⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 defaultrmicadapter.java

📁 Use the links below to download a source distribution of Ant from one of our mirrors. It is good pra
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        compilerArgs = preprocessCompilerArgs(compilerArgs);        cmd.addArguments(compilerArgs);        logAndAddFilesToCompile(cmd);        return cmd;     }    /**     * This is an override point; get the stub version off the rmic command and     * translate that into a compiler-specific argument     * @return a string to use for the stub version; can be null     * @since Ant1.7.1     */    protected String addStubVersionOptions() {        //handle the many different stub options.        String stubVersion = attributes.getStubVersion();        //default is compatibility        String stubOption = null;        if (null != stubVersion) {            if (STUB_OPTION_1_1.equals(stubVersion)) {                stubOption = STUB_1_1;            } else if (STUB_OPTION_1_2.equals(stubVersion)) {                stubOption = STUB_1_2;            } else if (STUB_OPTION_COMPAT.equals(stubVersion)) {                stubOption = STUB_COMPAT;            } else {                //anything else                attributes.log("Unknown stub option " + stubVersion);                //do nothing with the value? or go -v+stubVersion??            }        }        //for java1.5+, we generate compatible stubs, that is, unless        //the caller asked for IDL or IIOP support.        if (stubOption == null            && !attributes.getIiop()            && !attributes.getIdl()) {            stubOption = STUB_COMPAT;        }        return stubOption;    }    /**     * Preprocess the compiler arguments in any way you see fit.     * This is to allow compiler adapters to validate or filter the arguments.     * The base implementation returns the original compiler arguments unchanged.     * @param compilerArgs the original compiler arguments     * @return the filtered set.     */    protected String[] preprocessCompilerArgs(String[] compilerArgs) {        return compilerArgs;    }    /**     * Strip out all -J args from the command list. Invoke this from     * {@link #preprocessCompilerArgs(String[])} if you have a non-forking     * compiler.     * @param compilerArgs the original compiler arguments     * @return the filtered set.     */    protected String[] filterJvmCompilerArgs(String[] compilerArgs) {        int len = compilerArgs.length;        List args = new ArrayList(len);        for (int i = 0; i < len; i++) {            String arg = compilerArgs[i];            if (!arg.startsWith("-J")) {                args.add(arg);            } else {                attributes.log("Dropping " + arg + " from compiler arguments");            }        }        int count = args.size();        return (String[]) args.toArray(new String[count]);    }    /**     * Logs the compilation parameters, adds the files to compile and logs the     * &quot;niceSourceList&quot;     * @param cmd the commandline args     */    protected void logAndAddFilesToCompile(Commandline cmd) {        Vector compileList = attributes.getCompileList();        attributes.log("Compilation " + cmd.describeArguments(),                       Project.MSG_VERBOSE);        StringBuffer niceSourceList = new StringBuffer("File");        int cListSize = compileList.size();        if (cListSize != 1) {            niceSourceList.append("s");        }        niceSourceList.append(" to be compiled:");        for (int i = 0; i < cListSize; i++) {            String arg = (String) compileList.elementAt(i);            cmd.createArgument().setValue(arg);            niceSourceList.append("    ");            niceSourceList.append(arg);        }        attributes.log(niceSourceList.toString(), Project.MSG_VERBOSE);    }    /**     * Mapper that may return up to two file names.     *     * <ul>     *   <li>for JRMP it will return *_getStubClassSuffix (and     *   *_getSkelClassSuffix if JDK 1.1 is used)</li>     *     *   <li>for IDL it will return a random name, causing <rmic> to     *     always recompile.</li>     *     *   <li>for IIOP it will return _*_getStubClassSuffix for     *   interfaces and _*_getStubClassSuffix for non-interfaces (and     *   determine the interface and create _*_Stub from that).</li>     * </ul>     */    private class RmicFileNameMapper implements FileNameMapper {        RmicFileNameMapper() {        }        /**         * Empty implementation.         */        public void setFrom(String s) {        }        /**         * Empty implementation.         */        public void setTo(String s) {        }        public String[] mapFileName(String name) {            if (name == null                || !name.endsWith(".class")                || name.endsWith(getStubClassSuffix() + ".class")                || name.endsWith(getSkelClassSuffix() + ".class")                || name.endsWith(getTieClassSuffix() + ".class")) {                // Not a .class file or the one we'd generate                return null;            }            // we know that name.endsWith(".class")            String base = StringUtils.removeSuffix(name, ".class");            String classname = base.replace(File.separatorChar, '.');            if (attributes.getVerify()                && !attributes.isValidRmiRemote(classname)) {                return null;            }            /*             * fallback in case we have trouble loading the class or             * don't know how to handle it (there is no easy way to             * know what IDL mode would generate.             *             * This is supposed to make Ant always recompile the             * class, as a file of that name should not exist.             */            String[] target = new String[] {name + ".tmp." + RAND.nextLong()};            if (!attributes.getIiop() && !attributes.getIdl()) {                // JRMP with simple naming convention                if (STUB_OPTION_1_2.equals(attributes.getStubVersion())) {                    target = new String[] {                        base + getStubClassSuffix() + ".class"                    };                } else {                    target = new String[] {                        base + getStubClassSuffix() + ".class",                        base + getSkelClassSuffix() + ".class",                    };                }            } else if (!attributes.getIdl()) {                int lastSlash = base.lastIndexOf(File.separatorChar);                String dirname = "";                /*                 * I know, this is not necessary, but I prefer it explicit (SB)                 */                int index = -1;                if (lastSlash == -1) {                    // no package                    index = 0;                } else {                    index = lastSlash + 1;                    dirname = base.substring(0, index);                }                String filename = base.substring(index);                try {                    Class c = attributes.getLoader().loadClass(classname);                    if (c.isInterface()) {                        // only stub, no tie                        target = new String[] {                            dirname + "_" + filename + getStubClassSuffix()                            + ".class"                        };                    } else {                        /*                         * stub is derived from implementation,                         * tie from interface name.                         */                        Class interf = attributes.getRemoteInterface(c);                        String iName = interf.getName();                        String iDir = "";                        int iIndex = -1;                        int lastDot = iName.lastIndexOf(".");                        if (lastDot == -1) {                            // no package                            iIndex = 0;                        } else {                            iIndex = lastDot + 1;                            iDir = iName.substring(0, iIndex);                            iDir = iDir.replace('.', File.separatorChar);                        }                        target = new String[] {                            dirname + "_" + filename + getTieClassSuffix()                            + ".class",                            iDir + "_" + iName.substring(iIndex)                            + getStubClassSuffix() + ".class"                        };                    }                } catch (ClassNotFoundException e) {                    attributes.log("Unable to verify class " + classname                                   + ". It could not be found.",                                   Project.MSG_WARN);                } catch (NoClassDefFoundError e) {                    attributes.log("Unable to verify class " + classname                                   + ". It is not defined.", Project.MSG_WARN);                } catch (Throwable t) {                    attributes.log("Unable to verify class " + classname                                   + ". Loading caused Exception: "                                   + t.getMessage(), Project.MSG_WARN);                }            }            return target;        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -