harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ghar...@apache.org
Subject svn commit: r407625 [9/16] - in /incubator/harmony/enhanced/classlib/trunk/modules/rmi3: ./ doc/ make/ src/ src/common/ src/common/javasrc/ src/common/javasrc/java/ src/common/javasrc/java/rmi/ src/common/javasrc/java/rmi/activation/ src/common/javasrc...
Date Thu, 18 May 2006 20:01:30 GMT
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/ClassStub.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/ClassStub.java?rev=407625&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/ClassStub.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/ClassStub.java Thu May 18 13:01:22 2006
@@ -0,0 +1,1075 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author  Vasily Zakharov
+ * @version $Revision: 1.1.2.3 $
+ */
+package org.apache.harmony.rmi.compiler;
+
+import java.lang.reflect.Method;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.TreeMap;
+import java.util.Vector;
+
+import org.apache.harmony.rmi.common.ClassList;
+import org.apache.harmony.rmi.common.RMIHash;
+import org.apache.harmony.rmi.common.RMIHashException;
+import org.apache.harmony.rmi.common.RMIUtil;
+
+
+/**
+ * Generates RMI stub code for a particular class.
+ *
+ * @author  Vasily Zakharov
+ * @version $Revision: 1.1.2.3 $
+ */
+final class ClassStub implements RmicConstants {
+
+    /**
+     * Should the stub support v1.1.
+     */
+    final boolean v11;
+
+    /**
+     * Should the stub support v1.2.
+     */
+    final boolean v12;
+
+    /**
+     * Should the stub support both v1.1 and v1.2.
+     */
+    final boolean vCompat;
+
+    /**
+     * Indenter to write source files.
+     */
+    Indenter indenter;
+
+    /**
+     * Name of the class to generate stub for.
+     */
+    private final String className;
+
+    /**
+     * Package of the class to generate stub for.
+     */
+    private final String packageName;
+
+    /**
+     * Stub class name.
+     */
+    private final String stubName;
+
+    /**
+     * Skeleton class name.
+     */
+    private final String skelName;
+
+    /**
+     * List of remote interfaces for the class.
+     */
+    private final Class[] interfaces;
+
+    /**
+     * List of remote interfaces methods for the class.
+     */
+    private final Vector methods;
+
+    /**
+     * <code>true</code> if methods exist in {@link #methods} vector.
+     */
+    private final boolean methodsExist;
+
+    /**
+     * Class interface hash.
+     */
+    private final long interfaceHash;
+
+    /**
+     * Creates <code>ClassStub</code> instance for specified version and class.
+     *
+     * @param   version
+     *          Version of the stub to create.
+     *
+     * @param   className
+     *          Name of the class to load.
+     *
+     * @throws  RMICompilerException
+     *          If version number is incorrect or some other error occurs.
+     */
+    ClassStub(int version, String className) throws RMICompilerException {
+        this(version, getClass(className));
+    }
+
+    /**
+     * Creates <code>ClassStub</code> instance for specified version and class.
+     *
+     * @param   version
+     *          Version of the stub to create.
+     *
+     * @param   cls
+     *          Class to load.
+     *
+     * @throws  RMICompilerException
+     *          If version number is incorrect or some other error occurs.
+     */
+    ClassStub(int version, Class cls) throws RMICompilerException {
+        // Check version.
+        if ((version < MIN_VERSION) || (version > MAX_VERSION)) {
+            throw new RMICompilerException("Incorrect version specified.");
+        }
+
+        // Set appropriate version flags.
+        switch (version) {
+        case VERSION_V11:
+            v11 = true;
+            v12 = false;
+            vCompat = false;
+            break;
+        case VERSION_V12:
+            v11 = false;
+            v12 = true;
+            vCompat = false;
+            break;
+        case VERSION_VCOMPAT:
+            v11 = true;
+            v12 = true;
+            vCompat = true;
+            break;
+        default:
+            throw new RMICompilerException("Version currently unsupported.");
+        }
+
+        className = RMIUtil.getCanonicalName(cls);
+
+        // Check if the specified class is interface.
+        if (cls.isInterface()) {
+            throw new RMICompilerException("Class " + className
+                    + " is interface, and so does not need an RMI stub.");
+        }
+
+        // Check if the specified class is remote.
+        if (!Remote.class.isAssignableFrom(cls)) {
+            throw new RMICompilerException("Class " + className
+                    + " does not implement a remote interface,"
+                    + " and so does not need an RMI stub.");
+        }
+
+        // Check if the specified class implements any remote interfaces.
+        if (!new ClassList(cls.getInterfaces()).contains(Remote.class)) {
+            throw new RMICompilerException("Class " + className
+                    + " does not directly implement a remote interface,"
+                    + " and so does not need an RMI stub.");
+        }
+
+        // Initialize class variables.
+        packageName = RMIUtil.getPackageName(cls);
+
+        String shortClassName = RMIUtil.getShortName(cls);
+        stubName = shortClassName + stubSuffix;
+        skelName = shortClassName + skelSuffix;
+
+        try {
+            interfaces = RMIUtil.getRemoteInterfaces(cls);
+        } catch (IllegalArgumentException e) {
+            throw new RMICompilerException(e);
+        }
+
+        methods = new Vector();
+
+        // Create temporal method stubs table (sorted, no duplicates).
+        TreeMap methodMap = new TreeMap();
+
+        // Extract remote methods from remote interfaces of cls and ancestors.
+        for (int i = 0; i < interfaces.length; i++) {
+            // Add public methods from this interface to the map.
+            RMIHash.getSortedMethodMap(methodMap, interfaces[i].getMethods());
+        }
+
+        if (v11) {
+            try {
+                // Calculate interface hash value for the set of methods found.
+                interfaceHash = RMIHash.getInterfaceHash(methodMap);
+            } catch (RMIHashException e) {
+                throw new RMICompilerException(e.getMessage(), e.getCause());
+            }
+        } else {
+            interfaceHash = (-1L);
+        }
+
+        // Put the complete MethodStub objects to methods list.
+        int n = 0;
+        for (Iterator i = methodMap.values().iterator(); i.hasNext(); ) {
+            methods.add(new MethodStub((Method) i.next(), n++));
+        }
+
+        methodsExist = (n > 0);
+    }
+
+    /**
+     * Returns the class object for the specified class name.
+     *
+     * @param   className
+     *          Class name.
+     *
+     * @return  Class object for the specified class name.
+     *
+     * @throws  RMICompilerException
+     *          If class is not found.
+     */
+    private static Class getClass(String className)
+            throws RMICompilerException {
+        try {
+            return Class.forName(className);
+        } catch (ClassNotFoundException e) {
+            throw new RMICompilerException("Class not found: " + className);
+        }
+    }
+
+    /**
+     * Returns stub class name for loaded class.
+     *
+     * @return  Stub class name.
+     */
+    String getStubClassName() {
+        return stubName;
+    }
+
+    /**
+     * Returns skeleton class name for loaded class.
+     *
+     * @return  Skeleton class name.
+     */
+    String getSkeletonClassName() {
+        return skelName;
+    }
+
+    /**
+     * Returns stub source code for the loaded class (v1.1/v1.2).
+     *
+     * @return  String containing the stub source code for loaded class.
+     */
+    String getStubSource() {
+        indenter = new Indenter();
+
+        return (getStubHeader("stub") + getPackageStatement() + EOLN
+                + getStubClassDeclaration() + indenter.hIncrease()
+                + (v12 ? (EOLN + getSerialVersionUID()) : "")
+                + (v11 ? (EOLN + getInterfaceHash() + (methodsExist
+                        ? ((vCompat ? EOLN + getNewInvoke() : "")
+                        + EOLN + getOperationsArrayDeclaration()) : "")) : "")
+                + ((v12 && methodsExist) ? (EOLN
+                        + getMethodVariablesDeclaration() + EOLN
+                        + getStaticInitializationBlock()) : "") + EOLN
+                + getStubConstructors()
+                + (methodsExist ? getMethodImplementations() : "")
+                + indenter.decrease() + '}' + EOLN + indenter.assertEmpty());
+    }
+
+    /**
+     * Returns skeleton source code for the loaded class (v1.1).
+     *
+     * @return  String containing the skeleton source code for loaded class.
+     */
+    String getSkeletonSource() {
+        indenter = new Indenter();
+
+        return (getStubHeader("skeleton") + getPackageStatement() + EOLN
+                + getSkeletonClassDeclaration()
+                + indenter.hIncrease() + EOLN + getInterfaceHash() + EOLN
+                + getOperationsArrayDeclaration() + EOLN
+                + getOperationsMethod() + EOLN + getDispatchMethod()
+                + indenter.decrease() + '}' + EOLN + indenter.assertEmpty());
+    }
+
+    /**
+     * Returns stub source code header
+     * (Stub/Skeleton v1.1/v1.2/vCompat).
+     *
+     * @param   type
+     *          Header type, <code>"stub"</code> or <code>"skeleton"</code>.
+     *
+     * @return  Stub/skeleton header.
+     */
+    private String getStubHeader(String type) {
+        return ("/*" + EOLN + " * RMI " + type + " class" + EOLN
+                + " * for class " + className + EOLN
+                + " * Compatible with stub protocol version "
+                + (v11 ? "1.1" : "") + (vCompat ? "/" : "")
+                + (v12 ? "1.2" : "") + EOLN + " *" + EOLN
+                + " * Generated by DRL RMI Compiler (rmic)." + EOLN
+                + " *" + EOLN + " * DO NOT EDIT!!!" + EOLN
+                + " * Contents subject to change without notice!" + EOLN
+                + " */" + EOLN);
+    }
+
+    /**
+     * Returns <code>package</code> statement
+     * (Stub/Skeleton v1.1/v1.2/vCompat).
+     *
+     * @return  <code>package</code> statement for stub/skeleton class.
+     */
+    private String getPackageStatement() {
+        return ((packageName == null) ? ""
+                : ("package " + packageName + ';' + EOLN + EOLN));
+    }
+
+    /**
+     * Returns stub class declaration
+     * (Stub v1.1/v1.2/vCompat).
+     *
+     * @return  Stub class declaration statement.
+     */
+    private String getStubClassDeclaration() {
+        StringBuffer buffer = new StringBuffer("public final class "
+                + stubName + " extends java.rmi.server.RemoteStub" + EOLN
+                + indenter.tIncrease(2) + "implements ");
+
+        // Add implemented interfaces list.
+        for (int i = 0; i < interfaces.length; i++) {
+            buffer.append(((i > 0) ? ", " : "" ) + interfaces[i].getName());
+        }
+
+        buffer.append(" {" + EOLN);
+
+        return buffer.toString();
+    }
+
+    /**
+     * Returns skeleton class declaration
+     * (Skeleton v1.1/vCompat).
+     *
+     * @return  Skeleton class declaration statement.
+     */
+    private String getSkeletonClassDeclaration() {
+        return ("public final class " + skelName
+                + " implements java.rmi.server.Skeleton {" + EOLN);
+    }
+
+    /**
+     * Returns <code>serialVersionUID</code> declaration
+     * (Stub v1.2/vCompat).
+     *
+     * @return  <code>serialVersionUID</code> declaration statement.
+     */
+    private String getSerialVersionUID() {
+        return (indenter.indent()
+                    + "private static final long serialVersionUID = 2;" + EOLN);
+    }
+
+    /**
+     * Returns <code>interfaceHash</code> declaration
+     * (Stub/Skeleton v1.1/vCompat).
+     *
+     * @return  <code>interfaceHash</code> declaration statement.
+     */
+    private String getInterfaceHash() {
+        return (indenter.indent() + "private static final long "
+                + interfaceHashVarName + " = " + interfaceHash + "L;" + EOLN);
+    }
+
+    /**
+     * Returns <code>useNewInvoke</code> declaration
+     * (Stub vCompat).
+     *
+     * @return  <code>useNewInvoke</code> declaration statement.
+     */
+    private String getNewInvoke() {
+        return (indenter.indent()
+                + "private static boolean " + useNewInvoke + ';'+ EOLN);
+    }
+
+    /**
+     * Returns <code>operations</code> array declaration
+     * (Stub/Skeleton v1.1/vCompat).
+     *
+     * @return  <code>operations</code> array declaration statement.
+     */
+    private String getOperationsArrayDeclaration() {
+        StringBuffer buffer = new StringBuffer(indenter.indent()
+                + "private static final java.rmi.server.Operation[]"
+                + " operations = {");
+
+        if (methodsExist) {
+            buffer.append(EOLN + indenter.hIncrease());
+
+            for (Iterator i = methods.iterator(); i.hasNext(); ) {
+                buffer.append(((MethodStub) i.next()).getOpsArrayElement()
+                        + (i.hasNext() ? "," : "" ) + EOLN);
+            }
+
+            buffer.append(indenter.decrease());
+        }
+
+        buffer.append("};" + EOLN);
+
+        return buffer.toString();
+    }
+
+    /**
+     * Returns <code>getOperations()</code> method declaration
+     * (Skeleton v1.1/vCompat).
+     *
+     * @return  <code>getOperations()</code> declaration statement.
+     */
+    private String getOperationsMethod() {
+        return (indenter.indent()
+                + "public java.rmi.server.Operation[] getOperations() {" + EOLN
+                + indenter.tIncrease()
+                + "return (java.rmi.server.Operation[]) operations.clone();"
+                + EOLN + indenter.indent() + '}' + EOLN);
+    }
+
+    /**
+     * Returns <code>dispatch()</code> method declaration
+     * (Skeleton v1.1/vCompat).
+     *
+     * @return  <code>dispatch()</code> method declaration statement.
+     */
+    private String getDispatchMethod() {
+        StringBuffer buffer = new StringBuffer(indenter.indent()
+                + "public void dispatch(java.rmi.Remote obj, "
+                + "java.rmi.server.RemoteCall call, int opnum, long hash) "
+                + "throws java.lang.Exception {" + EOLN + indenter.hIncrease());
+
+        if (vCompat) {
+            buffer.append(indenter.indent() + "if (opnum < 0) {" + EOLN
+                    + indenter.increase());
+
+            if (methodsExist) {
+                for (Iterator i = methods.iterator(); i.hasNext(); ) {
+                    buffer.append(((MethodStub) i.next()).getHashCheck());
+                }
+                buffer.append('{' + EOLN + indenter.increase());
+            }
+
+            buffer.append("throw new java.rmi.UnmarshalException("
+                    + "\"Invalid method hash: \" + hash);" + EOLN
+                    + indenter.decrease() + '}' + EOLN
+                    + (methodsExist ? (indenter.tDecrease() + "} else {") : "")
+                    + EOLN);
+        }
+
+        buffer.append(indenter.indent() + "if (hash != interfaceHash) {" + EOLN
+                + indenter.increase()
+                + "throw new java.rmi.server.SkeletonMismatchException(" + EOLN
+                + indenter.tIncrease(2)
+                + "\"Interface hash mismatch, expected: \" + interfaceHash"
+                + " + \", received: \" + hash);" + EOLN
+                + indenter.decrease() + '}' + EOLN + ((vCompat && methodsExist)
+                        ? (indenter.decrease() + '}' + EOLN) : "") + EOLN
+                + indenter.indent() + className + " server = "
+                    + '(' + className + ") obj;" + EOLN + EOLN);
+
+        if (methodsExist) {
+            buffer.append(indenter.indent() + "switch (opnum) {" + EOLN);
+
+            for (Iterator i = methods.iterator(); i.hasNext(); ) {
+                buffer.append(EOLN + ((MethodStub) i.next()).getDispatchCase());
+            }
+
+            buffer.append(EOLN + indenter.indent() + "default:" + EOLN);
+
+            indenter.increase();
+        }
+
+        buffer.append(indenter.indent()
+                + "throw new java.rmi.UnmarshalException("
+                + "\"Invalid method number: \" + opnum);" + EOLN
+                + (methodsExist ? (indenter.decrease() + '}' + EOLN) : "")
+                + indenter.decrease() + '}' + EOLN);
+
+        return buffer.toString();
+    }
+
+    /**
+     * Returns method variables declaration block
+     * (Stub v1.2/vCompat).
+     *
+     * @return  Variables declaration block.
+     */
+    private String getMethodVariablesDeclaration() {
+        StringBuffer buffer = new StringBuffer();
+
+        for (Iterator i = methods.iterator(); i.hasNext(); ) {
+            buffer.append(((MethodStub) i.next()).getVariableDecl());
+        }
+
+        return buffer.toString();
+    }
+
+    /**
+     * Creates static initialization block
+     * (Stub v1.2/vCompat).
+     *
+     * @return  Static initialization declaration block.
+     */
+    private String getStaticInitializationBlock() {
+        StringBuffer buffer = new StringBuffer(indenter.indent()
+                + "static {" + EOLN + indenter.increase() + "try {" + EOLN
+                + indenter.hIncrease());
+
+        if (vCompat) {
+            buffer.append(indenter.indent()
+                    + "java.rmi.server.RemoteRef.class.getMethod(\"invoke\", "
+                    + "new java.lang.Class[] {java.rmi.Remote.class, "
+                    + "java.lang.reflect.Method.class, java.lang.Object[].class"
+                    + ", long.class});" + EOLN + EOLN);
+        }
+
+        for (Iterator i = methods.iterator(); i.hasNext(); ) {
+            buffer.append(((MethodStub) i.next()).getVariableInit());
+        }
+
+        buffer.append((vCompat ? (EOLN + indenter.indent() + useNewInvoke
+                + " = true;" + EOLN) : "") + indenter.decrease()
+                + "} catch (java.lang.NoSuchMethodException e) {" + EOLN
+                + indenter.increase()
+                + (vCompat ? (useNewInvoke + " = false;")
+                        : ("throw new java.lang.NoSuchMethodError(" + EOLN
+                                + indenter.tIncrease(2)
+                                + "\"Stub class initialization failed: "
+                                + ((packageName != null)
+                                        ? (packageName + '.') : "")
+                                + stubName + "\");")) + EOLN
+                + indenter.decrease() + '}' + EOLN
+                + indenter.decrease() + '}' + EOLN);
+
+        return buffer.toString();
+    }
+
+    /**
+     * Returns stub constructors
+     * (Stub v1.1/v1.2/vCompat).
+     *
+     * @return  Stub constructors code.
+     */
+    private String getStubConstructors() {
+        StringBuffer buffer = new StringBuffer();
+
+        if (v11) {
+            buffer.append(indenter.indent() + "public " + stubName
+                    + "() {" + EOLN + indenter.tIncrease() + "super();" + EOLN
+                    + indenter.indent() + '}' + EOLN + EOLN);
+        }
+
+        buffer.append(indenter.indent() + "public " + stubName
+                + "(java.rmi.server.RemoteRef ref) {" + EOLN
+                + indenter.tIncrease() + "super(ref);" + EOLN
+                + indenter.indent() + '}' + EOLN);
+
+        return buffer.toString();
+    }
+
+    /**
+     * Returns remote methods implementation
+     * (Stub v1.1/v1.2/vCompat).
+     *
+     * @return  Stub method implementations code.
+     */
+    private String getMethodImplementations() {
+        StringBuffer buffer = new StringBuffer();
+
+        for (Iterator i = methods.iterator(); i.hasNext(); ) {
+            buffer.append(EOLN + ((MethodStub) i.next()).getStubImpl());
+        }
+
+        return buffer.toString();
+    }
+
+    /**
+     * Generates RMI stub code for a particular method.
+     */
+    private final class MethodStub {
+
+        /**
+         * The method name (via {@link Method#getName()}).
+         */
+        private final String name;
+
+        /**
+         * The name of the interface declaring this method.
+         */
+        private final String interfaceName;
+
+        /**
+         * The method parameters (via {@link Method#getParameterTypes()}).
+         */
+        private final Class[] parameters;
+
+        /**
+         * The method parameters class names.
+         */
+        private final String[] paramClassNames;
+
+        /**
+         * The method parameters names.
+         */
+        private final String[] paramNames;
+
+        /**
+         * Number of parameters for this method.
+         */
+        private final int numParams;
+
+        /**
+         * The method return type (via {@link Method#getReturnType()}).
+         */
+        private final Class retType;
+
+        /**
+         * The method return type name.
+         */
+        private final String retTypeName;
+
+        /**
+         * Exceptions that this method throws.
+         */
+        private final Vector exceptions;
+
+        /**
+         * Exceptions that must be caught in method stub.
+         */
+        private final ClassList catches;
+
+        /**
+         * The method long signature
+         * (via {@link RMIUtil#getLongMethodSignature(Method)
+         * getLongMethodSignature()}).
+         */
+        private final String longSign;
+
+        /**
+         * The method short signature
+         * (via {@link RMIUtil#getShortMethodSignature(Method)
+         * getShortMethodSignature()}).
+         */
+        private final String shortSign;
+
+        /**
+         * The method hash (via {@link RMIHash#getMethodHash(Method)
+         * getMethodHash()}).
+         */
+        private final long hash;
+
+        /**
+         * The method number in the stub.
+         */
+        private final int number;
+
+        /**
+         * Name of the variable containing this method in the stub
+         * (<code>$method_<em>name</em>_<em>number</em></code>).
+         */
+        private final String varName;
+
+        /**
+         * Whether this method throws {@link Exception}.
+         */
+        private final boolean throwsException;
+
+        /**
+         * Creates method stub instance.
+         *
+         * @param   method
+         *          Method to process.
+         *
+         * @param   number
+         *          Method number in sorted methods table.
+         *
+         * @throws  RMICompilerException
+         *          If some error occurs.
+         */
+        MethodStub(Method method, int number) throws RMICompilerException {
+            this.name = method.getName();
+            this.interfaceName = method.getDeclaringClass().getName();
+            this.parameters = method.getParameterTypes();
+            this.numParams = parameters.length;
+            this.retType = method.getReturnType();
+            this.retTypeName = RMIUtil.getCanonicalName(retType);
+            this.longSign = RMIUtil.getLongMethodSignature(method);
+            this.shortSign = RMIUtil.getShortMethodSignature(method);
+            this.number = number;
+            this.varName = (methodVarPrefix + name + '_' + number);
+
+            try {
+                this.hash = RMIHash.getMethodHash(method);
+            } catch (RMIHashException e) {
+                throw new RMICompilerException(e.getMessage(), e);
+            }
+
+            // Create parameter names array.
+            paramClassNames = new String[numParams];
+            paramNames = new String[numParams];
+            for (int i = 0; i < numParams; i++) {
+                Class parameter = parameters[i];
+                paramClassNames[i] = RMIUtil.getCanonicalName(parameter);
+                paramNames[i] = RmicUtil.getParameterName(parameter, i + 1);
+            }
+
+            // Create list of exceptions declared thrown.
+            Class[] exceptionsArray = method.getExceptionTypes();
+            exceptions = new Vector(exceptionsArray.length);
+            exceptions.addAll(Arrays.asList(exceptionsArray));
+
+            // Create list of exceptions to be caught.
+            catches = new ClassList(true);
+
+            // Add standard exceptions to make sure they are first in the list.
+            catches.add(RuntimeException.class);
+            catches.add(RemoteException.class);
+
+            // Add declared thrown exceptions.
+            catches.addAll(exceptions);
+
+            throwsException = catches.contains(Exception.class);
+        }
+
+        /**
+         * Returns <code>operations</code> array element for this method
+         * (Stub/Skeleton v1.1/vCompat)
+         *
+         * @return  <code>operations</code> array element for this method.
+         */
+        String getOpsArrayElement() {
+            return (indenter.indent() +
+                        "new java.rmi.server.Operation(\"" + longSign + "\")");
+        }
+
+        /**
+         * Returns hash checking code for this method
+         * (Skeleton vCompat).
+         *
+         * @return  Hash checking code for this method..
+         */
+        String getHashCheck() {
+            return ("if (hash == " + hash + "L) {" + EOLN
+                    + indenter.tIncrease() + "opnum = " + number + ';' + EOLN
+                    + indenter.indent() + "} else ");
+        }
+
+        /**
+         * Returns <code>dispatch()</code> method case for this method
+         * (Skeleton v1.1/vCompat).
+         *
+         * @return  <code>dispatch()</code> method case for this method.
+         */
+        String getDispatchCase() {
+            StringBuffer buffer = new StringBuffer(indenter.indent()
+                    + "case " + number + ": {    // " + shortSign + EOLN + EOLN
+                    + indenter.hIncrease());
+
+            if (numParams > 0) {
+                // Add parameters declaration.
+                for (int i = 0; i < numParams; i++) {
+                    buffer.append(indenter.indent() + paramClassNames[i]
+                            + ' ' + paramNames[i] + ';' + EOLN);
+                }
+
+                // Access input stream.
+                buffer.append(EOLN + indenter.indent() + "try {" + EOLN
+                        + indenter.increase() + "java.io.ObjectInput "
+                        + inputStreamName + " = call.getInputStream();" + EOLN);
+
+                boolean objectParametersExist = false;
+
+                // Add parameters initialization, read them from the stream.
+                for (int i = 0; i < numParams; i++) {
+                    buffer.append(indenter.indent() + paramNames[i] + " = "
+                            + RmicUtil.getReadObjectString(parameters[i],
+                                    inputStreamName) + ';' + EOLN);
+
+                    if (!parameters[i].isPrimitive()) {
+                        objectParametersExist = true;
+                    }
+                }
+
+                // Add catch block.
+                buffer.append(indenter.tDecrease()
+                        + "} catch (java.io.IOException e) {" + EOLN
+                        + indenter.indent()
+                        + "throw new java.rmi.UnmarshalException("
+                        + "\"Error unmarshalling arguments\", e);" + EOLN
+                        + (objectParametersExist ? (indenter.tDecrease()
+                        + "} catch (java.lang.ClassNotFoundException e) {"
+                        + EOLN + indenter.indent()
+                        + "throw new java.rmi.UnmarshalException("
+                        + "\"Error unmarshalling arguments\", e);" + EOLN) : "")
+                        + indenter.tDecrease() + "} finally {" + EOLN);
+            }
+            // Release input stream.
+            buffer.append(indenter.indent()
+                    + "call.releaseInputStream();" + EOLN);
+
+            if (numParams > 0) {
+                buffer.append(indenter.decrease() + '}' + EOLN);
+            }
+
+            buffer.append(EOLN + indenter.indent() + ((retType != void.class)
+                    ? (retTypeName + ' ' + retVarName + " = ") : "")
+                    + "server." + name + '(');
+
+            for (int i = 0; i < numParams; i++) {
+                buffer.append(((i > 0) ? ", " : "") + paramNames[i]);
+            }
+
+            buffer.append(");" + EOLN + EOLN + indenter.indent() + "try {"
+                    + EOLN + indenter.increase() + ((retType != void.class)
+                    ? ("java.io.ObjectOutput " + outputStreamName + " = ") : "")
+                    + "call.getResultStream(true);" + EOLN
+                    + ((retType != void.class) ? (indenter.indent()
+                            + RmicUtil.getWriteObjectString(retType, retVarName,
+                                    outputStreamName) + ';' + EOLN) : "")
+                    + indenter.decrease() + "} catch (java.io.IOException e) {"
+                    + EOLN + indenter.tIncrease()
+                    + "throw new java.rmi.MarshalException("
+                    + "\"Error marshalling return\", e);" + EOLN
+                    + indenter.indent() + '}' + EOLN + EOLN
+                    + indenter.indent() + "break;" + EOLN
+                    + indenter.decrease() + '}' + EOLN);
+
+            return buffer.toString();
+        }
+
+        /**
+         * Returns source code for the method variable declaration
+         * (Stub v1.2/vCompat).
+         *
+         * @return  Method variable declaration.
+         */
+        String getVariableDecl() {
+            return (indenter.indent()
+                    + "private static java.lang.reflect.Method"
+                    + ' ' + varName + ';' + EOLN);
+        }
+
+        /**
+         * Returns source code for the method variable initialization
+         * (Stub v1.2/vCompat).
+         *
+         * @return  Method variable initialization.
+         */
+        String getVariableInit() {
+            StringBuffer buffer = new StringBuffer(indenter.indent()
+                    + varName + " = " + interfaceName + ".class.getMethod(\""
+                    + name + "\", new java.lang.Class[] {");
+
+            if (numParams > 0) {
+                // Write method parameters.
+                for (int i = 0; i < numParams; i++) {
+                    buffer.append(((i > 0) ? ", " : "")
+                            + paramClassNames[i] + ".class");
+                }
+            }
+
+            buffer.append("});" + EOLN);
+
+            return buffer.toString();
+        }
+
+        /**
+         * Returns stub imlementation for this method
+         * (Stub v1.1/v1.2/vCompat).
+         *
+         * @return  Stub imlementation for this method.
+         */
+        String getStubImpl() {
+            return (getStubImplHeader()
+                    + (vCompat ? (indenter.indent() + "if (" + useNewInvoke
+                            + ") {" + EOLN + indenter.hIncrease()) : "")
+                    + (v12 ? getStubImplCodeV12() : "") + (vCompat
+                            ? (indenter.tDecrease() + "} else {" + EOLN) : "")
+                    + (v11 ? getStubImplCodeV11() : "")
+                    + (vCompat ? (indenter.decrease() + '}' + EOLN) : "")
+                    + (throwsException ? "" : (indenter.hDecrease()
+                            + getStubImplCatchBlock()))
+                    + indenter.decrease() + '}' + EOLN);
+        }
+
+        /**
+         * Returns header for the stub implementaton for this method
+         * (Stub v1.1/v1.2/vCompat).
+         *
+         * @return  Stub imlementation header for this method.
+         */
+        private String getStubImplHeader() {
+            StringBuffer buffer = new StringBuffer(indenter.indent()
+                    + "// Implementation of " + shortSign + EOLN
+                    + indenter.indent() + "public " + retTypeName
+                    + ' ' + name + '(');
+
+            // Write method parameters.
+            for (int i = 0; i < numParams; i++) {
+                buffer.append(((i > 0) ? ", " : "")
+                        + paramClassNames[i] + ' ' + paramNames[i]);
+            }
+
+            buffer.append(')' + EOLN + indenter.tIncrease(2) + "throws ");
+
+            // Write exceptions declared thrown.
+            for (Iterator i = exceptions.iterator(); i.hasNext(); ) {
+                buffer.append(((Class) i.next()).getName()
+                        + (i.hasNext() ? ", " : "" ));
+            }
+
+            buffer.append(" {" + EOLN + indenter.hIncrease()
+                    + (throwsException ? "" : (indenter.indent()
+                            + "try {" + EOLN + indenter.hIncrease())));
+
+            return buffer.toString();
+        }
+
+        /**
+         * Returns the stub implementaton code section source for this method
+         * (Stub v1.1/vCompat).
+         *
+         * @return  Stub imlementation code for this method.
+         */
+        private String getStubImplCodeV11() {
+            StringBuffer buffer = new StringBuffer(indenter.indent()
+                    + "java.rmi.server.RemoteCall call = "
+                    + "ref.newCall((java.rmi.server.RemoteObject) this, "
+                    + "operations, " + number + ", " + interfaceHashVarName
+                    + ");" + EOLN);
+
+            if (numParams > 0) {
+                buffer.append(EOLN + indenter.indent() + "try {" + EOLN
+                    + indenter.increase() + "java.io.ObjectOutput "
+                    + outputStreamName + " = call.getOutputStream();" + EOLN);
+
+                for (int i = 0; i < numParams; i++) {
+                    buffer.append(indenter.indent()
+                            + RmicUtil.getWriteObjectString(parameters[i],
+                                    paramNames[i], outputStreamName)
+                            + ';' + EOLN);
+                }
+
+                buffer.append(indenter.decrease()
+                        + "} catch (java.io.IOException e) {" + EOLN
+                        + indenter.tIncrease()
+                        + "throw new java.rmi.MarshalException("
+                        + "\"Error marshalling arguments\", e);" + EOLN
+                        + indenter.indent() + '}' + EOLN);
+            }
+
+            buffer.append(EOLN + indenter.indent()
+                    + "ref.invoke(call);" + EOLN);
+
+            if (retType != void.class) {
+                buffer.append(EOLN + indenter.indent()
+                        + retTypeName + ' ' + retVarName + ';' + EOLN + EOLN
+                        + indenter.indent() + "try {" + EOLN
+                        + indenter.increase() + "java.io.ObjectInput "
+                        + inputStreamName + " = call.getInputStream();" + EOLN
+                        + indenter.indent() + retVarName + " = "
+                        + RmicUtil.getReadObjectString(retType, inputStreamName)
+                        + ';' + EOLN + indenter.decrease()
+                        + "} catch (java.io.IOException e) {" + EOLN
+                        + indenter.tIncrease()
+                        + "throw new java.rmi.UnmarshalException("
+                        + "\"Error unmarshalling return value\", e);" + EOLN
+                        + (!retType.isPrimitive() ? (indenter.indent()
+                        + "} catch (java.lang.ClassNotFoundException e) {"
+                        + EOLN + indenter.tIncrease()
+                        + "throw new java.rmi.UnmarshalException("
+                        + "\"Error unmarshalling return value\", e);" + EOLN)
+                        : "") + indenter.indent() + "} finally {" + EOLN
+                        + indenter.tIncrease() + "ref.done(call);" + EOLN
+                        + indenter.indent() + '}' + EOLN + EOLN
+                        + indenter.indent() + "return " + retVarName + ';'
+                        + EOLN);
+            } else {
+                buffer.append(EOLN + indenter.indent()
+                        + "ref.done(call);" + EOLN);
+            }
+
+            return buffer.toString();
+        }
+
+        /**
+         * Returns the stub implementaton code section source for this method
+         * (Stub v1.2/vCompat).
+         *
+         * @return  Stub imlementation code for this method.
+         */
+        private String getStubImplCodeV12() {
+            StringBuffer buffer = new StringBuffer(indenter.indent());
+
+            if (retType != void.class) {
+                buffer.append("java.lang.Object " + retVarName + " = ");
+            }
+
+            buffer.append("ref.invoke(this, " + varName + ", ");
+
+            if (numParams > 0) {
+                buffer.append("new java.lang.Object[] {");
+
+                // Write invocation parameters.
+                for (int i = 0; i < numParams; i++) {
+                    buffer.append(((i > 0) ? ", " : "")
+                            + RmicUtil.getObjectParameterString(
+                                    parameters[i], paramNames[i]));
+                }
+                buffer.append('}');
+            } else {
+                buffer.append("null");
+            }
+
+            buffer.append(", " + hash + "L);" + EOLN);
+
+            // Write return statement.
+            if (retType != void.class) {
+                buffer.append(indenter.indent() + "return "
+                        + RmicUtil.getReturnObjectString(retType, retVarName)
+                        + ';' + EOLN);
+            }
+
+            return buffer.toString();
+        }
+
+        /**
+         * Returns the stub implementaton catch block for this method
+         * (Stub v1.1/v1.2/vCompat).
+         *
+         * @return  Stub imlementation catch block for this method.
+         */
+        private String getStubImplCatchBlock() {
+            StringBuffer buffer = new StringBuffer();
+
+            for (Iterator i = catches.iterator(); i.hasNext(); ) {
+                buffer.append(indenter.indent() + "} catch ("
+                        + ((Class) i.next()).getName() + " e) {" + EOLN
+                        + indenter.tIncrease() + "throw e;" + EOLN);
+            }
+
+            buffer.append(indenter.indent()
+                    + "} catch (java.lang.Exception e) {" + EOLN
+                    + indenter.tIncrease()
+                    + "throw new java.rmi.UnexpectedException("
+                    + "\"Undeclared checked exception\", e);" + EOLN
+                    + indenter.indent() + '}' + EOLN);
+
+            return buffer.toString();
+        }
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/ClassStub.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/Indenter.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/Indenter.java?rev=407625&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/Indenter.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/Indenter.java Thu May 18 13:01:22 2006
@@ -0,0 +1,258 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author  Vasily Zakharov
+ * @version $Revision: 1.1.2.1 $
+ */
+package org.apache.harmony.rmi.compiler;
+
+
+/**
+ * Provides dynamic 4-space indents usable for source code generation.
+ * All indents are measured in 4-space units.
+ *
+ * This class' methods are designed to be called right from the output stream
+ * composition, i. e. <code>String output =
+ * ("first line" + indenter.increase() + "second line");</code>
+ *
+ * @author  Vasily Zakharov
+ * @version $Revision: 1.1.2.1 $
+ */
+final class Indenter {
+
+    /**
+     * String used for indentation.
+     */
+    private final String stepString = "    ";
+
+    /**
+     * Length of {@linkplain #stepString indentation string}.
+     */
+    private final int STEP_LENGTH = stepString.length();
+
+    /**
+     * Indent string.
+     */
+    private String currentIndent;
+
+    /**
+     * Create instance with zero starting indent.
+     */
+    Indenter() {
+        currentIndent = new String();
+    }
+
+    /**
+     * Create instance with specified starting indent.
+     *
+     * @param   indent
+     *          Starting indent.
+     */
+    Indenter(int indent) {
+        this();
+
+        if (indent > 0) {
+            increase(indent);
+        }
+    }
+
+    /**
+     * Returns current indent string.
+     *
+     * @return  Current indent string.
+     */
+    String indent() {
+        return currentIndent;
+    }
+
+    /**
+     * Increase current indent one step right.
+     *
+     * @return  Current (increased) indent string.
+     */
+    String increase() {
+        return increase(1);
+    }
+
+    /**
+     * Increase current indent the specified number of steps right.
+     *
+     * @param   steps
+     *          Number of steps to increase current indent.
+     *
+     * @return  Current (increased) indent string.
+     */
+    String increase(int steps) {
+        return currentIndent = tIncrease(steps);
+    }
+
+    /**
+     * Decrease current indent one step left.
+     *
+     * @return  Current (decreased) indent string.
+     *
+     * @throws  IndexOutOfBoundsException
+     *          If current indent is empty and thus cannot be decreased.
+     */
+    String decrease() throws IndexOutOfBoundsException {
+        return decrease(1);
+    }
+
+    /**
+     * Decrease current indent the specified number of steps left.
+     *
+     * @param   steps
+     *          Number of steps to decrease current indent.
+     *
+     * @return  Current (decreased) indent string.
+     *
+     * @throws  IndexOutOfBoundsException
+     *          If current indent is empty and thus cannot be decreased.
+     */
+    String decrease(int steps) throws IndexOutOfBoundsException {
+        return currentIndent = tDecrease(steps);
+    }
+
+    /**
+     * Increases current indent one step right, but returns empty string.
+     *
+     * @return  Empty string.
+     */
+    String hIncrease() {
+        return hIncrease(1);
+    }
+
+    /**
+     * Increases current indent the specified number of steps right,
+     * but returns empty string.
+     *
+     * @param   steps
+     *          Number of steps to increase current indent.
+     *
+     * @return  Empty string.
+     */
+    String hIncrease(int steps) {
+        increase(steps);
+        return "";
+    }
+
+    /**
+     * Decreases current indent one step left, but returns empty string.
+     *
+     * @return  Empty string.
+     *
+     * @throws  IndexOutOfBoundsException
+     *          If current indent is empty and thus cannot be decreased.
+     */
+    String hDecrease() throws IndexOutOfBoundsException {
+        return hDecrease(1);
+    }
+
+    /**
+     * Decreases current indent the specified number of steps left,
+     * but returns empty string.
+     *
+     * @param   steps
+     *          Number of steps to decrease indent.
+     *
+     * @return  Empty string.
+     *
+     * @throws  IndexOutOfBoundsException
+     *          If current indent is empty and thus cannot be decreased.
+     */
+    String hDecrease(int steps) throws IndexOutOfBoundsException {
+        decrease(steps);
+        return "";
+    }
+
+    /**
+     * Returns current indent temporary increased one step right.
+     * The stored indent is not changed.
+     *
+     * @return  Increased indent string.
+     */
+    String tIncrease() {
+        return tIncrease(1);
+    }
+
+    /**
+     * Returns current indent temporary increased the specified number of steps
+     * right. The stored indent is not changed.
+     *
+     * @param   steps
+     *          Number of steps to increase current indent.
+     *
+     * @return  Increased indent string.
+     */
+    String tIncrease(int steps) {
+        StringBuffer buffer = new StringBuffer(currentIndent);
+
+        for (int i = 0; i < steps; i++) {
+            buffer.append(stepString);
+        }
+
+        return buffer.toString();
+    }
+
+    /**
+     * Returns current indent temporary decreased one step left.
+     * The stored indent is not changed.
+     *
+     * @return  Decreased indent string.
+     *
+     * @throws  IndexOutOfBoundsException
+     *          If current indent is empty and thus cannot be decreased.
+     */
+    String tDecrease() throws IndexOutOfBoundsException {
+        return tDecrease(1);
+    }
+
+    /**
+     * Returns current indent temporary decreased the specified number of steps
+     * left. The stored indent is not changed.
+     *
+     * @param   steps
+     *          Number of steps to decrease indent.
+     *
+     * @return  Decreased indent string.
+     *
+     * @throws  IndexOutOfBoundsException
+     *          If current indent is empty and thus cannot be decreased.
+     */
+    String tDecrease(int steps) throws IndexOutOfBoundsException {
+        return currentIndent.substring(0,
+                (currentIndent.length() - (steps * STEP_LENGTH)));
+    }
+
+    /**
+     * Return empty string if current indent is empty.
+     * Throws {@link IllegalStateException} otherwise.
+     *
+     * @return  Empty string.
+     *
+     * @throws  IllegalStateException
+     *          If current indent is not empty.
+     */
+    String assertEmpty() throws IllegalStateException {
+        if (currentIndent.length() != 0) {
+            throw new IllegalStateException(
+                    "Indenter assertion failed: current indent is not empty");
+        }
+        return "";
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/Indenter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/Main.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/Main.java?rev=407625&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/Main.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/Main.java Thu May 18 13:01:22 2006
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author  Vasily Zakharov
+ * @version $Revision: 1.1.2.5 $
+ */
+package org.apache.harmony.rmi.compiler;
+
+
+/**
+ * Launcher engine for RMI Compiler.
+ *
+ * @author  Vasily Zakharov
+ * @version $Revision: 1.1.2.5 $
+ */
+public final class Main implements RmicConstants {
+
+    /**
+     * Command line startup method for RMI Compiler.
+     *
+     * @param   args
+     *          Command line arguments.
+     */
+    public static void main(String[] args) {
+        try {
+            new RMICompiler(args).run();
+        } catch (RMICompilerException e) {
+            String message = e.getMessage();
+
+            if ((message != null) && message.startsWith(EOLN)) {
+                System.out.println(message);
+            } else {
+                System.out.println("RMIC Error: "
+                        + ((message != null) ? message : ""));
+                e.printStackTrace(System.out);
+                System.exit(-1);
+            }
+        } catch (Throwable e) {
+            System.out.println("RMIC Error: Unexpected exception:" + e);
+            e.printStackTrace(System.out);
+            System.exit(-1);
+        }
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/Main.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/RMICompiler.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/RMICompiler.java?rev=407625&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/RMICompiler.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/RMICompiler.java Thu May 18 13:01:22 2006
@@ -0,0 +1,807 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author  Vasily Zakharov
+ * @version $Revision: 1.1.2.3 $
+ */
+package org.apache.harmony.rmi.compiler;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.StringTokenizer;
+
+import org.apache.harmony.rmi.common.JavaCompiler;
+import org.apache.harmony.rmi.common.JavaCompilerException;
+import org.apache.harmony.rmi.common.RMIUtil;
+
+
+/**
+ * Core class of RMI Compiler.
+ *
+ * @author  Vasily Zakharov
+ * @version $Revision: 1.1.2.3 $
+ *
+ * @todo    Implement IDL/IIOP support.
+ */
+public final class RMICompiler implements RmicConstants, RmicStrings {
+
+    /**
+     * Version of stubs to generate.
+     */
+    private final int version;
+
+    /**
+     * Option: do not delete generated source files
+     * (<code>-keep</code>).
+     */
+    private final boolean keepSources;
+
+    /**
+     * Option: always regenerate IDL/IIOP stubs
+     * (<code>-always</code>).
+     */
+    private final boolean always;
+
+    /**
+     * Option: use factory keyword in generated IDL stubs
+     * (<code>-factory</code>).
+     */
+    private final boolean factory;
+
+    /**
+     * Option: valuetype methods and initializers in IDL stubs
+     * (<code>-noValueMethods</code>).
+     */
+    private final boolean valueMethods;
+
+    /**
+     * Option: create stubs optimized for the same process
+     * (<code>-nolocalstubs</code>).
+     */
+    private final boolean localStubs;
+
+    /**
+     * Option: change POA inheritance
+     * (<code>-poa</code>).
+     */
+    private final boolean poa;
+
+    /**
+     * Option: generate debug information
+     * (<code>-debug</code>).
+     */
+    private final boolean debug;
+
+    /**
+     * Option: notify about compiler warnings
+     * (<code>-nowarn</code>).
+     */
+    private final boolean warnings;
+
+    /**
+     * Option: do not write compiled classes
+     * (<code>-nowrite</code>).
+     */
+    private final boolean writeClasses;
+
+    /**
+     * Option: print detailed compilation log
+     * (<code>-verbose</code>).
+     */
+    private final boolean verbose;
+
+    /**
+     * Option: recompile dependend classes.
+     * (<code>-depend</code>).
+     */
+    private final boolean depend;
+
+    /**
+     * Option: destination directory for generated source and class files.
+     * (<code>-d</code>).
+     */
+    private final String destinationDir;
+
+    /**
+     * If any options were specified.
+     */
+    private final boolean optionsPresent;
+
+    /**
+     * Java compiler options.
+     */
+    private final String[] javacOptions;
+
+    /**
+     * Warning flags.
+     */
+    private HashMap warningTags = new HashMap();
+
+    /**
+     * Classes to generate stubs for.
+     *
+     * We use {@link Object} array to store either {@link String}
+     * or {@link Class} objects because we don't want to resolve all the class
+     * names in the beginning - to avoid one incorrecly spelled class name
+     * preventing generation of stubs for other specified classes.
+     */
+    private Object[] classes;
+
+    /**
+     * Number of classes in {@link #classes} array.
+     */
+    private int numClasses;
+
+    /**
+     * Constructs instance of RMI Compiler.
+     *
+     * @param       args
+     *              RMI Compiler options (see
+     *              <a href="package-summary.html">package description</a>
+     *              for details).
+     *
+     * @param       classes
+     *              Classes to process.
+     *              Call {@link #run()} to process them.
+     *
+     * @throws      RMICompilerException
+     *              If some error occurs.
+     */
+    public RMICompiler(String[] args, Class[] classes)
+            throws RMICompilerException {
+        this(args, (Object[]) classes);
+    }
+
+    /**
+     * Constructs instance of RMI Compiler.
+     *
+     * @param       args
+     *              RMI Compiler options (see
+     *              <a href="package-summary.html">package description</a>
+     *              for details).
+     *
+     * @param       classNames
+     *              Names of classes to process.
+     *              Call {@link #run()} to process them.
+     *
+     * @throws      RMICompilerException
+     *              If some error occurs.
+     */
+    public RMICompiler(String[] args, String[] classNames)
+            throws RMICompilerException {
+        this(args, (Object[]) classNames);
+    }
+
+    /**
+     * Constructs instance of RMI Compiler.
+     *
+     * @param       args
+     *              RMI Compiler options (see
+     *              <a href="package-summary.html">package description</a>
+     *              for details).
+     *
+     * @param       classNames
+     *              Names of classes to process (space separated).
+     *              Call {@link #run()} to process them.
+     *
+     * @throws      RMICompilerException
+     *              If some error occurs.
+     */
+    public RMICompiler(String[] args, String classNames)
+            throws RMICompilerException {
+        this(args, (Object[]) stringToArray(classNames));
+    }
+
+    /**
+     * Constructs instance of RMI Compiler.
+     *
+     * @param       args
+     *              RMI Compiler options (see
+     *              <a href="package-summary.html">package description</a>
+     *              for details).
+     *              Call {@link #run(Class[])} or {@link #run(String[])}
+     *              to specify classes to process and process them immediately.
+     *
+     * @throws      RMICompilerException
+     *              If some error occurs.
+     */
+    public RMICompiler(String[] args) throws RMICompilerException {
+        this(args, (Object[]) null);
+    }
+
+    /**
+     * Constructs instance of RMI Compiler.
+     *
+     * @param       args
+     *              RMI Compiler options, space separated (see
+     *              <a href="package-summary.html">package description</a>
+     *              for details).
+     *
+     * @param       classes
+     *              Classes to process.
+     *              Call {@link #run()} to process them.
+     *
+     * @throws      RMICompilerException
+     *              If some error occurs.
+     */
+    public RMICompiler(String args, Class[] classes)
+            throws RMICompilerException {
+        this(stringToArray(args), (Object[]) classes);
+    }
+
+    /**
+     * Constructs instance of RMI Compiler.
+     *
+     * @param       args
+     *              RMI Compiler options, space separated (see
+     *              <a href="package-summary.html">package description</a>
+     *              for details).
+     *
+     * @param       classNames
+     *              Names of classes to process.
+     *              Call {@link #run()} to process them.
+     *
+     * @throws      RMICompilerException
+     *              If some error occurs.
+     */
+    public RMICompiler(String args, String[] classNames)
+            throws RMICompilerException {
+        this(stringToArray(args), (Object[]) classNames);
+    }
+
+    /**
+     * Constructs instance of RMI Compiler.
+     *
+     * @param       args
+     *              RMI Compiler options, space separated (see
+     *              <a href="package-summary.html">package description</a>
+     *              for details).
+     *
+     * @param       classNames
+     *              Names of classes to process (space separated).
+     *              Call {@link #run()} to process them.
+     *
+     * @throws      RMICompilerException
+     *              If some error occurs.
+     */
+    public RMICompiler(String args, String classNames)
+            throws RMICompilerException {
+        this(stringToArray(args), (Object[]) stringToArray(classNames));
+    }
+
+    /**
+     * Constructs instance of RMI Compiler.
+     *
+     * @param       args
+     *              RMI Compiler options, space separated (see
+     *              <a href="package-summary.html">package description</a>
+     *              for details).
+     *              Call {@link #run(Class[])} or {@link #run(String[])}
+     *              to specify classes to process and process them immediately.
+     *
+     * @throws      RMICompilerException
+     *              If some error occurs.
+     */
+    public RMICompiler(String args) throws RMICompilerException {
+        this(stringToArray(args), (Object[]) null);
+    }
+
+    /**
+     * Private constructor, called from all other constructors.
+     *
+     * @param       args
+     *              RMI Compiler options (see
+     *              <a href="package-summary.html">package description</a>
+     *              for details).
+     *
+     * @param       classes
+     *              Classes to process ({@link Class} or {@link String}
+     *              objects).
+     *
+     * @throws      RMICompilerException
+     *              If some error occurs.
+     */
+    private RMICompiler(String[] args, Object[] classes)
+            throws RMICompilerException {
+        int numArgs = args.length;
+
+        int version = VERSION_NOT_SET;
+        boolean keepSources = false;
+        boolean always = false;
+        boolean factory = false;
+        boolean valueMethods = true;
+        boolean localStubs = true;
+        boolean poa = false;
+        boolean debug = false;
+        boolean warnings = true;
+        boolean writeClasses = true;
+        boolean verbose = false;
+        boolean depend = false;
+        boolean optionsPresent = (numArgs > 0);
+        String destinationDir = ".";
+
+        ArrayList javacOptionsList = new ArrayList();
+
+        // User doesn't need any warnings on compiling stubs, as all possible
+        // issues that may appear concern RMI specification, not user classes.
+        javacOptionsList.add(optionNoWarnings);
+
+        // Parse arguments, adjust values of option fields,
+        // add neccessary options to javacOptionsList.
+        for (int i = 0; i < numArgs; i++) {
+            String arg = args[i].intern();
+
+            if (arg == optionV11) {
+                if (version == VERSION_NOT_SET) {
+                    version = VERSION_V11;
+                } else {
+                    error(errorVersionText);
+                }
+            } else if (arg == optionV12) {
+                if (version == VERSION_NOT_SET) {
+                    version = VERSION_V12;
+                } else {
+                    error(errorVersionText);
+                }
+            } else if (arg == optionVCompat) {
+                if (version == VERSION_NOT_SET) {
+                    version = VERSION_VCOMPAT;
+                } else {
+                    error(errorVersionText);
+                }
+            } else if (arg == optionIDL) {
+                if (version == VERSION_NOT_SET) {
+                    version = VERSION_IDL;
+                } else {
+                    error(errorVersionText);
+                }
+            } else if (arg == optionIIOP) {
+                if (version == VERSION_NOT_SET) {
+                    version = VERSION_IIOP;
+                } else {
+                    error(errorVersionText);
+                }
+            } else if (arg == optionTarget) {
+                if (i < (numArgs - 1)) {
+                    // If parameter is available,
+                    // add options to javacOptionsList.
+                    String target = args[++i].intern();
+                    String source = (((target == "1.1") || (target == "1.2"))
+                            ? "1.3" : target);
+
+                    javacOptionsList.add(optionSource);
+                    javacOptionsList.add(source);
+                    javacOptionsList.add(optionTarget);
+                    javacOptionsList.add(target);
+                } else {
+                    error(errorNeedParameterText, arg);
+                }
+            } else if ((arg == optionKeep) || (arg == optionKeepGenerated)) {
+                keepSources = true;
+            } else if ((arg == optionAlways) || (arg == optionAlwaysGenerate)) {
+                always = true;
+            } else if (arg == optionFactory) {
+                factory = true;
+            } else if (arg == optionNoValueMethods) {
+                valueMethods = false;
+            } else if (arg == optionNoLocalStubs) {
+                localStubs = false;
+            } else if (arg == optionPOA) {
+                poa = true;
+            } else if ((arg == optionDebug)
+                    || arg.startsWith(optionDebugDetails)) {
+                javacOptionsList.add(arg);
+                debug = true;
+            } else if (arg == optionNoWarnings) {
+                warnings = false;
+            } else if (arg == optionNoWrite) {
+                writeClasses = false;
+            } else if (arg == optionVerbose) {
+                javacOptionsList.add(arg);
+                verbose = true;
+            } else if (arg == optionDepend) {
+                depend = true;
+            } else if ((arg == optionIdlModule) || (arg == optionIdlFile)) {
+                if (i < (numArgs - 2)) {
+                    // @ToDo: implement for IDL support.
+                    i += 2;
+                } else {
+                    error(errorNeedTwoParametersText, arg);
+                }
+            } else if ((arg == optionClassPath) || (arg == optionCP)
+                    || (arg == optionBootClassPath) || (arg == optionExtDirs)
+                    || (arg == optionDestinationDir)) {
+                if (i < (numArgs - 1)) {
+                    // If parameter is available,
+                    // add option to javacOptionsList.
+                    String option = ((arg == optionCP) ? optionClassPath : arg);
+                    javacOptionsList.add(option);
+                    String param = args[++i];
+                    javacOptionsList.add(param);
+
+                    if (arg == optionDestinationDir) {
+                        destinationDir = param;
+                    } else {
+                        addWarning(option.substring(1), warningClassPathText);
+                    }
+                } else {
+                    error(errorNeedParameterText, arg);
+                }
+            } else if (arg.startsWith(optionJava) || arg.startsWith(optionX)) {
+                if (arg.length() > 2) {
+                    // If parameter is available,
+                    // add option to javacOptionsList.
+                    javacOptionsList.add(arg);
+                } else {
+                    error(errorNeedJVMParameterText, arg);
+                }
+            } else if (arg.startsWith(optionPrefix)) {
+                // What starts with dash is probably the non-specified option.
+                error(errorUnknownOptionText, arg);
+            } else {
+                // First arg that is not an option.
+                if (classes != null) {
+                    // If classes are specified explicitly,
+                    // then this is just an incorrect option.
+                    error(errorUnknownOptionText, arg);
+                } else {
+                    // If classes are not specified explicitly,
+                    // extract them from args.
+                    int numClasses = (numArgs - i);
+                    classes = new Object[numClasses];
+                    System.arraycopy(args, i, classes, 0, numClasses);
+
+                    if (i == 0) {
+                        // Mark that no options were really specified.
+                        optionsPresent = false;
+                    }
+                }
+                break;
+            }
+        }
+
+        // Print warnings.
+        if (warnings) {
+            for (Iterator i = warningTags.values().iterator(); i.hasNext(); ) {
+                System.err.println("WARNING: " + i.next());
+            }
+        }
+
+        // Check options compatibility.
+        if (always && (version != VERSION_IDL) && (version != VERSION_IIOP)) {
+            error(errorUnusableExceptIDL_IIOP, optionAlways);
+        }
+
+        if (factory && (version != VERSION_IDL)) {
+            error(errorUnusableExceptIDL, optionFactory);
+        }
+
+        if (!valueMethods && (version != VERSION_IDL)) {
+            error(errorUnusableExceptIDL, optionNoValueMethods);
+        }
+
+        if (!localStubs && (version != VERSION_IIOP)) {
+            error(errorUnusableExceptIIOP, optionNoLocalStubs);
+        }
+
+        if (poa && (version != VERSION_IIOP)) {
+            error(errorUnusableExceptIIOP, optionPOA);
+        }
+
+        if (version == VERSION_NOT_SET) {
+            version = VERSION_V12;
+        }
+
+        // Save configuration.
+        this.classes = ((classes != null) ? classes : new Object[0]);
+        this.numClasses = this.classes.length;
+
+        this.version = version;
+        this.keepSources = keepSources;
+        this.always = always;
+        this.factory = factory;
+        this.valueMethods = valueMethods;
+        this.localStubs = localStubs;
+        this.poa = poa;
+        this.debug = debug;
+        this.warnings = warnings;
+        this.writeClasses = writeClasses;
+        this.verbose = verbose;
+        this.depend = depend;
+        this.optionsPresent = optionsPresent;
+        this.destinationDir = destinationDir;
+
+        // "Export" Javac options.
+        javacOptions = (String[]) javacOptionsList.toArray(
+                new String[javacOptionsList.size()]);
+    }
+
+    /**
+     * Runs the compilation process.
+     *
+     * Note that to call this method classes to compile must be specified
+     * in constructor or in previous call to {@link #run(Class[])}
+     * or {@link #run(String[])}.
+     *
+     * @throws      RMICompilerException
+     *              If some error occurs.
+     */
+    public void run() throws RMICompilerException {
+        if (numClasses < 1) {
+            if (optionsPresent) {
+                error(errorNoClassesText);
+            } else {
+                usage();
+            }
+        }
+
+        // Create files array for stub and skeleton files.
+        File[] stubFiles = new File[numClasses];
+        File[] skelFiles = new File[numClasses];
+        File[] skelClassFiles = new File[numClasses];
+        int filesNum = 0;
+
+        try {
+            // Walk through the specified classes.
+            for (int i = 0; i < numClasses; i++) {
+
+                // Find out the class to process.
+                Object obj = classes[i];
+                Class cls;
+
+                if (obj instanceof Class) {
+                    cls = (Class) obj;
+                } else {    // (obj instanceof String)
+                    String className = (String) obj;
+
+                    try {
+                        cls = Class.forName(className);
+                        classes[i] = cls;
+                    } catch (ClassNotFoundException e) {
+                        throw new RMICompilerException(
+                                "Class not found: " + e.getMessage(), e);
+                    } catch (LinkageError e) {
+                        throw new RMICompilerException(
+                                "Class loading error: " + e.getMessage(), e);
+                    }
+                }
+
+                // Create class stub.
+                ClassStub stub = new ClassStub(version, cls);
+
+                String packageName = RMIUtil.getPackageName(cls);
+
+                if (packageName != null) {
+                    packageName = packageName.replace('.', File.separatorChar);
+                }
+
+                String stubClassName = stub.getStubClassName();
+                String skelClassName = stub.getSkeletonClassName();
+
+                File dir = RmicUtil.getPackageDir(destinationDir, packageName);
+
+                // Generate stub source file name.
+                File stubFile = RmicUtil.getPackageFile(dir,
+                        stubClassName + javaSuffix);
+                stubFiles[filesNum] = stubFile;
+
+                // Generate skeleton source file name.
+                File skelFile = RmicUtil.getPackageFile(dir,
+                        skelClassName + javaSuffix);
+                skelFiles[filesNum] = skelFile;
+
+                // Generate skeleton class file name.
+                skelClassFiles[filesNum] = RmicUtil.getPackageFile(dir,
+                        skelClassName + classSuffix);
+
+                filesNum++;
+
+                try {
+                    // Write generated stub source to the file.
+                    FileWriter writer = new FileWriter(stubFile);
+                    writer.write(stub.getStubSource());
+                    writer.close();
+                } catch (IOException e) {
+                    throw new RMICompilerException(
+                            "Can't write file " + stubFile.getName(), e);
+                }
+
+                if (version != VERSION_V12) {
+                    try {
+                        // Write generated skeleton source to the file.
+                        FileWriter writer = new FileWriter(skelFile);
+                        writer.write(stub.getSkeletonSource());
+                        writer.close();
+                    } catch (IOException e) {
+                        throw new RMICompilerException(
+                                "Can't write file " + skelFile.getName(), e);
+                    }
+                }
+            }
+
+            // Prepare files array for compilation.
+            File[] files;
+
+            if (version == VERSION_V12) {
+                files = stubFiles;
+            } else {
+                files = new File[2 * numClasses];
+
+                int j = 0;
+                for (int i = 0; i < numClasses; i++) {
+                    files[j++] = stubFiles[i];
+                    files[j++] = skelFiles[i];
+                }
+            }
+
+            try {
+                // Invoke Java compiler for generated files.
+                int ret = JavaCompiler.locateJavaCompiler(verbose)
+                        .compile(javacOptions, files);
+
+                if (ret != 0) {
+                    throw new RMICompilerException("Javac failed, code " + ret);
+                }
+            } catch (JavaCompilerException e) {
+                throw new RMICompilerException("Can't run Javac: " + e, e);
+            }
+        } finally {
+
+            // Remove generated stub and skeleton files even if exception arised
+            if (!keepSources) {
+                for (int i = 0; i < filesNum; i++) {
+                    stubFiles[i].delete();
+                }
+            }
+
+            // Remove skeleton files if version is set to 1.2.
+            if (!keepSources || (version == VERSION_V12)) {
+                for (int i = 0; i < filesNum; i++) {
+                    skelFiles[i].delete();
+                }
+            }
+
+            // Remove skeleton class files if version is set to 1.2.
+            if (version == VERSION_V12) {
+                for (int i = 0; i < filesNum; i++) {
+                    skelClassFiles[i].delete();
+                }
+            }
+        }
+    }
+
+    /**
+     * Runs the compilation process.
+     *
+     * @param       classes
+     *              Classes to compile. This classes list replace any previous
+     *              specifications of classes to compile, made in constructor
+     *              or in other calls to <code>run()</code> methods.
+     *
+     * @throws      RMICompilerException
+     *              If some error occurs.
+     */
+    public void run(Class[] classes) throws RMICompilerException {
+        this.classes = (Object[]) classes;
+        run();
+    }
+
+    /**
+     * Runs the compilation process.
+     *
+     * @param       classNames
+     *              Names of classes to compile. This classes list replace any
+     *              previous specifications of classes to compile, made in
+     *              constructor or in other calls to <code>run()</code> methods.
+     *
+     * @throws      RMICompilerException
+     *              If some error occurs.
+     */
+    public void run(String[] classNames) throws RMICompilerException {
+        this.classes = (Object[]) classNames;
+        run();
+    }
+
+    /**
+     * Produces usage information.
+     *
+     * @throws      RMICompilerException
+     *              Always. Exception message contains usage information.
+     */
+    private static void usage() throws RMICompilerException {
+        throw new RMICompilerException(EOLN + usageText);
+    }
+
+    /**
+     * Produces error message.
+     *
+     * @param       message
+     *              Error message.
+     *
+     * @throws      RMICompilerException
+     *              Always. Exception message contains the specified message
+     *              and usage information.
+     */
+    private static void error(String message) throws RMICompilerException {
+        throw new RMICompilerException(message + EOLN);
+    }
+
+    /**
+     * Produces error message.
+     *
+     * @param       message
+     *              Error message, can contain references to a single argument,
+     *              specified by <code>arg</code>. References are represented
+     *              by <code>%s</code> substrings.
+     *
+     * @param       arg
+     *              Argument. Each occurence of <code>%s</code>
+     *              in <code>message</code> is replaced with this string.
+     *
+     * @throws      RMICompilerException
+     *              Always. Exception message contains the specified message
+     *              and usage information.
+     */
+    private static void error(String message, String arg)
+            throws RMICompilerException {
+        error(message.replaceAll("%s", arg));
+    }
+
+    /**
+     * Produces warning message.
+     *
+     * @param       tag
+     *              Warning tag. Used to track warnings. Also, each occurence
+     *              of <code>%s</code> in <code>message</code> is replaced
+     *              with this string.
+     *
+     * @param       message
+     *              Warning message, can contain references to a single argument,
+     *              specified by <code>arg</code>. References are represented
+     *              by <code>%s</code> substrings.
+     */
+    private void addWarning(String tag, String message) {
+        warningTags.put(tag, message.replaceAll("%s", tag));
+    }
+
+    /**
+     * Parses string to a number of tokens, using spaces as separators.
+     * Indeed, {@link StringTokenizer} with no parameters is used.
+     *
+     * @param       string
+     *              String to process.
+     *
+     * @return      String array containing all tokens of the specified string.
+     */
+    private static String[] stringToArray(String string) {
+        StringTokenizer tokenizer = new StringTokenizer(string);
+        int numTokens = tokenizer.countTokens();
+        String[] array = new String[numTokens];
+
+        for (int i = 0; i < numTokens; i++) {
+            array[i] = tokenizer.nextToken();
+        }
+
+        return array;
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/RMICompiler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/RMICompilerException.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/RMICompilerException.java?rev=407625&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/RMICompilerException.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/RMICompilerException.java Thu May 18 13:01:22 2006
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author  Vasily Zakharov
+ * @version $Revision: 1.1.2.2 $
+ */
+package org.apache.harmony.rmi.compiler;
+
+
+/**
+ * Basic exception for RMI Compiler operations.
+ *
+ * @author  Vasily Zakharov
+ * @version $Revision: 1.1.2.2 $
+ */
+public class RMICompilerException extends Exception {
+
+    /**
+     * serialVersionUID
+     */
+    private static final long serialVersionUID = -7107015868027717508L;
+
+    /**
+     * Constructs a new exception with <code>null</code> message.
+     */
+    public RMICompilerException() {
+        super();
+    }
+
+    /**
+     * Constructs a new exception with the specified message.
+     *
+     * @param   message
+     *          Message of this exception.
+     */
+    public RMICompilerException(String message) {
+        super(message);
+    }
+
+    /**
+     * Constructs a new exception with the specified cause and message
+     * equal to the specified cause.
+     *
+     * @param   cause
+     *          Cause of this exception.
+     */
+    public RMICompilerException(Throwable cause) {
+        super(cause);
+    }
+
+    /**
+     * Constructs a new exception with the specified message and cause.
+     *
+     * @param   message
+     *          Message of this exception.
+     *
+     * @param   cause
+     *          Cause of this exception.
+     */
+    public RMICompilerException(String message, Throwable cause) {
+        super(message, cause);
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/RMICompilerException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/RmicConstants.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/RmicConstants.java?rev=407625&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/RmicConstants.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/RmicConstants.java Thu May 18 13:01:22 2006
@@ -0,0 +1,140 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author  Vasily Zakharov
+ * @version $Revision: 1.1.2.1 $
+ */
+package org.apache.harmony.rmi.compiler;
+
+
+/**
+ * This interface contains various useful constants for RMI Compiler.
+ *
+ * @author  Vasily Zakharov
+ * @version $Revision: 1.1.2.1 $
+ */
+interface RmicConstants {
+
+    /**
+     * System-dependent end-of-line string
+     * {@link System#getProperty(String) System.getProperty("line.separator")}.
+     */
+    String EOLN = System.getProperty("line.separator");
+
+    /**
+     * Stub classes name suffix (<code>_Stub</code>).
+     */
+    String stubSuffix = "_Stub";
+
+    /**
+     * Skeleton classes name suffix (<code>_Skel</code>).
+     */
+    String skelSuffix = "_Skel";
+
+    /**
+     * Java source files name suffix (<code>.java</code>).
+     */
+    String javaSuffix = ".java";
+
+    /**
+     * Java class files name suffix (<code>.class</code>).
+     */
+    String classSuffix = ".class";
+
+    /**
+     * Method variables name prefix.
+     */
+    String methodVarPrefix = "$method_";
+
+    /**
+     * Parameters name prefix.
+     */
+    String paramPrefix = "$param_";
+
+    /**
+     * Array type prefix in parameter name.
+     */
+    String arrayPrefix = "arrayOf_";
+
+    /**
+     * Return result variable name.
+     */
+    String retVarName = "$result";
+
+    /**
+     * interfaceHash variable name.
+     */
+    String interfaceHashVarName = "interfaceHash";
+
+    /**
+     * useNewInvoke variable name.
+     */
+    String useNewInvoke = "useNewInvoke";
+
+    /**
+     * Input object stream name.
+     */
+    String inputStreamName = "in";
+
+    /**
+     * Output object stream name.
+     */
+    String outputStreamName = "out";
+
+    /**
+     * Version was not set, initial version value.
+     *
+     * @todo: all VERSION constants should be moved to enum for Java 5.0.
+     */
+    int VERSION_NOT_SET = 0;
+
+    /**
+     * Option to create RMI v1.1 stub.
+     */
+    int VERSION_V11 = 1;
+
+    /**
+     * Option to create RMI v1.2 stub.
+     */
+    int VERSION_V12 = 2;
+
+    /**
+     * Option to create RMI v1.1/v1.2 compatible stub.
+     */
+    int VERSION_VCOMPAT = 3;
+
+    /**
+     * Option to create IDL stub.
+     */
+    int VERSION_IDL = 4;
+
+    /**
+     * Option to create IIOP stub.
+     */
+    int VERSION_IIOP = 5;
+
+    /**
+     * Smallest possible option value.
+     */
+    int MIN_VERSION = VERSION_V11;
+
+    /**
+     * Largest possible option value.
+     */
+    int MAX_VERSION = VERSION_IIOP;
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/compiler/RmicConstants.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message