< prev index next >

src/jdk.rmic/share/classes/sun/rmi/rmic/RMIGenerator.java

Print this page


   1 /*
   2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  29 /* (C) Copyright IBM Corp. 1998                                              */
  30 /*                                                                           */
  31 /*****************************************************************************/
  32 
  33 package sun.rmi.rmic;
  34 
  35 import java.io.File;
  36 import java.io.FileOutputStream;
  37 import java.io.OutputStreamWriter;
  38 import java.io.IOException;
  39 import java.util.Enumeration;
  40 import java.util.Hashtable;
  41 import java.util.Vector;
  42 import sun.tools.java.Type;
  43 import sun.tools.java.Identifier;
  44 import sun.tools.java.ClassDefinition;
  45 import sun.tools.java.ClassDeclaration;
  46 import sun.tools.java.ClassNotFound;
  47 import sun.tools.java.ClassFile;
  48 import sun.tools.java.MemberDefinition;
  49 import com.sun.corba.se.impl.util.Utility;
  50 
  51 /**
  52  * A Generator object will generate the Java source code of the stub
  53  * and skeleton classes for an RMI remote implementation class, using
  54  * a particular stub protocol version.
  55  *
  56  * WARNING: The contents of this source file are not part of any
  57  * supported API.  Code that depends on them does so at its own risk:
  58  * they are subject to change or removal without notice.
  59  *
  60  * @author      Peter Jones,  Bryan Atsatt
  61  */
  62 public class RMIGenerator implements RMIConstants, Generator {
  63 
  64     private static final Hashtable<String, Integer> versionOptions = new Hashtable<>();
  65     static {
  66         versionOptions.put("-v1.1", STUB_VERSION_1_1);
  67         versionOptions.put("-vcompat", STUB_VERSION_FAT);
  68         versionOptions.put("-v1.2", STUB_VERSION_1_2);
  69     }


 179             File skeletonClassFile = new File(outputDir,skeletonClassName.getName().toString() + ".class");
 180 
 181             skeletonFile.delete();      // ignore failures (no big deal)
 182             skeletonClassFile.delete();
 183         }
 184     }
 185 
 186     /**
 187      * Return the File object that should be used as the source file
 188      * for the given Java class, using the supplied destination
 189      * directory for the top of the package hierarchy.
 190      */
 191     protected static File sourceFileForClass(Identifier className,
 192                                              Identifier outputClassName,
 193                                              File destDir,
 194                                              BatchEnvironment env)
 195     {
 196         File packageDir = Util.getOutputDirectoryFor(className,destDir,env);
 197         String outputName = Names.mangleClass(outputClassName).getName().toString();
 198 
 199         // Is there any existing _Tie equivalent leftover from a
 200         // previous invocation of rmic -iiop? Only do this once per
 201         // class by looking for skeleton generation...
 202 
 203         if (outputName.endsWith("_Skel")) {
 204             String classNameStr = className.getName().toString();
 205             File temp = new File(packageDir, Utility.tieName(classNameStr) + ".class");
 206             if (temp.exists()) {
 207 
 208                 // Found a tie. Is IIOP generation also being done?
 209 
 210                 if (!env.getMain().iiopGeneration) {
 211 
 212                     // No, so write a warning...
 213 
 214                     env.error(0,"warn.rmic.tie.found",
 215                               classNameStr,
 216                               temp.getAbsolutePath());
 217                 }
 218             }
 219         }
 220 
 221         String outputFileName = outputName + ".java";
 222         return new File(packageDir, outputFileName);
 223     }
 224 
 225 
 226     /** rmic environment for this object */
 227     private BatchEnvironment env;
 228 
 229     /** the remote class that this instance is generating code for */
 230     private RemoteClass remoteClass;
 231 
 232     /** version of the stub protocol to use in code generation */
 233     private int version;
 234 
 235     /** remote methods for remote class, indexed by operation number */
 236     private RemoteClass.Method[] remoteMethods;
 237 
 238     /**
 239      * Names for the remote class and the stub and skeleton classes
 240      * to be generated for it.


   1 /*
   2  * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  29 /* (C) Copyright IBM Corp. 1998                                              */
  30 /*                                                                           */
  31 /*****************************************************************************/
  32 
  33 package sun.rmi.rmic;
  34 
  35 import java.io.File;
  36 import java.io.FileOutputStream;
  37 import java.io.OutputStreamWriter;
  38 import java.io.IOException;
  39 import java.util.Enumeration;
  40 import java.util.Hashtable;
  41 import java.util.Vector;
  42 import sun.tools.java.Type;
  43 import sun.tools.java.Identifier;
  44 import sun.tools.java.ClassDefinition;
  45 import sun.tools.java.ClassDeclaration;
  46 import sun.tools.java.ClassNotFound;
  47 import sun.tools.java.ClassFile;
  48 import sun.tools.java.MemberDefinition;

  49 
  50 /**
  51  * A Generator object will generate the Java source code of the stub
  52  * and skeleton classes for an RMI remote implementation class, using
  53  * a particular stub protocol version.
  54  *
  55  * WARNING: The contents of this source file are not part of any
  56  * supported API.  Code that depends on them does so at its own risk:
  57  * they are subject to change or removal without notice.
  58  *
  59  * @author      Peter Jones,  Bryan Atsatt
  60  */
  61 public class RMIGenerator implements RMIConstants, Generator {
  62 
  63     private static final Hashtable<String, Integer> versionOptions = new Hashtable<>();
  64     static {
  65         versionOptions.put("-v1.1", STUB_VERSION_1_1);
  66         versionOptions.put("-vcompat", STUB_VERSION_FAT);
  67         versionOptions.put("-v1.2", STUB_VERSION_1_2);
  68     }


 178             File skeletonClassFile = new File(outputDir,skeletonClassName.getName().toString() + ".class");
 179 
 180             skeletonFile.delete();      // ignore failures (no big deal)
 181             skeletonClassFile.delete();
 182         }
 183     }
 184 
 185     /**
 186      * Return the File object that should be used as the source file
 187      * for the given Java class, using the supplied destination
 188      * directory for the top of the package hierarchy.
 189      */
 190     protected static File sourceFileForClass(Identifier className,
 191                                              Identifier outputClassName,
 192                                              File destDir,
 193                                              BatchEnvironment env)
 194     {
 195         File packageDir = Util.getOutputDirectoryFor(className,destDir,env);
 196         String outputName = Names.mangleClass(outputClassName).getName().toString();
 197 






















 198         String outputFileName = outputName + ".java";
 199         return new File(packageDir, outputFileName);
 200     }
 201 
 202 
 203     /** rmic environment for this object */
 204     private BatchEnvironment env;
 205 
 206     /** the remote class that this instance is generating code for */
 207     private RemoteClass remoteClass;
 208 
 209     /** version of the stub protocol to use in code generation */
 210     private int version;
 211 
 212     /** remote methods for remote class, indexed by operation number */
 213     private RemoteClass.Method[] remoteMethods;
 214 
 215     /**
 216      * Names for the remote class and the stub and skeleton classes
 217      * to be generated for it.


< prev index next >