61 |
private boolean need12Stubs = true; |
private boolean need12Stubs = true; |
62 |
private boolean compile = true; |
private boolean compile = true; |
63 |
private boolean verbose; |
private boolean verbose; |
64 |
private String destination; |
private String destination = ""; |
65 |
|
|
66 |
private PrintWriter out; |
private PrintWriter out; |
67 |
private TabbedWriter ctrl; |
private TabbedWriter ctrl; |
138 |
} |
} |
139 |
|
|
140 |
private void analyzeClass(String cname) throws Exception { |
private void analyzeClass(String cname) throws Exception { |
141 |
|
if(verbose){ |
142 |
|
System.out.println("[analyze class "+cname+"]"); |
143 |
|
} |
144 |
int p = cname.lastIndexOf('.'); |
int p = cname.lastIndexOf('.'); |
145 |
if (p != -1) { |
if (p != -1) { |
146 |
classname = cname.substring(p+1); |
classname = cname.substring(p+1); |
150 |
} |
} |
151 |
fullclassname = cname; |
fullclassname = cname; |
152 |
|
|
153 |
// ??? |
|
154 |
HashSet rmeths = new HashSet(); |
HashSet rmeths = new HashSet(); |
155 |
findClass(); |
findClass(); |
156 |
|
|
157 |
// get the remote interface |
// get the remote interface |
158 |
mRemoteInterface = getRemoteInterface(clazz); |
mRemoteInterface = getRemoteInterface(clazz); |
159 |
|
if(mRemoteInterface == null) |
160 |
|
return; |
161 |
|
if(verbose){ |
162 |
|
System.out.println("[implements "+mRemoteInterface.getName()+"]"); |
163 |
|
} |
164 |
|
|
165 |
// check if the methods of the remote interface declare RemoteExceptions |
// check if the methods of the remote interface declare RemoteExceptions |
166 |
Method[] meths = mRemoteInterface.getDeclaredMethods(); |
Method[] meths = mRemoteInterface.getDeclaredMethods(); |
167 |
for (int i = 0; i < meths.length; i++) { |
for (int i = 0; i < meths.length; i++) { |
168 |
// NYI: ignore check until Method.getExceptionTypes is implemented |
Class[] exceptions = meths[i].getExceptionTypes(); |
169 |
// Class[] exceptions = meths[i].getExceptionTypes(); |
int index = 0; |
170 |
// int index = 0; |
for(;index < exceptions.length; index++){ |
171 |
// for(;index < exceptions.length; index++){ |
if(exceptions[index].equals(RemoteException.class)){ |
172 |
// if(exceptions[index].equals(RemoteException.class)){ |
break; |
173 |
// break; |
} |
174 |
// } |
} |
175 |
// } |
if (index < exceptions.length) { |
|
// if (index < exceptions.length) { |
|
176 |
rmeths.add(meths[i]); |
rmeths.add(meths[i]); |
177 |
// } else { |
} else { |
178 |
// logError("Method "+meths[i]+" does not throw a java.rmi.RemoteException"); |
logError("Method "+meths[i]+" does not throw a java.rmi.RemoteException"); |
179 |
// } |
} |
180 |
} |
} |
181 |
|
|
182 |
|
|
199 |
|
|
200 |
private void generateStub() throws IOException { |
private void generateStub() throws IOException { |
201 |
stubname = classname + "_Stub"; |
stubname = classname + "_Stub"; |
202 |
ctrl = new TabbedWriter(new FileWriter(stubname + ".java")); |
ctrl = new TabbedWriter(new FileWriter(destination + File.separator + stubname + ".java")); |
203 |
out = new PrintWriter(ctrl); |
out = new PrintWriter(ctrl); |
204 |
|
|
205 |
if (verbose) { |
if (verbose) { |
362 |
} |
} |
363 |
} |
} |
364 |
out.print(") "); |
out.print(") "); |
365 |
// NYI hard-code java.rmi.RemoteException until Method.getExceptionTypes is implemented |
out.print("throws "); |
|
// out.print("throws "); |
|
|
out.print("throws java.rmi.RemoteException"); |
|
366 |
for (int j = 0; j < except.length; j++) { |
for (int j = 0; j < except.length; j++) { |
367 |
out.print(getPrettyName(except[j])); |
out.print(getPrettyName(except[j])); |
368 |
if (j+1 < except.length) { |
if (j+1 < except.length) { |
620 |
|
|
621 |
private void generateSkel() throws IOException { |
private void generateSkel() throws IOException { |
622 |
skelname = classname + "_Skel"; |
skelname = classname + "_Skel"; |
623 |
ctrl = new TabbedWriter(new FileWriter(skelname + ".java")); |
ctrl = new TabbedWriter(new FileWriter(destination + File.separator + skelname + ".java")); |
624 |
out = new PrintWriter(ctrl); |
out = new PrintWriter(ctrl); |
625 |
|
|
626 |
if (verbose) { |
if (verbose) { |
980 |
} |
} |
981 |
} |
} |
982 |
|
|
983 |
|
/** |
984 |
|
* Looks for the java.rmi.Remote interface that that is implemented by theClazz. |
985 |
|
* @param theClazz the class to look in |
986 |
|
* @return the Remote interface of theClazz or null if theClazz does not implement a Remote interface |
987 |
|
*/ |
988 |
|
private Class getRemoteInterface(Class theClazz) |
989 |
|
{ |
990 |
|
Class[] interfaces = theClazz.getInterfaces(); |
991 |
|
for (int i = 0; i < interfaces.length; i++) |
992 |
|
{ |
993 |
|
if (java.rmi.Remote.class.isAssignableFrom(interfaces[i])) |
994 |
|
{ |
995 |
|
return interfaces[i]; |
996 |
|
} |
997 |
|
} |
998 |
|
logError("Class "+ theClazz.getName() |
999 |
|
+ " is not a remote object. It does not implement an interface that is a java.rmi.Remote-interface."); |
1000 |
|
return null; |
1001 |
|
} |
1002 |
|
|
1003 |
|
/** |
1004 |
|
* Prints an error to System.err and increases the error count. |
1005 |
|
* @param theError |
1006 |
|
*/ |
1007 |
|
private void logError(String theError){ |
1008 |
|
errorCount++; |
1009 |
|
System.err.println("error:"+theError); |
1010 |
|
} |
1011 |
|
|
1012 |
private static void error(String message) { |
private static void error(String message) { |
1013 |
System.err.println("rmic: " + message); |
System.err.println("rmic: " + message); |
1014 |
System.err.println("Try `rmic --help' for more information."); |
System.err.println("Try `rmic --help' for more information."); |
1062 |
|
|
1063 |
} |
} |
1064 |
|
|
|
/** |
|
|
* Looks for the java.rmi.Remote interface that that is implemented by theClazz. |
|
|
* @param theClazz the class to look in |
|
|
* @return the Remote interface of theClazz |
|
|
*/ |
|
|
private Class getRemoteInterface(Class theClazz) |
|
|
{ |
|
|
System.out.println( |
|
|
"[RMIC]looking for remote interface in " + theClazz.getName()); |
|
|
Class[] interfaces = theClazz.getInterfaces(); |
|
|
System.out.println("[RMIC] got interface array"); |
|
|
for (int i = 0; i < interfaces.length; i++) |
|
|
{ |
|
|
if (java.rmi.Remote.class.isAssignableFrom(interfaces[i])) |
|
|
{ |
|
|
System.out.println("[RMIC]found remote interface " + interfaces[i].getName()); |
|
|
return interfaces[i]; |
|
|
} |
|
|
} |
|
|
System.out.println("[RMIC]found no remote interface"); |
|
|
|
|
|
logError("Class "+ theClazz.getName() |
|
|
+ " is not a remote object. It does not implement an interface that is a java.rmi.Remote-interface."); |
|
|
return null; |
|
|
} |
|
|
|
|
|
/** |
|
|
* Prints an error to System.err and increases the error count. |
|
|
* @param theError |
|
|
*/ |
|
|
private void logError(String theError){ |
|
|
errorCount++; |
|
|
System.err.println("error:"+theError); |
|
|
} |
|
|
|
|
|
|
|
1065 |
} |
} |