1 /* RMIC.java -- RMI stub generator.
2 Copyright (C) 2006 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package gnu
.classpath
.tools
.rmi
;
41 import gnu
.classpath
.tools
.HelpPrinter
;
42 import gnu
.classpath
.tools
.giop
.GRMIC
;
43 import gnu
.classpath
.tools
.giop
.grmic
.GiopRmicCompiler
;
44 import gnu
.classpath
.tools
.rmi
.rmic
.RmicCompiler
;
47 import java
.io
.FileOutputStream
;
48 import java
.io
.IOException
;
49 import java
.io
.OutputStream
;
52 * Generates the ordinary stubs (not GIOP based) for java.rmi.* package.
54 * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
59 * The version of the compiler.
61 public static String VERSION
= "0.0 alpha pre";
64 * The GRMIC compiler methods
66 * @param args the compiler parameters.
68 public static void main(String
[] args
)
70 // Check for the -iiop or -giop keys. If one of these keys is present,
71 // forward all call to GRMIC.
72 for (int i
= 0; i
< args
.length
; i
++)
74 if (args
[i
].equals("-giop") || args
[i
].equals("-iiop"))
81 boolean noWrite
= false;
82 boolean verbose
= false;
84 String HelpPath
= "rmi/RMIC.txt";
86 HelpPrinter
.checkHelpKey(args
, HelpPath
);
88 File output
= new File(".");
92 HelpPrinter
.printHelpAndExit(HelpPath
);
96 RmicCompiler compiler
= new RmicCompiler();
100 Options
: for (int i
= 0; i
< args
.length
; i
++)
108 else if (c
.equals("-nowrite"))
110 else if (c
.equals("-nowarn"))
111 compiler
.setWarnings(false);
112 else if (c
.equals("-verbose"))
115 compiler
.setVerbose(true);
117 else if (c
.equals("-d"))
122 output
= new File(args
[f
]);
126 HelpPrinter
.printHelpAndExit(HelpPath
);
128 else if (c
.charAt(0) != '-')
129 // No more options - start of class list.
137 HelpPrinter
.printHelpAndExit(HelpPath
);
140 System
.out
.println("Compiling to " + output
.getAbsolutePath());
143 Compile
: for (int i
= cl
; i
< args
.length
; i
++)
145 if (args
[i
].charAt(0) != '-')
151 c
= Thread
.currentThread().getContextClassLoader().loadClass(
154 catch (ClassNotFoundException e
)
156 System
.err
.println(args
[i
] + " class not found.");
161 String packag
= compiler
.getPackageName().replace('.', '/');
162 File fw
= new File(output
, packag
);
165 String stub
= compiler
.generateStub();
166 String subName
= compiler
.getStubName() + "_Stub.java";
174 OutputStream out
= new FileOutputStream(new File(fw
,
176 out
.write(stub
.getBytes());
179 catch (IOException ioex
)
181 System
.err
.println("Output path not accessible");
182 ioex
.printStackTrace();
191 * Print the version information.
193 public static void printVersion()
196 ("rmic v "+VERSION
+" - RMI stub generator for java.rmi.* ");