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
23 package gnu
.classpath
.tools
.rmi
;
25 import gnu
.classpath
.tools
.HelpPrinter
;
26 import gnu
.classpath
.tools
.giop
.GRMIC
;
27 import gnu
.classpath
.tools
.rmi
.rmic
.RmicCompiler
;
30 import java
.io
.FileOutputStream
;
31 import java
.io
.IOException
;
32 import java
.io
.OutputStream
;
35 * Generates the ordinary stubs (not GIOP based) for java.rmi.* package.
37 * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
42 * The version of the compiler.
44 public static String VERSION
= "0.0 alpha pre";
47 * The GRMIC compiler methods
49 * @param args the compiler parameters.
51 public static void main(String
[] args
)
53 // Check for the -iiop or -giop keys. If one of these keys is present,
54 // forward all call to GRMIC.
55 for (int i
= 0; i
< args
.length
; i
++)
57 if (args
[i
].equals("-giop") || args
[i
].equals("-iiop"))
64 boolean noWrite
= false;
65 boolean verbose
= false;
67 String HelpPath
= "rmi/RMIC.txt";
69 HelpPrinter
.checkHelpKey(args
, HelpPath
);
71 File output
= new File(".");
75 HelpPrinter
.printHelpAndExit(HelpPath
);
79 RmicCompiler compiler
= new RmicCompiler();
83 Options
: for (int i
= 0; i
< args
.length
; i
++)
91 else if (c
.equals("-nowrite"))
93 else if (c
.equals("-nowarn"))
94 compiler
.setWarnings(false);
95 else if (c
.equals("-verbose"))
98 compiler
.setVerbose(true);
100 else if (c
.equals("-force"))
102 compiler
.setForce(true);
104 else if (c
.equals("-d"))
109 output
= new File(args
[f
]);
113 HelpPrinter
.printHelpAndExit(HelpPath
);
115 else if (c
.charAt(0) != '-')
116 // No more options - start of class list.
124 HelpPrinter
.printHelpAndExit(HelpPath
);
127 System
.out
.println("Compiling to " + output
.getAbsolutePath());
130 Compile
: for (int i
= cl
; i
< args
.length
; i
++)
132 if (args
[i
].charAt(0) != '-')
138 c
= Thread
.currentThread().getContextClassLoader().loadClass(
141 catch (ClassNotFoundException e
)
143 System
.err
.println(args
[i
] + " class not found.");
148 String packag
= compiler
.getPackageName().replace('.', '/');
149 File fw
= new File(output
, packag
);
152 String stub
= compiler
.generateStub();
153 String subName
= compiler
.getStubName() + "_Stub.java";
161 OutputStream out
= new FileOutputStream(new File(fw
,
163 out
.write(stub
.getBytes());
166 catch (IOException ioex
)
168 System
.err
.println("Output path not accessible");
169 ioex
.printStackTrace();
178 * Print the version information.
180 public static void printVersion()
183 ("rmic v "+VERSION
+" - RMI stub generator for java.rmi.* ");