Commit 659d8f1a by Michael Koch Committed by Michael Koch

RMIC.java: Reformatted.

2004-10-20  Michael Koch  <konqueror@gmx.de>

	* gnu/java/rmi/rmic/RMIC.java: Reformatted.

From-SVN: r89327
parent f4a8f279
2004-10-20 Michael Koch <konqueror@gmx.de> 2004-10-20 Michael Koch <konqueror@gmx.de>
* gnu/java/rmi/rmic/RMIC.java: Reformatted.
2004-10-20 Michael Koch <konqueror@gmx.de>
* java/sql/Timestamp.java, * java/sql/Timestamp.java,
java/text/AttributedCharacterIterator.java, java/text/AttributedCharacterIterator.java,
java/text/AttributedString.java, java/text/AttributedString.java,
......
...@@ -52,169 +52,174 @@ import java.util.HashSet; ...@@ -52,169 +52,174 @@ import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.Set; import java.util.Set;
public class RMIC {
public class RMIC
private String[] args; {
private int next; private String[] args;
private Exception exception; private int next;
private Exception exception;
private boolean keep = false; private boolean keep = false;
private boolean need11Stubs = true; private boolean need11Stubs = true;
private boolean need12Stubs = true; private boolean need12Stubs = true;
private boolean compile = true; private boolean compile = true;
private boolean verbose; private boolean verbose;
private String destination; private String destination;
private PrintWriter out;
private PrintWriter out; private TabbedWriter ctrl;
private TabbedWriter ctrl; private Class clazz;
private String classname;
private Class clazz; private String fullclassname;
private String classname; private MethodRef[] remotemethods;
private String fullclassname; private String stubname;
private MethodRef[] remotemethods; private String skelname;
private String stubname; private int errorCount = 0;
private String skelname; private Class mRemoteInterface;
private int errorCount = 0;
public RMIC(String[] a)
private Class mRemoteInterface; {
public RMIC(String[] a) {
args = a; args = a;
} }
public static void main(String args[]) { public static void main(String[] args)
{
RMIC r = new RMIC(args); RMIC r = new RMIC(args);
if (r.run() == false) { if (r.run() == false)
Exception exception = r.getException(); {
if (exception != null) { Exception e = r.getException();
exception.printStackTrace(); if (e != null)
} e.printStackTrace();
else { else
System.exit(1); System.exit(1);
} }
} }
}
public boolean run() { public boolean run()
{
parseOptions(); parseOptions();
if (next >= args.length) { if (next >= args.length)
error("no class names found"); error("no class names found");
} for (int i = next; i < args.length; i++)
for (int i = next; i < args.length; i++) { {
try { try
if (verbose) { {
if (verbose)
System.out.println("[Processing class " + args[i] + ".class]"); System.out.println("[Processing class " + args[i] + ".class]");
}
processClass(args[i].replace(File.separatorChar, '.')); processClass(args[i].replace(File.separatorChar, '.'));
} }
catch (Exception e) { catch (Exception e)
{
exception = e; exception = e;
return (false); return (false);
} }
} }
return (true); return (true);
} }
private boolean processClass(String classname) throws Exception { private boolean processClass(String classname) throws Exception
{
errorCount = 0; errorCount = 0;
analyzeClass(classname); analyzeClass(classname);
if(errorCount > 0) { if (errorCount > 0)
System.exit(1); System.exit(1);
}
generateStub(); generateStub();
if (need11Stubs) { if (need11Stubs)
generateSkel(); generateSkel();
} if (compile)
if (compile) { {
compile(stubname.replace('.', File.separatorChar) + ".java"); compile(stubname.replace('.', File.separatorChar) + ".java");
if (need11Stubs) { if (need11Stubs)
compile(skelname.replace('.', File.separatorChar) + ".java"); compile(skelname.replace('.', File.separatorChar) + ".java");
} }
} if (! keep)
if (!keep) { {
(new File(stubname.replace('.', File.separatorChar) + ".java")).delete(); (new File(stubname.replace('.', File.separatorChar) + ".java")).delete();
if (need11Stubs) { if (need11Stubs)
(new File(skelname.replace('.', File.separatorChar) + ".java")).delete(); (new File(skelname.replace('.', File.separatorChar) + ".java"))
} .delete();
} }
return (true); return (true);
}
private void analyzeClass(String cname) throws Exception {
if(verbose){
System.out.println("[analyze class "+cname+"]");
} }
private void analyzeClass(String cname) throws Exception
{
if (verbose)
System.out.println("[analyze class " + cname + "]");
int p = cname.lastIndexOf('.'); int p = cname.lastIndexOf('.');
if (p != -1) { if (p != -1)
classname = cname.substring(p+1); classname = cname.substring(p + 1);
} else
else {
classname = cname; classname = cname;
}
fullclassname = cname; fullclassname = cname;
HashSet rmeths = new HashSet(); HashSet rmeths = new HashSet();
findClass(); findClass();
// get the remote interface // get the remote interface
mRemoteInterface = getRemoteInterface(clazz); mRemoteInterface = getRemoteInterface(clazz);
if(mRemoteInterface == null) if (mRemoteInterface == null)
return; return;
if(verbose){ if (verbose)
System.out.println("[implements "+mRemoteInterface.getName()+"]"); System.out.println("[implements " + mRemoteInterface.getName() + "]");
}
// check if the methods of the remote interface declare RemoteExceptions // check if the methods of the remote interface declare RemoteExceptions
Method[] meths = mRemoteInterface.getDeclaredMethods(); Method[] meths = mRemoteInterface.getDeclaredMethods();
for (int i = 0; i < meths.length; i++) { for (int i = 0; i < meths.length; i++)
{
Class[] exceptions = meths[i].getExceptionTypes(); Class[] exceptions = meths[i].getExceptionTypes();
int index = 0; int index = 0;
for(;index < exceptions.length; index++){ for (; index < exceptions.length; index++)
if(exceptions[index].equals(RemoteException.class)){ {
if (exceptions[index].equals(RemoteException.class))
break; break;
} }
} if (index < exceptions.length)
if (index < exceptions.length) {
rmeths.add(meths[i]); rmeths.add(meths[i]);
} else { else
logError("Method "+meths[i]+" does not throw a java.rmi.RemoteException"); logError("Method " + meths[i]
+ " does not throw a java.rmi.RemoteException");
} }
}
// Convert into a MethodRef array and sort them // Convert into a MethodRef array and sort them
remotemethods = new MethodRef[rmeths.size()]; remotemethods = new MethodRef[rmeths.size()];
int c = 0; int c = 0;
for (Iterator i = rmeths.iterator(); i.hasNext(); ) { for (Iterator i = rmeths.iterator(); i.hasNext();)
remotemethods[c++] = new MethodRef((Method)i.next()); remotemethods[c++] = new MethodRef((Method) i.next());
}
Arrays.sort(remotemethods); Arrays.sort(remotemethods);
} }
public Exception getException() { public Exception getException()
{
return (exception); return (exception);
} }
private void findClass() throws ClassNotFoundException { private void findClass() throws ClassNotFoundException
clazz = Class.forName(fullclassname, true, ClassLoader.getSystemClassLoader()); {
} clazz =
Class.forName(fullclassname, true, ClassLoader.getSystemClassLoader());
}
private void generateStub() throws IOException { private void generateStub() throws IOException
{
stubname = fullclassname + "_Stub"; stubname = fullclassname + "_Stub";
String stubclassname = classname + "_Stub"; String stubclassname = classname + "_Stub";
ctrl = new TabbedWriter(new FileWriter((destination == null ? "" : destination + File.separator) ctrl =
+ stubname.replace('.', File.separatorChar) new TabbedWriter(new FileWriter((destination == null ? ""
: destination
+ File.separator)
+ stubname.replace('.',
File.separatorChar)
+ ".java")); + ".java"));
out = new PrintWriter(ctrl); out = new PrintWriter(ctrl);
if (verbose) { if (verbose)
System.out.println("[Generating class " + stubname + ".java]"); System.out.println("[Generating class " + stubname + ".java]");
}
out.println("// Stub class generated by rmic - DO NOT EDIT!"); out.println("// Stub class generated by rmic - DO NOT EDIT!");
out.println(); out.println();
if (fullclassname != classname) { if (fullclassname != classname)
String pname = fullclassname.substring(0, fullclassname.lastIndexOf('.')); {
String pname =
fullclassname.substring(0, fullclassname.lastIndexOf('.'));
out.println("package " + pname + ";"); out.println("package " + pname + ";");
out.println(); out.println();
} }
...@@ -228,38 +233,42 @@ private void generateStub() throws IOException { ...@@ -228,38 +233,42 @@ private void generateStub() throws IOException {
/* Scan implemented interfaces, and only print remote interfaces. */ /* Scan implemented interfaces, and only print remote interfaces. */
Class[] ifaces = clazz.getInterfaces(); Class[] ifaces = clazz.getInterfaces();
Set remoteIfaces = new HashSet(); Set remoteIfaces = new HashSet();
for (int i = 0; i < ifaces.length; i++) { for (int i = 0; i < ifaces.length; i++)
{
Class iface = ifaces[i]; Class iface = ifaces[i];
if (java.rmi.Remote.class.isAssignableFrom(iface)) { if (java.rmi.Remote.class.isAssignableFrom(iface))
remoteIfaces.add(iface); remoteIfaces.add(iface);
} }
}
Iterator iter = remoteIfaces.iterator(); Iterator iter = remoteIfaces.iterator();
while (iter.hasNext()) { while (iter.hasNext())
{
/* Print remote interface. */ /* Print remote interface. */
Class iface = (Class) iter.next(); Class iface = (Class) iter.next();
out.print(iface.getName()); out.print(iface.getName());
/* Print ", " if more remote interfaces follow. */ /* Print ", " if more remote interfaces follow. */
if (iter.hasNext()) { if (iter.hasNext())
out.print(", "); out.print(", ");
} }
}
ctrl.unindent(); ctrl.unindent();
out.print("{"); out.print("{");
ctrl.indent(); ctrl.indent();
// UID // UID
if (need12Stubs) { if (need12Stubs)
{
out.println("private static final long serialVersionUID = 2L;"); out.println("private static final long serialVersionUID = 2L;");
out.println(); out.println();
} }
// InterfaceHash - don't know how to calculate this - XXX // InterfaceHash - don't know how to calculate this - XXX
if (need11Stubs) { if (need11Stubs)
out.println("private static final long interfaceHash = " + RMIHashes.getInterfaceHash(clazz) + "L;"); {
out.println("private static final long interfaceHash = "
+ RMIHashes.getInterfaceHash(clazz) + "L;");
out.println(); out.println();
if (need12Stubs) { if (need12Stubs)
{
out.println("private static boolean useNewInvoke;"); out.println("private static boolean useNewInvoke;");
out.println(); out.println();
} }
...@@ -268,34 +277,37 @@ private void generateStub() throws IOException { ...@@ -268,34 +277,37 @@ private void generateStub() throws IOException {
out.print("private static final java.rmi.server.Operation[] operations = {"); out.print("private static final java.rmi.server.Operation[] operations = {");
ctrl.indent(); ctrl.indent();
for (int i = 0; i < remotemethods.length; i++) { for (int i = 0; i < remotemethods.length; i++)
{
Method m = remotemethods[i].meth; Method m = remotemethods[i].meth;
out.print("new java.rmi.server.Operation(\""); out.print("new java.rmi.server.Operation(\"");
out.print(getPrettyName(m.getReturnType()) + " "); out.print(getPrettyName(m.getReturnType()) + " ");
out.print(m.getName() + "("); out.print(m.getName() + "(");
// Output signature // Output signature
Class[] sig = m.getParameterTypes(); Class[] sig = m.getParameterTypes();
for (int j = 0; j < sig.length; j++) { for (int j = 0; j < sig.length; j++)
{
out.print(getPrettyName(sig[j])); out.print(getPrettyName(sig[j]));
if (j+1 < sig.length) { if (j + 1 < sig.length)
out.print(", "); out.print(", ");
} }
}
out.print(")\")"); out.print(")\")");
if (i + 1 < remotemethods.length) { if (i + 1 < remotemethods.length)
out.println(","); out.println(",");
} }
}
ctrl.unindent(); ctrl.unindent();
out.println("};"); out.println("};");
out.println(); out.println();
} }
// Set of method references. // Set of method references.
if (need12Stubs) { if (need12Stubs)
for (int i = 0; i < remotemethods.length; i++) { {
for (int i = 0; i < remotemethods.length; i++)
{
Method m = remotemethods[i].meth; Method m = remotemethods[i].meth;
out.println("private static java.lang.reflect.Method $method_" + m.getName() + "_" + i + ";"); out.println("private static java.lang.reflect.Method $method_"
+ m.getName() + "_" + i + ";");
} }
// Initialize the methods references. // Initialize the methods references.
...@@ -306,36 +318,37 @@ private void generateStub() throws IOException { ...@@ -306,36 +318,37 @@ private void generateStub() throws IOException {
out.print("try {"); out.print("try {");
ctrl.indent(); ctrl.indent();
if (need11Stubs) { if (need11Stubs)
{
out.println("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 });"); out.println("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 });");
out.println("useNewInvoke = true;"); out.println("useNewInvoke = true;");
} }
for (int i = 0; i < remotemethods.length; i++) { for (int i = 0; i < remotemethods.length; i++)
{
Method m = remotemethods[i].meth; Method m = remotemethods[i].meth;
out.print("$method_" + m.getName() + "_" + i + " = "); out.print("$method_" + m.getName() + "_" + i + " = ");
out.print(mRemoteInterface.getName() + ".class.getMethod(\"" + m.getName() + "\""); out.print(mRemoteInterface.getName() + ".class.getMethod(\""
+ m.getName() + "\"");
out.print(", new java.lang.Class[] {"); out.print(", new java.lang.Class[] {");
// Output signature // Output signature
Class[] sig = m.getParameterTypes(); Class[] sig = m.getParameterTypes();
for (int j = 0; j < sig.length; j++) { for (int j = 0; j < sig.length; j++)
{
out.print(getPrettyName(sig[j]) + ".class"); out.print(getPrettyName(sig[j]) + ".class");
if (j+1 < sig.length) { if (j + 1 < sig.length)
out.print(", "); out.print(", ");
} }
}
out.println("});"); out.println("});");
} }
ctrl.unindent(); ctrl.unindent();
out.println("}"); out.println("}");
out.print("catch (java.lang.NoSuchMethodException e) {"); out.print("catch (java.lang.NoSuchMethodException e) {");
ctrl.indent(); ctrl.indent();
if (need11Stubs) { if (need11Stubs)
out.print("useNewInvoke = false;"); out.print("useNewInvoke = false;");
} else
else {
out.print("throw new java.lang.NoSuchMethodError(\"stub class initialization failed\");"); out.print("throw new java.lang.NoSuchMethodError(\"stub class initialization failed\");");
}
ctrl.unindent(); ctrl.unindent();
out.print("}"); out.print("}");
...@@ -346,7 +359,8 @@ private void generateStub() throws IOException { ...@@ -346,7 +359,8 @@ private void generateStub() throws IOException {
} }
// Constructors // Constructors
if (need11Stubs) { if (need11Stubs)
{
out.print("public " + stubclassname + "() {"); out.print("public " + stubclassname + "() {");
ctrl.indent(); ctrl.indent();
out.print("super();"); out.print("super();");
...@@ -354,8 +368,10 @@ private void generateStub() throws IOException { ...@@ -354,8 +368,10 @@ private void generateStub() throws IOException {
out.println("}"); out.println("}");
} }
if (need12Stubs) { if (need12Stubs)
out.print("public " + stubclassname + "(java.rmi.server.RemoteRef ref) {"); {
out.print("public " + stubclassname
+ "(java.rmi.server.RemoteRef ref) {");
ctrl.indent(); ctrl.indent();
out.print("super(ref);"); out.print("super(ref);");
ctrl.unindent(); ctrl.unindent();
...@@ -363,120 +379,108 @@ private void generateStub() throws IOException { ...@@ -363,120 +379,108 @@ private void generateStub() throws IOException {
} }
// Method implementations // Method implementations
for (int i = 0; i < remotemethods.length; i++) { for (int i = 0; i < remotemethods.length; i++)
{
Method m = remotemethods[i].meth; Method m = remotemethods[i].meth;
Class[] sig = m.getParameterTypes(); Class[] sig = m.getParameterTypes();
Class returntype = m.getReturnType(); Class returntype = m.getReturnType();
Class[] except = sortExceptions(m.getExceptionTypes()); Class[] except = sortExceptions(m.getExceptionTypes());
out.println(); out.println();
out.print("public " + getPrettyName(returntype) + " " + m.getName() + "("); out.print("public " + getPrettyName(returntype) + " " + m.getName()
for (int j = 0; j < sig.length; j++) { + "(");
for (int j = 0; j < sig.length; j++)
{
out.print(getPrettyName(sig[j])); out.print(getPrettyName(sig[j]));
out.print(" $param_" + j); out.print(" $param_" + j);
if (j+1 < sig.length) { if (j + 1 < sig.length)
out.print(", "); out.print(", ");
} }
}
out.print(") "); out.print(") ");
out.print("throws "); out.print("throws ");
for (int j = 0; j < except.length; j++) { for (int j = 0; j < except.length; j++)
{
out.print(getPrettyName(except[j])); out.print(getPrettyName(except[j]));
if (j+1 < except.length) { if (j + 1 < except.length)
out.print(", "); out.print(", ");
} }
}
out.print(" {"); out.print(" {");
ctrl.indent(); ctrl.indent();
out.print("try {"); out.print("try {");
ctrl.indent(); ctrl.indent();
if (need12Stubs) { if (need12Stubs)
if (need11Stubs) { {
if (need11Stubs)
{
out.print("if (useNewInvoke) {"); out.print("if (useNewInvoke) {");
ctrl.indent(); ctrl.indent();
} }
if (returntype != Void.TYPE) { if (returntype != Void.TYPE)
out.print("java.lang.Object $result = "); out.print("java.lang.Object $result = ");
} out.print("ref.invoke(this, $method_" + m.getName() + "_" + i
out.print("ref.invoke(this, $method_" + m.getName() + "_" + i + ", "); + ", ");
if (sig.length == 0) { if (sig.length == 0)
out.print("null, "); out.print("null, ");
} else
else { {
out.print("new java.lang.Object[] {"); out.print("new java.lang.Object[] {");
for (int j = 0; j < sig.length; j++) { for (int j = 0; j < sig.length; j++)
if (sig[j] == Boolean.TYPE) { {
if (sig[j] == Boolean.TYPE)
out.print("new java.lang.Boolean($param_" + j + ")"); out.print("new java.lang.Boolean($param_" + j + ")");
} else if (sig[j] == Byte.TYPE)
else if (sig[j] == Byte.TYPE) {
out.print("new java.lang.Byte($param_" + j + ")"); out.print("new java.lang.Byte($param_" + j + ")");
} else if (sig[j] == Character.TYPE)
else if (sig[j] == Character.TYPE) {
out.print("new java.lang.Character($param_" + j + ")"); out.print("new java.lang.Character($param_" + j + ")");
} else if (sig[j] == Short.TYPE)
else if (sig[j] == Short.TYPE) {
out.print("new java.lang.Short($param_" + j + ")"); out.print("new java.lang.Short($param_" + j + ")");
} else if (sig[j] == Integer.TYPE)
else if (sig[j] == Integer.TYPE) {
out.print("new java.lang.Integer($param_" + j + ")"); out.print("new java.lang.Integer($param_" + j + ")");
} else if (sig[j] == Long.TYPE)
else if (sig[j] == Long.TYPE) {
out.print("new java.lang.Long($param_" + j + ")"); out.print("new java.lang.Long($param_" + j + ")");
} else if (sig[j] == Float.TYPE)
else if (sig[j] == Float.TYPE) {
out.print("new java.lang.Float($param_" + j + ")"); out.print("new java.lang.Float($param_" + j + ")");
} else if (sig[j] == Double.TYPE)
else if (sig[j] == Double.TYPE) {
out.print("new java.lang.Double($param_" + j + ")"); out.print("new java.lang.Double($param_" + j + ")");
} else
else {
out.print("$param_" + j); out.print("$param_" + j);
} if (j + 1 < sig.length)
if (j+1 < sig.length) {
out.print(", "); out.print(", ");
} }
}
out.print("}, "); out.print("}, ");
} }
out.print(Long.toString(remotemethods[i].hash) + "L"); out.print(Long.toString(remotemethods[i].hash) + "L");
out.print(");"); out.print(");");
if (returntype != Void.TYPE) { if (returntype != Void.TYPE)
{
out.println(); out.println();
out.print("return ("); out.print("return (");
if (returntype == Boolean.TYPE) { if (returntype == Boolean.TYPE)
out.print("((java.lang.Boolean)$result).booleanValue()"); out.print("((java.lang.Boolean)$result).booleanValue()");
} else if (returntype == Byte.TYPE)
else if (returntype == Byte.TYPE) {
out.print("((java.lang.Byte)$result).byteValue()"); out.print("((java.lang.Byte)$result).byteValue()");
} else if (returntype == Character.TYPE)
else if (returntype == Character.TYPE) {
out.print("((java.lang.Character)$result).charValue()"); out.print("((java.lang.Character)$result).charValue()");
} else if (returntype == Short.TYPE)
else if (returntype == Short.TYPE) {
out.print("((java.lang.Short)$result).shortValue()"); out.print("((java.lang.Short)$result).shortValue()");
} else if (returntype == Integer.TYPE)
else if (returntype == Integer.TYPE) {
out.print("((java.lang.Integer)$result).intValue()"); out.print("((java.lang.Integer)$result).intValue()");
} else if (returntype == Long.TYPE)
else if (returntype == Long.TYPE) {
out.print("((java.lang.Long)$result).longValue()"); out.print("((java.lang.Long)$result).longValue()");
} else if (returntype == Float.TYPE)
else if (returntype == Float.TYPE) {
out.print("((java.lang.Float)$result).floatValue()"); out.print("((java.lang.Float)$result).floatValue()");
} else if (returntype == Double.TYPE)
else if (returntype == Double.TYPE) {
out.print("((java.lang.Double)$result).doubleValue()"); out.print("((java.lang.Double)$result).doubleValue()");
} else
else {
out.print("(" + getPrettyName(returntype) + ")$result"); out.print("(" + getPrettyName(returntype) + ")$result");
}
out.print(");"); out.print(");");
} }
if (need11Stubs) { if (need11Stubs)
{
ctrl.unindent(); ctrl.unindent();
out.println("}"); out.println("}");
out.print("else {"); out.print("else {");
...@@ -484,40 +488,34 @@ private void generateStub() throws IOException { ...@@ -484,40 +488,34 @@ private void generateStub() throws IOException {
} }
} }
if (need11Stubs) { if (need11Stubs)
out.println("java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject)this, operations, " + i + ", interfaceHash);"); {
out.println("java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject)this, operations, "
+ i + ", interfaceHash);");
out.print("try {"); out.print("try {");
ctrl.indent(); ctrl.indent();
out.print("java.io.ObjectOutput out = call.getOutputStream();"); out.print("java.io.ObjectOutput out = call.getOutputStream();");
for (int j = 0; j < sig.length; j++) { for (int j = 0; j < sig.length; j++)
{
out.println(); out.println();
if (sig[j] == Boolean.TYPE) { if (sig[j] == Boolean.TYPE)
out.print("out.writeBoolean("); out.print("out.writeBoolean(");
} else if (sig[j] == Byte.TYPE)
else if (sig[j] == Byte.TYPE) {
out.print("out.writeByte("); out.print("out.writeByte(");
} else if (sig[j] == Character.TYPE)
else if (sig[j] == Character.TYPE) {
out.print("out.writeChar("); out.print("out.writeChar(");
} else if (sig[j] == Short.TYPE)
else if (sig[j] == Short.TYPE) {
out.print("out.writeShort("); out.print("out.writeShort(");
} else if (sig[j] == Integer.TYPE)
else if (sig[j] == Integer.TYPE) {
out.print("out.writeInt("); out.print("out.writeInt(");
} else if (sig[j] == Long.TYPE)
else if (sig[j] == Long.TYPE) {
out.print("out.writeLong("); out.print("out.writeLong(");
} else if (sig[j] == Float.TYPE)
else if (sig[j] == Float.TYPE) {
out.print("out.writeFloat("); out.print("out.writeFloat(");
} else if (sig[j] == Double.TYPE)
else if (sig[j] == Double.TYPE) {
out.print("out.writeDouble("); out.print("out.writeDouble(");
} else
else {
out.print("out.writeObject("); out.print("out.writeObject(");
}
out.print("$param_" + j + ");"); out.print("$param_" + j + ");");
} }
ctrl.unindent(); ctrl.unindent();
...@@ -528,47 +526,38 @@ private void generateStub() throws IOException { ...@@ -528,47 +526,38 @@ private void generateStub() throws IOException {
ctrl.unindent(); ctrl.unindent();
out.println("}"); out.println("}");
out.println("ref.invoke(call);"); out.println("ref.invoke(call);");
if (returntype != Void.TYPE) { if (returntype != Void.TYPE)
out.println(getPrettyName(returntype) + " $result;"); out.println(getPrettyName(returntype) + " $result;");
}
out.print("try {"); out.print("try {");
ctrl.indent(); ctrl.indent();
out.print("java.io.ObjectInput in = call.getInputStream();"); out.print("java.io.ObjectInput in = call.getInputStream();");
boolean needcastcheck = false; boolean needcastcheck = false;
if (returntype != Void.TYPE) { if (returntype != Void.TYPE)
{
out.println(); out.println();
out.print("$result = "); out.print("$result = ");
if (returntype == Boolean.TYPE) { if (returntype == Boolean.TYPE)
out.print("in.readBoolean();"); out.print("in.readBoolean();");
} else if (returntype == Byte.TYPE)
else if (returntype == Byte.TYPE) {
out.print("in.readByte();"); out.print("in.readByte();");
} else if (returntype == Character.TYPE)
else if (returntype == Character.TYPE) {
out.print("in.readChar();"); out.print("in.readChar();");
} else if (returntype == Short.TYPE)
else if (returntype == Short.TYPE) {
out.print("in.readShort();"); out.print("in.readShort();");
} else if (returntype == Integer.TYPE)
else if (returntype == Integer.TYPE) {
out.print("in.readInt();"); out.print("in.readInt();");
} else if (returntype == Long.TYPE)
else if (returntype == Long.TYPE) {
out.print("in.readLong();"); out.print("in.readLong();");
} else if (returntype == Float.TYPE)
else if (returntype == Float.TYPE) {
out.print("in.readFloat();"); out.print("in.readFloat();");
} else if (returntype == Double.TYPE)
else if (returntype == Double.TYPE) {
out.print("in.readDouble();"); out.print("in.readDouble();");
} else
else { {
if (returntype != Object.class) { if (returntype != Object.class)
out.print("(" + getPrettyName(returntype) + ")"); out.print("(" + getPrettyName(returntype) + ")");
} else
else {
needcastcheck = true; needcastcheck = true;
}
out.print("in.readObject();"); out.print("in.readObject();");
} }
out.println(); out.println();
...@@ -581,7 +570,8 @@ private void generateStub() throws IOException { ...@@ -581,7 +570,8 @@ private void generateStub() throws IOException {
out.print("throw new java.rmi.UnmarshalException(\"error unmarshalling return\", e);"); out.print("throw new java.rmi.UnmarshalException(\"error unmarshalling return\", e);");
ctrl.unindent(); ctrl.unindent();
out.println("}"); out.println("}");
if (needcastcheck) { if (needcastcheck)
{
out.print("catch (java.lang.ClassNotFoundException e) {"); out.print("catch (java.lang.ClassNotFoundException e) {");
ctrl.indent(); ctrl.indent();
out.print("throw new java.rmi.UnmarshalException(\"error unmarshalling return\", e);"); out.print("throw new java.rmi.UnmarshalException(\"error unmarshalling return\", e);");
...@@ -594,7 +584,8 @@ private void generateStub() throws IOException { ...@@ -594,7 +584,8 @@ private void generateStub() throws IOException {
ctrl.unindent(); ctrl.unindent();
out.print("}"); out.print("}");
if (need12Stubs && need11Stubs) { if (need12Stubs && need11Stubs)
{
ctrl.unindent(); ctrl.unindent();
out.print("}"); out.print("}");
} }
...@@ -604,18 +595,19 @@ private void generateStub() throws IOException { ...@@ -604,18 +595,19 @@ private void generateStub() throws IOException {
out.print("}"); out.print("}");
boolean needgeneral = true; boolean needgeneral = true;
for (int j = 0; j < except.length; j++) { for (int j = 0; j < except.length; j++)
{
out.println(); out.println();
out.print("catch (" + getPrettyName(except[j]) + " e) {"); out.print("catch (" + getPrettyName(except[j]) + " e) {");
ctrl.indent(); ctrl.indent();
out.print("throw e;"); out.print("throw e;");
ctrl.unindent(); ctrl.unindent();
out.print("}"); out.print("}");
if (except[j] == Exception.class) { if (except[j] == Exception.class)
needgeneral = false; needgeneral = false;
} }
} if (needgeneral)
if (needgeneral) { {
out.println(); out.println();
out.print("catch (java.lang.Exception e) {"); out.print("catch (java.lang.Exception e) {");
ctrl.indent(); ctrl.indent();
...@@ -633,24 +625,30 @@ private void generateStub() throws IOException { ...@@ -633,24 +625,30 @@ private void generateStub() throws IOException {
out.println("}"); out.println("}");
out.close(); out.close();
} }
private void generateSkel() throws IOException { private void generateSkel() throws IOException
{
skelname = fullclassname + "_Skel"; skelname = fullclassname + "_Skel";
String skelclassname = classname + "_Skel"; String skelclassname = classname + "_Skel";
ctrl = new TabbedWriter(new FileWriter((destination == null ? "" : destination + File.separator) ctrl =
+ skelname.replace('.', File.separatorChar) new TabbedWriter(new FileWriter((destination == null ? ""
: destination
+ File.separator)
+ skelname.replace('.',
File.separatorChar)
+ ".java")); + ".java"));
out = new PrintWriter(ctrl); out = new PrintWriter(ctrl);
if (verbose) { if (verbose)
System.out.println("[Generating class " + skelname + ".java]"); System.out.println("[Generating class " + skelname + ".java]");
}
out.println("// Skel class generated by rmic - DO NOT EDIT!"); out.println("// Skel class generated by rmic - DO NOT EDIT!");
out.println(); out.println();
if (fullclassname != classname) { if (fullclassname != classname)
String pname = fullclassname.substring(0, fullclassname.lastIndexOf('.')); {
String pname =
fullclassname.substring(0, fullclassname.lastIndexOf('.'));
out.println("package " + pname + ";"); out.println("package " + pname + ";");
out.println(); out.println();
} }
...@@ -666,31 +664,32 @@ private void generateSkel() throws IOException { ...@@ -666,31 +664,32 @@ private void generateSkel() throws IOException {
ctrl.indent(); ctrl.indent();
// Interface hash - don't know how to calculate this - XXX // Interface hash - don't know how to calculate this - XXX
out.println("private static final long interfaceHash = " + RMIHashes.getInterfaceHash(clazz) + "L;"); out.println("private static final long interfaceHash = "
+ RMIHashes.getInterfaceHash(clazz) + "L;");
out.println(); out.println();
// Operation table // Operation table
out.print("private static final java.rmi.server.Operation[] operations = {"); out.print("private static final java.rmi.server.Operation[] operations = {");
ctrl.indent(); ctrl.indent();
for (int i = 0; i < remotemethods.length; i++) { for (int i = 0; i < remotemethods.length; i++)
{
Method m = remotemethods[i].meth; Method m = remotemethods[i].meth;
out.print("new java.rmi.server.Operation(\""); out.print("new java.rmi.server.Operation(\"");
out.print(getPrettyName(m.getReturnType()) + " "); out.print(getPrettyName(m.getReturnType()) + " ");
out.print(m.getName() + "("); out.print(m.getName() + "(");
// Output signature // Output signature
Class[] sig = m.getParameterTypes(); Class[] sig = m.getParameterTypes();
for (int j = 0; j < sig.length; j++) { for (int j = 0; j < sig.length; j++)
{
out.print(getPrettyName(sig[j])); out.print(getPrettyName(sig[j]));
if (j+1 < sig.length) { if (j + 1 < sig.length)
out.print(", "); out.print(", ");
} }
}
out.print("\")"); out.print("\")");
if (i + 1 < remotemethods.length) { if (i + 1 < remotemethods.length)
out.println(","); out.println(",");
} }
}
ctrl.unindent(); ctrl.unindent();
out.println("};"); out.println("};");
...@@ -712,8 +711,10 @@ private void generateSkel() throws IOException { ...@@ -712,8 +711,10 @@ private void generateSkel() throws IOException {
out.print("if (opnum < 0) {"); out.print("if (opnum < 0) {");
ctrl.indent(); ctrl.indent();
for (int i = 0; i < remotemethods.length; i++) { for (int i = 0; i < remotemethods.length; i++)
out.print("if (hash == " + Long.toString(remotemethods[i].hash) + "L) {"); {
out.print("if (hash == " + Long.toString(remotemethods[i].hash)
+ "L) {");
ctrl.indent(); ctrl.indent();
out.print("opnum = " + i + ";"); out.print("opnum = " + i + ";");
ctrl.unindent(); ctrl.unindent();
...@@ -740,14 +741,16 @@ private void generateSkel() throws IOException { ...@@ -740,14 +741,16 @@ private void generateSkel() throws IOException {
out.println("switch (opnum) {"); out.println("switch (opnum) {");
// Method dispatch // Method dispatch
for (int i = 0; i < remotemethods.length; i++) { for (int i = 0; i < remotemethods.length; i++)
{
Method m = remotemethods[i].meth; Method m = remotemethods[i].meth;
out.println("case " + i + ":"); out.println("case " + i + ":");
out.print("{"); out.print("{");
ctrl.indent(); ctrl.indent();
Class[] sig = m.getParameterTypes(); Class[] sig = m.getParameterTypes();
for (int j = 0; j < sig.length; j++) { for (int j = 0; j < sig.length; j++)
{
out.print(getPrettyName(sig[j])); out.print(getPrettyName(sig[j]));
out.println(" $param_" + j + ";"); out.println(" $param_" + j + ";");
} }
...@@ -756,34 +759,29 @@ private void generateSkel() throws IOException { ...@@ -756,34 +759,29 @@ private void generateSkel() throws IOException {
boolean needcastcheck = false; boolean needcastcheck = false;
ctrl.indent(); ctrl.indent();
out.println("java.io.ObjectInput in = call.getInputStream();"); out.println("java.io.ObjectInput in = call.getInputStream();");
for (int j = 0; j < sig.length; j++) { for (int j = 0; j < sig.length; j++)
{
out.print("$param_" + j + " = "); out.print("$param_" + j + " = ");
if (sig[j] == Boolean.TYPE) { if (sig[j] == Boolean.TYPE)
out.print("in.readBoolean();"); out.print("in.readBoolean();");
} else if (sig[j] == Byte.TYPE)
else if (sig[j] == Byte.TYPE) {
out.print("in.readByte();"); out.print("in.readByte();");
} else if (sig[j] == Character.TYPE)
else if (sig[j] == Character.TYPE) {
out.print("in.readChar();"); out.print("in.readChar();");
} else if (sig[j] == Short.TYPE)
else if (sig[j] == Short.TYPE) {
out.print("in.readShort();"); out.print("in.readShort();");
} else if (sig[j] == Integer.TYPE)
else if (sig[j] == Integer.TYPE) {
out.print("in.readInt();"); out.print("in.readInt();");
} else if (sig[j] == Long.TYPE)
else if (sig[j] == Long.TYPE) {
out.print("in.readLong();"); out.print("in.readLong();");
} else if (sig[j] == Float.TYPE)
else if (sig[j] == Float.TYPE) {
out.print("in.readFloat();"); out.print("in.readFloat();");
} else if (sig[j] == Double.TYPE)
else if (sig[j] == Double.TYPE) {
out.print("in.readDouble();"); out.print("in.readDouble();");
} else
else { {
if (sig[j] != Object.class) { if (sig[j] != Object.class)
{
out.print("(" + getPrettyName(sig[j]) + ")"); out.print("(" + getPrettyName(sig[j]) + ")");
needcastcheck = true; needcastcheck = true;
} }
...@@ -798,7 +796,8 @@ private void generateSkel() throws IOException { ...@@ -798,7 +796,8 @@ private void generateSkel() throws IOException {
out.print("throw new java.rmi.UnmarshalException(\"error unmarshalling arguments\", e);"); out.print("throw new java.rmi.UnmarshalException(\"error unmarshalling arguments\", e);");
ctrl.unindent(); ctrl.unindent();
out.println("}"); out.println("}");
if (needcastcheck) { if (needcastcheck)
{
out.print("catch (java.lang.ClassCastException e) {"); out.print("catch (java.lang.ClassCastException e) {");
ctrl.indent(); ctrl.indent();
out.print("throw new java.rmi.UnmarshalException(\"error unmarshalling arguments\", e);"); out.print("throw new java.rmi.UnmarshalException(\"error unmarshalling arguments\", e);");
...@@ -812,51 +811,42 @@ private void generateSkel() throws IOException { ...@@ -812,51 +811,42 @@ private void generateSkel() throws IOException {
out.println("}"); out.println("}");
Class returntype = m.getReturnType(); Class returntype = m.getReturnType();
if (returntype != Void.TYPE) { if (returntype != Void.TYPE)
out.print(getPrettyName(returntype) + " $result = "); out.print(getPrettyName(returntype) + " $result = ");
}
out.print("server." + m.getName() + "("); out.print("server." + m.getName() + "(");
for (int j = 0; j < sig.length; j++) { for (int j = 0; j < sig.length; j++)
{
out.print("$param_" + j); out.print("$param_" + j);
if (j + 1 < sig.length) { if (j + 1 < sig.length)
out.print(", "); out.print(", ");
} }
}
out.println(");"); out.println(");");
out.print("try {"); out.print("try {");
ctrl.indent(); ctrl.indent();
out.print("java.io.ObjectOutput out = call.getResultStream(true);"); out.print("java.io.ObjectOutput out = call.getResultStream(true);");
if (returntype != Void.TYPE) { if (returntype != Void.TYPE)
{
out.println(); out.println();
if (returntype == Boolean.TYPE) { if (returntype == Boolean.TYPE)
out.print("out.writeBoolean($result);"); out.print("out.writeBoolean($result);");
} else if (returntype == Byte.TYPE)
else if (returntype == Byte.TYPE) {
out.print("out.writeByte($result);"); out.print("out.writeByte($result);");
} else if (returntype == Character.TYPE)
else if (returntype == Character.TYPE) {
out.print("out.writeChar($result);"); out.print("out.writeChar($result);");
} else if (returntype == Short.TYPE)
else if (returntype == Short.TYPE) {
out.print("out.writeShort($result);"); out.print("out.writeShort($result);");
} else if (returntype == Integer.TYPE)
else if (returntype == Integer.TYPE) {
out.print("out.writeInt($result);"); out.print("out.writeInt($result);");
} else if (returntype == Long.TYPE)
else if (returntype == Long.TYPE) {
out.print("out.writeLong($result);"); out.print("out.writeLong($result);");
} else if (returntype == Float.TYPE)
else if (returntype == Float.TYPE) {
out.print("out.writeFloat($result);"); out.print("out.writeFloat($result);");
} else if (returntype == Double.TYPE)
else if (returntype == Double.TYPE) {
out.print("out.writeDouble($result);"); out.print("out.writeDouble($result);");
} else
else {
out.print("out.writeObject($result);"); out.print("out.writeObject($result);");
} }
}
ctrl.unindent(); ctrl.unindent();
out.println("}"); out.println("}");
out.print("catch (java.io.IOException e) {"); out.print("catch (java.io.IOException e) {");
...@@ -884,38 +874,44 @@ private void generateSkel() throws IOException { ...@@ -884,38 +874,44 @@ private void generateSkel() throws IOException {
out.println("}"); out.println("}");
out.close(); out.close();
} }
private void compile(String name) throws Exception { private void compile(String name) throws Exception
{
Compiler comp = Compiler.getInstance(); Compiler comp = Compiler.getInstance();
if (verbose) { if (verbose)
System.out.println("[Compiling class " + name + "]"); System.out.println("[Compiling class " + name + "]");
}
comp.setDestination(destination); comp.setDestination(destination);
comp.compile(name); comp.compile(name);
} }
private static String getPrettyName(Class cls) { private static String getPrettyName(Class cls)
{
StringBuffer str = new StringBuffer(); StringBuffer str = new StringBuffer();
for (int count = 0;; count++) { for (int count = 0;; count++)
if (!cls.isArray()) { {
if (! cls.isArray())
{
str.append(cls.getName()); str.append(cls.getName());
for (; count > 0; count--) { for (; count > 0; count--)
str.append("[]"); str.append("[]");
}
return (str.toString()); return (str.toString());
} }
cls = cls.getComponentType(); cls = cls.getComponentType();
} }
} }
/** /**
* Sort exceptions so the most general go last. * Sort exceptions so the most general go last.
*/ */
private Class[] sortExceptions(Class[] except) { private Class[] sortExceptions(Class[] except)
for (int i = 0; i < except.length; i++) { {
for (int j = i+1; j < except.length; j++) { for (int i = 0; i < except.length; i++)
if (except[i].isAssignableFrom(except[j])) { {
for (int j = i + 1; j < except.length; j++)
{
if (except[i].isAssignableFrom(except[j]))
{
Class tmp = except[i]; Class tmp = except[i];
except[i] = except[j]; except[i] = except[j];
except[j] = tmp; except[j] = tmp;
...@@ -923,163 +919,160 @@ private Class[] sortExceptions(Class[] except) { ...@@ -923,163 +919,160 @@ private Class[] sortExceptions(Class[] except) {
} }
} }
return (except); return (except);
} }
/** /**
* Process the options until we find the first argument. * Process the options until we find the first argument.
*/ */
private void parseOptions() { private void parseOptions()
for (;;) { {
if (next >= args.length || args[next].charAt(0) != '-') { for (;;)
{
if (next >= args.length || args[next].charAt(0) != '-')
break; break;
}
String arg = args[next]; String arg = args[next];
next++; next++;
// Accept `--' options if they look long enough. // Accept `--' options if they look long enough.
if (arg.length() > 3 && arg.charAt(0) == '-' if (arg.length() > 3 && arg.charAt(0) == '-' && arg.charAt(1) == '-')
&& arg.charAt(1) == '-')
arg = arg.substring(1); arg = arg.substring(1);
if (arg.equals("-keep")) { if (arg.equals("-keep"))
keep = true; keep = true;
} else if (arg.equals("-keepgenerated"))
else if (arg.equals("-keepgenerated")) {
keep = true; keep = true;
} else if (arg.equals("-v1.1"))
else if (arg.equals("-v1.1")) { {
need11Stubs = true; need11Stubs = true;
need12Stubs = false; need12Stubs = false;
} }
else if (arg.equals("-vcompat")) { else if (arg.equals("-vcompat"))
{
need11Stubs = true; need11Stubs = true;
need12Stubs = true; need12Stubs = true;
} }
else if (arg.equals("-v1.2")) { else if (arg.equals("-v1.2"))
{
need11Stubs = false; need11Stubs = false;
need12Stubs = true; need12Stubs = true;
} }
else if (arg.equals("-g")) { else if (arg.equals("-g"))
{
} }
else if (arg.equals("-depend")) { else if (arg.equals("-depend"))
{
} }
else if (arg.equals("-nowarn")) { else if (arg.equals("-nowarn"))
{
} }
else if (arg.equals("-verbose")) { else if (arg.equals("-verbose"))
verbose = true; verbose = true;
} else if (arg.equals("-nocompile"))
else if (arg.equals("-nocompile")) {
compile = false; compile = false;
} else if (arg.equals("-classpath"))
else if (arg.equals("-classpath")) {
next++; next++;
} else if (arg.equals("-help"))
else if (arg.equals("-help")) {
usage(); usage();
} else if (arg.equals("-version"))
else if (arg.equals("-version")) { {
System.out.println("rmic (" System.out.println("rmic (" + System.getProperty("java.vm.name")
+ System.getProperty("java.vm.name") + ") " + System.getProperty("java.vm.version"));
+ ") "
+ System.getProperty("java.vm.version"));
System.out.println(); System.out.println();
System.out.println("Copyright 2002 Free Software Foundation, Inc."); System.out.println("Copyright 2002 Free Software Foundation, Inc.");
System.out.println("This is free software; see the source for copying conditions. There is NO"); System.out.println("This is free software; see the source for copying conditions. There is NO");
System.out.println("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."); System.out.println("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.");
System.exit(0); System.exit(0);
} }
else if (arg.equals("-d")) { else if (arg.equals("-d"))
{
destination = args[next]; destination = args[next];
next++; next++;
} }
else if (arg.charAt(1) == 'J') { else if (arg.charAt(1) == 'J')
{
} }
else { else
error("unrecognized option `" + arg + "'"); error("unrecognized option `" + arg + "'");
} }
} }
}
/** /**
* Looks for the java.rmi.Remote interface that that is implemented by theClazz. * Looks for the java.rmi.Remote interface that that is implemented by theClazz.
* @param theClazz the class to look in * @param theClazz the class to look in
* @return the Remote interface of theClazz or null if theClazz does not implement a Remote interface * @return the Remote interface of theClazz or null if theClazz does not implement a Remote interface
*/ */
private Class getRemoteInterface(Class theClazz) private Class getRemoteInterface(Class theClazz)
{ {
Class[] interfaces = theClazz.getInterfaces(); Class[] interfaces = theClazz.getInterfaces();
for (int i = 0; i < interfaces.length; i++) for (int i = 0; i < interfaces.length; i++)
{ {
if (java.rmi.Remote.class.isAssignableFrom(interfaces[i])) if (java.rmi.Remote.class.isAssignableFrom(interfaces[i]))
{
return interfaces[i]; return interfaces[i];
} }
} logError("Class " + theClazz.getName()
logError("Class "+ theClazz.getName()
+ " is not a remote object. It does not implement an interface that is a java.rmi.Remote-interface."); + " is not a remote object. It does not implement an interface that is a java.rmi.Remote-interface.");
return null; return null;
} }
/** /**
* Prints an error to System.err and increases the error count. * Prints an error to System.err and increases the error count.
* @param theError * @param theError
*/ */
private void logError(String theError){ private void logError(String theError)
{
errorCount++; errorCount++;
System.err.println("error:"+theError); System.err.println("error:" + theError);
} }
private static void error(String message) { private static void error(String message)
{
System.err.println("rmic: " + message); System.err.println("rmic: " + message);
System.err.println("Try `rmic --help' for more information."); System.err.println("Try `rmic --help' for more information.");
System.exit(1); System.exit(1);
} }
private static void usage() { private static void usage()
System.out.println( {
"Usage: rmic [OPTION]... CLASS...\n" + System.out.println("Usage: rmic [OPTION]... CLASS...\n" + "\n"
"\n" + + " -keep Don't delete any intermediate files\n"
" -keep Don't delete any intermediate files\n" + + " -keepgenerated Same as -keep\n"
" -keepgenerated Same as -keep\n" + + " -v1.1 Java 1.1 style stubs only\n"
" -v1.1 Java 1.1 style stubs only\n" + + " -vcompat Java 1.1 & Java 1.2 stubs\n"
" -vcompat Java 1.1 & Java 1.2 stubs\n" + + " -v1.2 Java 1.2 style stubs only\n"
" -v1.2 Java 1.2 style stubs only\n" + + " -g * Generated debugging information\n"
" -g * Generated debugging information\n" + + " -depend * Recompile out-of-date files\n"
" -depend * Recompile out-of-date files\n" + + " -nowarn * Suppress warning messages\n"
" -nowarn * Suppress warning messages\n" + + " -nocompile Don't compile the generated files\n"
" -nocompile Don't compile the generated files\n" + + " -verbose Output what's going on\n"
" -verbose Output what's going on\n" + + " -classpath <path> * Use given path as classpath\n"
" -classpath <path> * Use given path as classpath\n" + + " -d <directory> Specify where to place generated classes\n"
" -d <directory> Specify where to place generated classes\n" + + " -J<flag> * Pass flag to Java\n"
" -J<flag> * Pass flag to Java\n" + + " -help Print this help, then exit\n"
" -help Print this help, then exit\n" + + " -version Print version number, then exit\n" + "\n"
" -version Print version number, then exit\n" + + " * Option currently ignored\n"
"\n" + + "Long options can be used with `--option' form as well.");
" * Option currently ignored\n" +
"Long options can be used with `--option' form as well."
);
System.exit(0); System.exit(0);
} }
static class MethodRef
implements Comparable {
Method meth; static class MethodRef
String sig; implements Comparable
long hash; {
Method meth;
String sig;
long hash;
MethodRef(Method m) { MethodRef(Method m)
{
meth = m; meth = m;
// We match on the name - but what about overloading? - XXX // We match on the name - but what about overloading? - XXX
sig = m.getName(); sig = m.getName();
hash = RMIHashes.getMethodHash(m); hash = RMIHashes.getMethodHash(m);
} }
public int compareTo(Object obj) { public int compareTo(Object obj)
MethodRef that = (MethodRef)obj; {
MethodRef that = (MethodRef) obj;
return (this.sig.compareTo(that.sig)); return (this.sig.compareTo(that.sig));
} }
}
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment