summaryrefslogtreecommitdiffstats
path: root/libjava/classpath/tools/gnu/classpath/tools/rmic
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/tools/gnu/classpath/tools/rmic')
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/rmic/ClassRmicCompiler.java126
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/rmic/Main.java6
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/rmic/RmiMethodGenerator.java8
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/rmic/SourceGiopRmicCompiler.java58
-rw-r--r--libjava/classpath/tools/gnu/classpath/tools/rmic/Variables.java27
5 files changed, 108 insertions, 117 deletions
diff --git a/libjava/classpath/tools/gnu/classpath/tools/rmic/ClassRmicCompiler.java b/libjava/classpath/tools/gnu/classpath/tools/rmic/ClassRmicCompiler.java
index 9ac103c75a1..790407bae18 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/rmic/ClassRmicCompiler.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/rmic/ClassRmicCompiler.java
@@ -1,5 +1,5 @@
/* ClassRmicCompiler.java --
- Copyright (c) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005
+ Copyright (c) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005, 2012
Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -76,26 +76,23 @@ public class ClassRmicCompiler
{
private String[] args;
private int next;
- private List errors = new ArrayList();
- private boolean keep = false;
+ private List<Exception> errors = new ArrayList<Exception>();
private boolean need11Stubs = true;
private boolean need12Stubs = true;
- private boolean compile = true;
private boolean verbose;
private boolean noWrite;
private String destination;
- private String classpath;
private ClassLoader loader;
private int errorCount = 0;
- private Class clazz;
+ private Class<?> clazz;
private String classname;
private String classInternalName;
private String fullclassname;
private MethodRef[] remotemethods;
private String stubname;
private String skelname;
- private List mRemoteInterfaces;
+ private List<Class<?>> mRemoteInterfaces;
/**
* @return true if run was successful
@@ -126,9 +123,9 @@ public class ClassRmicCompiler
}
if (errors.size() > 0)
{
- for (Iterator it = errors.iterator(); it.hasNext(); )
+ for (Iterator<Exception> it = errors.iterator(); it.hasNext(); )
{
- Exception ex = (Exception) it.next();
+ Exception ex = it.next();
logError(ex);
}
}
@@ -146,7 +143,7 @@ public class ClassRmicCompiler
remotemethods = null;
stubname = null;
skelname = null;
- mRemoteInterfaces = new ArrayList();
+ mRemoteInterfaces = new ArrayList<Class<?>>();
analyzeClass(cls);
generateStub();
@@ -175,7 +172,7 @@ public class ClassRmicCompiler
*/
public Exception getException()
{
- return errors.size() == 0 ? null : (Exception) errors.get(0);
+ return errors.size() == 0 ? null : errors.get(0);
}
private void findClass()
@@ -202,7 +199,7 @@ public class ClassRmicCompiler
}
}
- private static Type[] typeArray(Class[] cls)
+ private static Type[] typeArray(Class<?>[] cls)
{
Type[] t = new Type[cls.length];
for (int i = 0; i < cls.length; i++)
@@ -231,11 +228,11 @@ public class ClassRmicCompiler
private static final String forName = "class$";
- private static Object param(Method m, int argIndex)
+ private static List<Object> param(Method m, int argIndex)
{
- List l = new ArrayList();
+ List<Object> l = new ArrayList<Object>();
l.add(m);
- l.add(new Integer(argIndex));
+ l.add(Integer.valueOf(argIndex));
return l;
}
@@ -283,10 +280,10 @@ public class ClassRmicCompiler
cv.visitMaxs(-1, -1);
}
- private void generateClassConstant(MethodVisitor cv, Class cls) {
+ private void generateClassConstant(MethodVisitor cv, Class<?> cls) {
if (cls.isPrimitive())
{
- Class boxCls;
+ Class<?> boxCls;
if (cls.equals(Boolean.TYPE))
boxCls = Boolean.class;
else if (cls.equals(Character.TYPE))
@@ -321,7 +318,7 @@ public class ClassRmicCompiler
new Type[] { Type.getType(String.class) }));
}
- private void generateClassArray(MethodVisitor code, Class[] classes)
+ private void generateClassArray(MethodVisitor code, Class<?>[] classes)
{
code.visitLdcInsn(new Integer(classes.length));
code.visitTypeInsn(Opcodes.ANEWARRAY, typeArg(Class.class));
@@ -352,7 +349,7 @@ public class ClassRmicCompiler
desc.append(m.getName() + "(");
// signature
- Class[] sig = m.getParameterTypes();
+ Class<?>[] sig = m.getParameterTypes();
for (int j = 0; j < sig.length; j++)
{
desc.append(getPrettyName(sig[j]));
@@ -418,7 +415,6 @@ public class ClassRmicCompiler
throws IOException
{
stubname = fullclassname + "_Stub";
- String stubclassname = classname + "_Stub";
File file = new File((destination == null ? "." : destination)
+ File.separator
+ stubname.replace('.', File.separatorChar)
@@ -433,7 +429,7 @@ public class ClassRmicCompiler
Type.getType(RemoteStub.class).getInternalName();
String[] remoteInternalNames =
- internalNameArray((Class[]) mRemoteInterfaces.toArray(new Class[] {}));
+ internalNameArray(mRemoteInterfaces.toArray(new Class[mRemoteInterfaces.size()]));
stub.visit
(Opcodes.V1_2, Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL, classInternalName,
null, superInternalName, remoteInternalNames);
@@ -601,10 +597,10 @@ public class ClassRmicCompiler
for (int i = 0; i < remotemethods.length; i++)
{
Method m = remotemethods[i].meth;
- Class[] sig = m.getParameterTypes();
- Class returntype = m.getReturnType();
- Class[] except = sortExceptions
- ((Class[]) remotemethods[i].exceptions.toArray(new Class[0]));
+ Class<?>[] sig = m.getParameterTypes();
+ Class<?> returntype = m.getReturnType();
+ Class<?>[] except = sortExceptions
+ (remotemethods[i].exceptions.toArray(new Class<?>[remotemethods[i].exceptions.size()]));
MethodVisitor code = stub.visitMethod
(Opcodes.ACC_PUBLIC,
@@ -664,9 +660,8 @@ public class ClassRmicCompiler
for (int j = 0; j < sig.length; j++)
{
- int size = size(sig[j]);
int insn = loadOpcode(sig[j]);
- Class box = sig[j].isPrimitive() ? box(sig[j]) : null;
+ Class<?> box = sig[j].isPrimitive() ? box(sig[j]) : null;
code.visitVarInsn(Opcodes.ALOAD, var.get("argArray"));
code.visitLdcInsn(new Integer(j));
@@ -695,7 +690,7 @@ public class ClassRmicCompiler
}
// push remote operation opcode
- code.visitLdcInsn(new Long(remotemethods[i].hash));
+ code.visitLdcInsn(Long.valueOf(remotemethods[i].hash));
code.visitMethodInsn
(Opcodes.INVOKEINTERFACE,
Type.getInternalName(RemoteRef.class),
@@ -710,7 +705,7 @@ public class ClassRmicCompiler
if (! returntype.equals(Void.TYPE))
{
int retcode = returnOpcode(returntype);
- Class boxCls =
+ Class<?> boxCls =
returntype.isPrimitive() ? box(returntype) : null;
code.visitTypeInsn
(Opcodes.CHECKCAST, typeArg(boxCls == null ? returntype : boxCls));
@@ -797,7 +792,7 @@ public class ClassRmicCompiler
// get j'th arg to remote method
code.visitVarInsn(loadOpcode(sig[j]), var.get(param(m, j)));
- Class argCls =
+ Class<?> argCls =
sig[j].isPrimitive() ? sig[j] : Object.class;
// out.writeFoo
@@ -872,7 +867,7 @@ public class ClassRmicCompiler
Type.getMethodDescriptor
(Type.getType(ObjectInput.class), new Type[] {}));
- Class readCls =
+ Class<?> readCls =
returntype.isPrimitive() ? returntype : Object.class;
code.visitMethodInsn
(Opcodes.INVOKEINTERFACE,
@@ -936,8 +931,6 @@ public class ClassRmicCompiler
Type.getType(Exception.class) }));
code.visitInsn(Opcodes.ATHROW);
- Label endReturnTryCatch = new Label();
-
// catch IOException
code.visitTryCatchBlock
(beginReturnTryCatch, handler, handler,
@@ -1024,7 +1017,6 @@ public class ClassRmicCompiler
private void generateSkel() throws IOException
{
skelname = fullclassname + "_Skel";
- String skelclassname = classname + "_Skel";
File file = new File(destination == null ? "" : destination
+ File.separator
+ skelname.replace('.', File.separatorChar)
@@ -1119,7 +1111,7 @@ public class ClassRmicCompiler
{
// assign opnum if hash matches supplied hash
dispatch.visitVarInsn(Opcodes.LLOAD, var.get("hash"));
- dispatch.visitLdcInsn(new Long(remotemethods[i].hash));
+ dispatch.visitLdcInsn(Long.valueOf(remotemethods[i].hash));
Label notIt = new Label();
dispatch.visitInsn(Opcodes.LCMP);
dispatch.visitJumpInsn(Opcodes.IFNE, notIt);
@@ -1214,7 +1206,7 @@ public class ClassRmicCompiler
private void generateMethodSkel(MethodVisitor cv, Method m, Variables var)
{
- Class[] sig = m.getParameterTypes();
+ Class<?>[] sig = m.getParameterTypes();
Label readArgs = new Label();
cv.visitLabel(readArgs);
@@ -1235,7 +1227,7 @@ public class ClassRmicCompiler
// dup input stream
cv.visitVarInsn(Opcodes.ALOAD, var.get("objectinput"));
- Class readCls = sig[i].isPrimitive() ? sig[i] : Object.class;
+ Class<?> readCls = sig[i].isPrimitive() ? sig[i] : Object.class;
// in.readFoo()
cv.visitMethodInsn
@@ -1314,7 +1306,7 @@ public class ClassRmicCompiler
(Opcodes.INVOKEVIRTUAL, Type.getInternalName(clazz), m.getName(),
Type.getMethodDescriptor(m));
- Class returntype = m.getReturnType();
+ Class<?> returntype = m.getReturnType();
if (! returntype.equals(Void.TYPE))
{
cv.visitVarInsn
@@ -1338,7 +1330,7 @@ public class ClassRmicCompiler
{
// out.writeFoo(result)
cv.visitVarInsn(loadOpcode(returntype), var.deallocate("result"));
- Class writeCls = returntype.isPrimitive() ? returntype : Object.class;
+ Class<?> writeCls = returntype.isPrimitive() ? returntype : Object.class;
cv.visitMethodInsn
(Opcodes.INVOKEINTERFACE,
Type.getInternalName(ObjectOutput.class),
@@ -1370,7 +1362,7 @@ public class ClassRmicCompiler
Type.getInternalName(IOException.class));
}
- private static String typeArg(Class cls)
+ private static String typeArg(Class<?> cls)
{
if (cls.isArray())
return Type.getDescriptor(cls);
@@ -1378,7 +1370,7 @@ public class ClassRmicCompiler
return Type.getInternalName(cls);
}
- private static String readMethod(Class cls)
+ private static String readMethod(Class<?> cls)
{
if (cls.equals(Void.TYPE))
throw new IllegalArgumentException("can not read void");
@@ -1406,7 +1398,7 @@ public class ClassRmicCompiler
return method;
}
- private static String writeMethod(Class cls)
+ private static String writeMethod(Class<?> cls)
{
if (cls.equals(Void.TYPE))
throw new IllegalArgumentException("can not read void");
@@ -1434,7 +1426,7 @@ public class ClassRmicCompiler
return method;
}
- private static int returnOpcode(Class cls)
+ private static int returnOpcode(Class<?> cls)
{
int returncode;
if (cls.equals(Boolean.TYPE))
@@ -1461,7 +1453,7 @@ public class ClassRmicCompiler
return returncode;
}
- private static int loadOpcode(Class cls)
+ private static int loadOpcode(Class<?> cls)
{
if (cls.equals(Void.TYPE))
throw new IllegalArgumentException("can not load void");
@@ -1489,7 +1481,7 @@ public class ClassRmicCompiler
return loadcode;
}
- private static int storeOpcode(Class cls)
+ private static int storeOpcode(Class<?> cls)
{
if (cls.equals(Void.TYPE))
throw new IllegalArgumentException("can not load void");
@@ -1517,7 +1509,7 @@ public class ClassRmicCompiler
return storecode;
}
- private static String unboxMethod(Class primitive)
+ private static String unboxMethod(Class<?> primitive)
{
if (! primitive.isPrimitive())
throw new IllegalArgumentException("can not unbox nonprimitive");
@@ -1545,12 +1537,12 @@ public class ClassRmicCompiler
return method;
}
- public static Class box(Class cls)
+ public static Class<?> box(Class<?> cls)
{
if (! cls.isPrimitive())
throw new IllegalArgumentException("can only box primitive");
- Class box;
+ Class<?> box;
if (cls.equals(Boolean.TYPE))
box = Boolean.class;
else if (cls.equals(Byte.TYPE))
@@ -1573,7 +1565,7 @@ public class ClassRmicCompiler
return box;
}
- private static int size(Class cls) {
+ private static int size(Class<?> cls) {
if (cls.equals(Long.TYPE) || cls.equals(Double.TYPE))
return 2;
else
@@ -1583,7 +1575,7 @@ public class ClassRmicCompiler
/**
* 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++)
{
@@ -1591,7 +1583,7 @@ public class ClassRmicCompiler
{
if (except[i].isAssignableFrom(except[j]))
{
- Class tmp = except[i];
+ Class<?> tmp = except[i];
except[i] = except[j];
except[j] = tmp;
}
@@ -1605,14 +1597,12 @@ public class ClassRmicCompiler
boolean noWrite, boolean verbose, boolean force, String classpath,
String bootclasspath, String extdirs, String outputDirectory)
{
- this.keep = keep;
this.need11Stubs = need11Stubs;
this.need12Stubs = need12Stubs;
this.verbose = verbose;
this.noWrite = noWrite;
// Set up classpath.
- this.classpath = classpath;
StringTokenizer st =
new StringTokenizer(classpath, File.pathSeparator);
URL[] u = new URL[st.countTokens()];
@@ -1638,15 +1628,15 @@ public class ClassRmicCompiler
private void findRemoteMethods()
throws RMICException
{
- List rmeths = new ArrayList();
- for (Class cur = clazz; cur != null; cur = cur.getSuperclass())
+ List<Method> rmeths = new ArrayList<Method>();
+ for (Class<?> cur = clazz; cur != null; cur = cur.getSuperclass())
{
- Class[] interfaces = cur.getInterfaces();
+ Class<?>[] interfaces = cur.getInterfaces();
for (int i = 0; i < interfaces.length; i++)
{
if (java.rmi.Remote.class.isAssignableFrom(interfaces[i]))
{
- Class remoteInterface = interfaces[i];
+ Class<?> remoteInterface = interfaces[i];
if (verbose)
System.out.println
("[implements " + remoteInterface.getName() + "]");
@@ -1684,11 +1674,11 @@ public class ClassRmicCompiler
boolean[] skip = new boolean[rmeths.size()];
for (int i = 0; i < skip.length; i++)
skip[i] = false;
- List methrefs = new ArrayList();
+ List<MethodRef> methrefs = new ArrayList<MethodRef>();
for (int i = 0; i < rmeths.size(); i++)
{
if (skip[i]) continue;
- Method current = (Method) rmeths.get(i);
+ Method current = rmeths.get(i);
MethodRef ref = new MethodRef(current);
for (int j = i+1; j < rmeths.size(); j++)
{
@@ -1703,7 +1693,7 @@ public class ClassRmicCompiler
}
// Convert into a MethodRef array and sort them
- remotemethods = (MethodRef[])
+ remotemethods =
methrefs.toArray(new MethodRef[methrefs.size()]);
Arrays.sort(remotemethods);
}
@@ -1748,7 +1738,7 @@ public class ClassRmicCompiler
{
Method meth;
long hash;
- List exceptions;
+ List<Class<?>> exceptions;
private String sig;
MethodRef(Method m) {
@@ -1784,12 +1774,12 @@ public class ClassRmicCompiler
return true;
}
- private static List removeSubclasses(Class[] classes)
+ private static List<Class<?>> removeSubclasses(Class<?>[] classes)
{
- List list = new ArrayList();
+ List<Class<?>> list = new ArrayList<Class<?>>();
for (int i = 0; i < classes.length; i++)
{
- Class candidate = classes[i];
+ Class<?> candidate = classes[i];
boolean add = true;
for (int j = 0; j < classes.length; j++)
{
@@ -1806,17 +1796,17 @@ public class ClassRmicCompiler
public void intersectExceptions(Method m)
{
- List incoming = removeSubclasses(m.getExceptionTypes());
+ List<Class<?>> incoming = removeSubclasses(m.getExceptionTypes());
- List updated = new ArrayList();
+ List<Class<?>> updated = new ArrayList<Class<?>>();
for (int i = 0; i < exceptions.size(); i++)
{
- Class outer = (Class) exceptions.get(i);
+ Class<?> outer = exceptions.get(i);
boolean addOuter = false;
for (int j = 0; j < incoming.size(); j++)
{
- Class inner = (Class) incoming.get(j);
+ Class<?> inner = incoming.get(j);
if (inner.equals(outer) || inner.isAssignableFrom(outer))
addOuter = true;
diff --git a/libjava/classpath/tools/gnu/classpath/tools/rmic/Main.java b/libjava/classpath/tools/gnu/classpath/tools/rmic/Main.java
index 868fc758ee3..02f72441a17 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/rmic/Main.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/rmic/Main.java
@@ -1,5 +1,5 @@
/* Main.java -- RMI stub generator.
- Copyright (C) 2006 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2012 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -236,7 +236,7 @@ public class Main
System.exit(1);
}
- ArrayList backends = new ArrayList();
+ ArrayList<RmicBackend> backends = new ArrayList<RmicBackend>();
// FIXME: need an IDL RmicBackend
// FIXME: need a ClassGiopRmicCompiler RmicBackend
@@ -262,7 +262,7 @@ public class Main
for (int i = 0; i < backends.size(); i++)
{
- RmicBackend b = (RmicBackend) backends.get(i);
+ RmicBackend b = backends.get(i);
b.setup(keep, need11Stubs, need12Stubs,
iiop, poa, false, warnings,
noWrite, verbose, force, classpath,
diff --git a/libjava/classpath/tools/gnu/classpath/tools/rmic/RmiMethodGenerator.java b/libjava/classpath/tools/gnu/classpath/tools/rmic/RmiMethodGenerator.java
index e02f086efdc..d533f122055 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/rmic/RmiMethodGenerator.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/rmic/RmiMethodGenerator.java
@@ -86,7 +86,7 @@ public class RmiMethodGenerator
{
StringBuilder b = new StringBuilder();
- Class[] args = method.getParameterTypes();
+ Class<?>[] args = method.getParameterTypes();
for (int i = 0; i < args.length; i++)
{
@@ -108,7 +108,7 @@ public class RmiMethodGenerator
{
StringBuilder b = new StringBuilder();
- Class[] args = method.getParameterTypes();
+ Class<?>[] args = method.getParameterTypes();
for (int i = 0; i < args.length; i++)
{
@@ -128,7 +128,7 @@ public class RmiMethodGenerator
{
StringBuilder b = new StringBuilder();
- Class[] args = method.getExceptionTypes();
+ Class<?>[] args = method.getExceptionTypes();
for (int i = 0; i < args.length; i++)
{
@@ -184,7 +184,7 @@ public class RmiMethodGenerator
public String getStaticMethodDeclarations()
{
StringBuilder b = new StringBuilder();
- Class[] args = method.getParameterTypes();
+ Class<?>[] args = method.getParameterTypes();
for (int i = 0; i < args.length; i++)
{
diff --git a/libjava/classpath/tools/gnu/classpath/tools/rmic/SourceGiopRmicCompiler.java b/libjava/classpath/tools/gnu/classpath/tools/rmic/SourceGiopRmicCompiler.java
index dd35c2bd5a0..cf1b0b67925 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/rmic/SourceGiopRmicCompiler.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/rmic/SourceGiopRmicCompiler.java
@@ -1,5 +1,5 @@
/* SourceGiopRmicCompiler -- Central GIOP-based RMI stub and tie compiler class.
- Copyright (C) 2006, 2008 Free Software Foundation
+ Copyright (C) 2006, 2008, 2012 Free Software Foundation
This file is part of GNU Classpath.
@@ -50,7 +50,7 @@ import java.util.TreeSet;
* @author Audrius Meskauskas, Lithuania (audriusa@Bioinformatics.org)
*/
public class SourceGiopRmicCompiler
- extends Generator implements Comparator, RmicBackend
+ extends Generator implements Comparator<AbstractMethodGenerator>, RmicBackend
{
/** The package name. */
protected String packag;
@@ -74,17 +74,18 @@ public class SourceGiopRmicCompiler
/**
* The Remote's, implemented by this class.
*/
- protected Collection implementedRemotes = new HashSet();
+ protected Collection<Class<?>> implementedRemotes = new HashSet<Class<?>>();
/**
* The extra classes that must be imported.
*/
- protected Collection extraImports = new HashSet();
+ protected Collection<String> extraImports = new HashSet<String>();
/**
* The methods we must implement.
*/
- protected Collection methods = new HashSet();
+ protected Collection<AbstractMethodGenerator> methods =
+ new HashSet<AbstractMethodGenerator>();
/**
* The map of all code generator variables.
@@ -228,7 +229,7 @@ public class SourceGiopRmicCompiler
* @param remote
* the class to compile.
*/
- public synchronized void compile(Class remote)
+ public synchronized void compile(Class<?> remote)
{
reset();
String s;
@@ -261,7 +262,7 @@ public class SourceGiopRmicCompiler
+ implName);
// Get the implemented remotes.
- Class[] interfaces = remote.getInterfaces();
+ Class<?>[] interfaces = remote.getInterfaces();
for (int i = 0; i < interfaces.length; i++)
{
@@ -277,11 +278,11 @@ public class SourceGiopRmicCompiler
vars.put("#idList", getIdList(implementedRemotes));
// Collect and process methods.
- Iterator iter = implementedRemotes.iterator();
+ Iterator<Class<?>> iter = implementedRemotes.iterator();
while (iter.hasNext())
{
- Class c = (Class) iter.next();
+ Class<?> c = iter.next();
Method[] m = c.getMethods();
// Check if throws RemoteException.
@@ -374,7 +375,7 @@ public class SourceGiopRmicCompiler
* the interface, for that the repository Id must be created.
* @return the repository id
*/
- public String getId(Class c)
+ public String getId(Class<?> c)
{
return "RMI:" + c.getName() + ":0000000000000000";
}
@@ -386,25 +387,25 @@ public class SourceGiopRmicCompiler
* the collection of interfaces
* @return the fully formatted string array.
*/
- public String getIdList(Collection remotes)
+ public String getIdList(Collection<Class<?>> remotes)
{
StringBuilder b = new StringBuilder();
// Keep the Ids sorted, ensuring, that the same order will be preserved
// between compilations.
- TreeSet sortedIds = new TreeSet();
+ TreeSet<String> sortedIds = new TreeSet<String>();
- Iterator iter = remotes.iterator();
+ Iterator<Class<?>> iter = remotes.iterator();
while (iter.hasNext())
{
- sortedIds.add(getId((Class) iter.next()));
+ sortedIds.add(getId(iter.next()));
}
- iter = sortedIds.iterator();
- while (iter.hasNext())
+ Iterator<String> iterIds = sortedIds.iterator();
+ while (iterIds.hasNext())
{
- b.append(" \"" + iter.next() + "\"");
- if (iter.hasNext())
+ b.append(" \"" + iterIds.next() + "\"");
+ if (iterIds.hasNext())
b.append(", \n");
}
return b.toString();
@@ -421,10 +422,10 @@ public class SourceGiopRmicCompiler
// Generate methods.
StringBuilder b = new StringBuilder();
- Iterator iter = methods.iterator();
+ Iterator<AbstractMethodGenerator> iter = methods.iterator();
while (iter.hasNext())
{
- AbstractMethodGenerator m = (AbstractMethodGenerator) iter.next();
+ AbstractMethodGenerator m = iter.next();
b.append(m.generateStubMethod());
}
@@ -474,7 +475,7 @@ public class SourceGiopRmicCompiler
HashFinder hashFinder = new HashFinder();
// Find the hash character position:
- Iterator iter = methods.iterator();
+ Iterator<AbstractMethodGenerator> iter = methods.iterator();
String[] names = new String[methods.size()];
int p = 0;
@@ -489,7 +490,8 @@ public class SourceGiopRmicCompiler
vars.put("#hashCharPos", Integer.toString(hashCharPosition));
- ArrayList sortedMethods = new ArrayList(methods);
+ ArrayList<AbstractMethodGenerator> sortedMethods =
+ new ArrayList<AbstractMethodGenerator>(methods);
Collections.sort(sortedMethods, this);
iter = sortedMethods.iterator();
@@ -515,10 +517,10 @@ public class SourceGiopRmicCompiler
return output;
}
- public int compare(Object a, Object b)
+ public int compare(AbstractMethodGenerator ag1, AbstractMethodGenerator ag2)
{
- MethodGenerator g1 = (MethodGenerator) a;
- MethodGenerator g2 = (MethodGenerator) b;
+ MethodGenerator g1 = (MethodGenerator) ag1;
+ MethodGenerator g2 = (MethodGenerator) ag2;
return g1.getHashChar() - g2.getHashChar();
}
@@ -530,12 +532,12 @@ public class SourceGiopRmicCompiler
*/
protected String getImportStatements()
{
- TreeSet imp = new TreeSet();
+ TreeSet<String> imp = new TreeSet<String>();
- Iterator it = extraImports.iterator();
+ Iterator<String> it = extraImports.iterator();
while (it.hasNext())
{
- String ic = it.next().toString();
+ String ic = it.next();
imp.add("import " + ic + ";\n");
}
diff --git a/libjava/classpath/tools/gnu/classpath/tools/rmic/Variables.java b/libjava/classpath/tools/gnu/classpath/tools/rmic/Variables.java
index 1fc6a809518..14ba6493ae0 100644
--- a/libjava/classpath/tools/gnu/classpath/tools/rmic/Variables.java
+++ b/libjava/classpath/tools/gnu/classpath/tools/rmic/Variables.java
@@ -1,6 +1,5 @@
/* Variables.java --
- Copyright (c) 2004, 2005
- Free Software Foundation, Inc.
+ Copyright (c) 2004, 2005, 2012 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -44,10 +43,10 @@ import java.util.Iterator;
class Variables
{
- private final HashSet free = new HashSet();
- private final HashMap names = new HashMap();
- private final HashSet wides = new HashSet();
- private final HashSet declared = new HashSet();
+ private final HashSet<Integer> free = new HashSet<Integer>();
+ private final HashMap<Object,Integer> names = new HashMap<Object,Integer>();
+ private final HashSet<Object> wides = new HashSet<Object>();
+ private final HashSet<Object> declared = new HashSet<Object>();
private boolean allocated = false;
public void declare(Object name)
@@ -77,7 +76,7 @@ class Variables
{
// total allocation size is first unallocated slot
int i = free.size() + names.size() + wides.size();
- names.put(name, new Integer(i));
+ names.put(name, Integer.valueOf(i));
if (size == 2) wides.add(name);
return i;
}
@@ -103,10 +102,10 @@ class Variables
if (size == 2)
{
// look for consecutive free slots
- for (Iterator it = free.iterator(); it.hasNext(); )
+ for (Iterator<Integer> it = free.iterator(); it.hasNext(); )
{
- Integer i = (Integer) it.next();
- Integer next = new Integer(i.intValue() + 1);
+ Integer i = it.next();
+ Integer next = Integer.valueOf(i.intValue() + 1);
if (free.contains(next))
{
free.remove(i);
@@ -119,7 +118,7 @@ class Variables
}
else if (free.size() > 0)
{
- Integer i = (Integer) free.iterator().next();
+ Integer i = free.iterator().next();
free.remove(i);
names.put(name, i);
return i.intValue();
@@ -136,11 +135,11 @@ class Variables
if (declared.contains(name))
throw new IllegalStateException(name + " can't be deallocated");
- Integer i = (Integer) names.get(name);
+ Integer i = names.get(name);
names.remove(name);
free.add(i);
if (wides.remove(name))
- free.add(new Integer(i.intValue() + 1));
+ free.add(Integer.valueOf(i.intValue() + 1));
return i.intValue();
}
@@ -149,6 +148,6 @@ class Variables
if (! names.containsKey(name))
throw new IllegalArgumentException("no variable " + name);
- return ((Integer) names.get(name)).intValue();
+ return names.get(name).intValue();
}
}
OpenPOWER on IntegriCloud