From: <pj...@us...> - 2009-05-30 06:03:09
|
Revision: 6425 http://jython.svn.sourceforge.net/jython/?rev=6425&view=rev Author: pjenvey Date: 2009-05-30 06:00:25 +0000 (Sat, 30 May 2009) Log Message: ----------- quiet some warnings and remove a couple unused things Modified Paths: -------------- trunk/jython/src/org/python/core/JavaImportHelper.java trunk/jython/src/org/python/core/Py.java trunk/jython/src/org/python/core/PyArray.java trunk/jython/src/org/python/core/ReflectedArgs.java trunk/jython/src/org/python/core/codecs.java Modified: trunk/jython/src/org/python/core/JavaImportHelper.java =================================================================== --- trunk/jython/src/org/python/core/JavaImportHelper.java 2009-05-30 02:08:23 UTC (rev 6424) +++ trunk/jython/src/org/python/core/JavaImportHelper.java 2009-05-30 06:00:25 UTC (rev 6425) @@ -36,10 +36,8 @@ // check explicit imports first (performance optimization) // handle 'from java.net import URL' like explicit imports - List stringFromlist = getFromListAsStrings(fromlist); - Iterator fromlistIterator = stringFromlist.iterator(); - while (fromlistIterator.hasNext()) { - String fromName = (String) fromlistIterator.next(); + List<String> stringFromlist = getFromListAsStrings(fromlist); + for (String fromName : stringFromlist) { if (isJavaClass(packageName, fromName)) { packageAdded = addPackage(packageName, packageAdded); @@ -59,7 +57,7 @@ // if all else fails, check already loaded packages if (!packageAdded) { // build the actual map with the packages known to the VM - Map packages = buildLoadedPackages(); + Map<String, String> packages = buildLoadedPackages(); // add known packages String parentPackageName = packageName; @@ -78,9 +76,7 @@ } while (dotPos > 0); // handle package imports like 'from java import math' - fromlistIterator = stringFromlist.iterator(); - while (fromlistIterator.hasNext()) { - String fromName = (String) fromlistIterator.next(); + for (String fromName : stringFromlist) { String fromPackageName = packageName + DOT + fromName; if (isLoadedPackage(fromPackageName, packages)) { packageAdded = addPackage(fromPackageName, packageAdded); @@ -113,8 +109,8 @@ * @param fromlist * @return a list containing java.lang.String entries */ - private static final List getFromListAsStrings(PyObject fromlist) { - List stringFromlist = new ArrayList(); + private static final List<String> getFromListAsStrings(PyObject fromlist) { + List<String> stringFromlist = new ArrayList<String>(); if (fromlist != null && fromlist != Py.EmptyTuple && fromlist instanceof PyTuple) { Iterator iterator = ((PyTuple) fromlist).iterator(); @@ -146,7 +142,7 @@ * @return <code>true</code> if the package with the given name is already loaded by the VM, <code>false</code> * otherwise. */ - private static boolean isLoadedPackage(String javaPackageName, Map packages) { + private static boolean isLoadedPackage(String javaPackageName, Map<String, String> packages) { boolean isLoaded = false; if (javaPackageName != null) { isLoaded = packages.containsKey(javaPackageName); @@ -160,8 +156,8 @@ * All parent packages appear as single entries like python modules, e.g. <code>java</code>, * <code>java.lang</code>, <code>java.lang.reflect</code>, */ - private static Map buildLoadedPackages() { - TreeMap packageMap = new TreeMap(); + private static Map<String, String> buildLoadedPackages() { + TreeMap<String, String> packageMap = new TreeMap<String, String>(); Package[] packages = Package.getPackages(); for (int i = 0; i < packages.length; i++) { String packageName = packages[i].getName(); Modified: trunk/jython/src/org/python/core/Py.java =================================================================== --- trunk/jython/src/org/python/core/Py.java 2009-05-30 02:08:23 UTC (rev 6424) +++ trunk/jython/src/org/python/core/Py.java 2009-05-30 06:00:25 UTC (rev 6425) @@ -13,6 +13,7 @@ import java.io.Serializable; import java.io.StreamCorruptedException; import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.sql.Date; import java.sql.Time; import java.sql.Timestamp; @@ -23,7 +24,6 @@ import com.kenai.constantine.platform.Errno; import java.util.ArrayList; import java.util.List; -import org.python.compiler.Module; import org.python.core.adapter.ClassicPyObjectAdapter; import org.python.core.adapter.ExtensiblePyObjectAdapter; import org.python.util.Generic; @@ -481,7 +481,7 @@ // ??pending: was @deprecated but is actually used by proxie code. // Can get rid of it? public static Object tojava(PyObject o, String s) { - Class c = findClass(s); + Class<?> c = findClass(s); if (c == null) { throw Py.TypeError("can't convert to: " + s); } @@ -663,15 +663,13 @@ funcs, func_id); } - public static PyCode newJavaCode(Class cls, String name) { + public static PyCode newJavaCode(Class<?> cls, String name) { return new JavaCode(newJavaFunc(cls, name)); } - public static PyObject newJavaFunc(Class cls, String name) { + public static PyObject newJavaFunc(Class<?> cls, String name) { try { - java.lang.reflect.Method m = cls.getMethod(name, new Class[]{ - PyObject[].class, String[].class - }); + Method m = cls.getMethod(name, new Class<?>[]{PyObject[].class, String[].class}); return new JavaFunc(m); } catch (NoSuchMethodException e) { throw Py.JavaError(e); @@ -1510,10 +1508,6 @@ */ private static ExtensiblePyObjectAdapter adapter; - private static Class[] pyClassCtrSignature = { - String.class, PyTuple.class, PyObject.class, Class.class - }; - // XXX: The following two makeClass overrides are *only* for the // old compiler, they should be removed when the newcompiler hits public static PyObject makeClass(String name, PyObject[] bases, @@ -1939,6 +1933,7 @@ } } + @Override protected PyObject myFile() { return file; } @@ -1958,6 +1953,7 @@ } } + @Override public PyObject call(ThreadState state, PyFrame frame, PyObject closure) { //XXX: what the heck is this? Looks like debug code, but it's // been here a long time... @@ -1965,39 +1961,46 @@ return Py.None; } + @Override public PyObject call(ThreadState state, PyObject args[], String keywords[], PyObject globals, PyObject[] defaults, PyObject closure) { return func.__call__(args, keywords); } + @Override public PyObject call(ThreadState state, PyObject self, PyObject args[], String keywords[], PyObject globals, PyObject[] defaults, PyObject closure) { return func.__call__(self, args, keywords); } + @Override public PyObject call(ThreadState state, PyObject globals, PyObject[] defaults, PyObject closure) { return func.__call__(); } + @Override public PyObject call(ThreadState state, PyObject arg1, PyObject globals, PyObject[] defaults, PyObject closure) { return func.__call__(arg1); } + @Override public PyObject call(ThreadState state, PyObject arg1, PyObject arg2, PyObject globals, PyObject[] defaults, PyObject closure) { return func.__call__(arg1, arg2); } + @Override public PyObject call(ThreadState state, PyObject arg1, PyObject arg2, PyObject arg3, PyObject globals, PyObject[] defaults, PyObject closure) { return func.__call__(arg1, arg2, arg3); } + @Override public PyObject call(ThreadState state, PyObject arg1, PyObject arg2, PyObject arg3, PyObject arg4, PyObject globals, PyObject[] defaults, PyObject closure) { @@ -2011,12 +2014,13 @@ */ class JavaFunc extends PyObject { - java.lang.reflect.Method method; + Method method; - public JavaFunc(java.lang.reflect.Method method) { + public JavaFunc(Method method) { this.method = method; } + @Override public PyObject __call__(PyObject[] args, String[] kws) { Object[] margs = new Object[]{args, kws}; try { @@ -2026,10 +2030,12 @@ } } + @Override public PyObject _doget(PyObject container) { return _doget(container, null); } + @Override public PyObject _doget(PyObject container, PyObject wherefound) { if (container == null) { return this; Modified: trunk/jython/src/org/python/core/PyArray.java =================================================================== --- trunk/jython/src/org/python/core/PyArray.java 2009-05-30 02:08:23 UTC (rev 6424) +++ trunk/jython/src/org/python/core/PyArray.java 2009-05-30 06:00:25 UTC (rev 6425) @@ -36,7 +36,7 @@ private Object data; /** The Java array class. */ - private Class type; + private Class<?> type; /** The Python style typecode of the array. */ private String typecode; @@ -47,12 +47,12 @@ super(type); } - public PyArray(Class type, Object data) { + public PyArray(Class<?> type, Object data) { this(TYPE); setup(type, data); } - public PyArray(Class type, int n) { + public PyArray(Class<?> type, int n) { this(type, Array.newInstance(type, n)); } @@ -61,7 +61,7 @@ typecode = toCopy.typecode; } - private void setup(Class type, Object data) { + private void setup(Class<?> type, Object data) { this.type = type; typecode = class2char(type); if (data == null) { @@ -87,7 +87,7 @@ PyObject obj = ap.getPyObject(0); PyObject initial = ap.getPyObject(1, null); - Class type; + Class<?> type; String typecode; if (obj instanceof PyString && !(obj instanceof PyUnicode)) { if (obj.__len__() != 1) { @@ -138,7 +138,7 @@ return array; } - public static PyArray zeros(int n, Class ctype) { + public static PyArray zeros(int n, Class<?> ctype) { PyArray array = new PyArray(ctype, n); array.typecode = ctype.getName(); return array; @@ -161,7 +161,7 @@ * <code>Class</code> type of the elements stored in the array. * @return a new PyArray */ - public static PyArray array(PyObject init, Class ctype) { + public static PyArray array(PyObject init, Class<?> ctype) { PyArray array = new PyArray(ctype, 0); array.typecode = ctype.getName(); array.extendInternal(init); @@ -248,6 +248,7 @@ seq___delslice__(start, stop, step); } + @Override public PyObject __imul__(PyObject o) { return array___imul__(o); } @@ -272,6 +273,7 @@ return this; } + @Override public PyObject __mul__(PyObject o) { return array___mul__(o); } @@ -284,6 +286,7 @@ return repeat(o.asIndex(Py.OverflowError)); } + @Override public PyObject __rmul__(PyObject o) { return array___rmul__(o); } @@ -296,6 +299,7 @@ return repeat(o.asIndex(Py.OverflowError)); } + @Override public PyObject __iadd__(PyObject other) { return array___iadd__(other); } @@ -316,6 +320,7 @@ return this; } + @Override public PyObject __add__(PyObject other) { return array___add__(other); } @@ -348,6 +353,7 @@ * * @return number of elements in the array */ + @Override public int __len__() { return array___len__(); } @@ -357,6 +363,7 @@ return delegate.getSize(); } + @Override public PyObject __reduce__() { return array___reduce__(); } @@ -402,7 +409,8 @@ * target <em>Class</em> for the conversion * @return Java object converted to required class type if possible. */ - public Object __tojava__(Class c) { + @Override + public Object __tojava__(Class<?> c) { if(c == Object.class || (c.isArray() && c.getComponentType().isAssignableFrom(type))) { return data; @@ -502,6 +510,7 @@ * * @return copy of current PyArray */ + @Override public Object clone() { return new PyArray(this); } @@ -558,7 +567,7 @@ */ // promote B, H, I (unsigned int) to next larger size - public static Class char2class(char type) throws PyIgnoreMethodTag { + public static Class<?> char2class(char type) throws PyIgnoreMethodTag { switch(type){ case 'z': return Boolean.TYPE; @@ -591,40 +600,7 @@ } } - private static Class char2storageClass(char type) throws PyIgnoreMethodTag { - switch(type){ - case 'z': - return Boolean.TYPE; - case 'b': - return Byte.TYPE; - case 'B': - return Byte.TYPE; - case 'u': - return Integer.TYPE; - case 'c': - return Character.TYPE; - case 'h': - return Short.TYPE; - case 'H': - return Short.TYPE; - case 'i': - return Integer.TYPE; - case 'I': - return Integer.TYPE; - case 'l': - return Long.TYPE; - case 'L': - return Long.TYPE; - case 'f': - return Float.TYPE; - case 'd': - return Double.TYPE; - default: - throw Py.ValueError("bad typecode (must be c, b, B, u, h, H, i, I, l, L, f or d)"); - } - } - - private static String class2char(Class cls) { + private static String class2char(Class<?> cls) { if(cls.equals(Boolean.TYPE)) return "z"; else if(cls.equals(Character.TYPE)) @@ -684,6 +660,7 @@ * @param i * index of the item to be deleted from the array */ + @Override protected void del(int i) { // Now the AbstractArray can support this: // throw Py.TypeError("can't remove from array"); @@ -698,6 +675,7 @@ * @param stop * finishing index of slice */ + @Override protected void delRange(int start, int stop) { delegate.remove(start, stop); } @@ -1054,6 +1032,7 @@ * @param i * index of the item to be retrieved from the array */ + @Override protected PyObject pyget(int i) { if ("u".equals(typecode)) { return new PyUnicode(Array.getInt(data, i)); @@ -1199,6 +1178,7 @@ * stepping increment of the slice * @return A new PyArray object containing the described slice */ + @Override protected PyObject getslice(int start, int stop, int step) { if (step > 0 && stop < start) { stop = start; @@ -1376,6 +1356,7 @@ * @return A new PyArray object containing the source object repeated * <em>count</em> times. */ + @Override protected PyObject repeat(int count) { Object arraycopy = delegate.copyArray(); PyArray ret = new PyArray(type, 0); @@ -1425,6 +1406,7 @@ pyset(i, value); } + @Override protected void pyset(int i, PyObject value) { if ("u".equals(typecode)) { Array.setInt(data, i, getCodePoint(value)); @@ -1528,6 +1510,7 @@ * @param step * stepping increment of the slice */ + @Override protected void setslice(int start, int stop, int step, PyObject value) { if (stop < start) { stop = start; @@ -1819,17 +1802,19 @@ super(data == null ? 0 : Array.getLength(data)); } + @Override protected Object getArray() { return data; } + @Override protected void setArray(Object array) { data = array; } @Override protected Object createArray(int size) { - Class baseType = data.getClass().getComponentType(); + Class<?> baseType = data.getClass().getComponentType(); return Array.newInstance(baseType, size); } } Modified: trunk/jython/src/org/python/core/ReflectedArgs.java =================================================================== --- trunk/jython/src/org/python/core/ReflectedArgs.java 2009-05-30 02:08:23 UTC (rev 6424) +++ trunk/jython/src/org/python/core/ReflectedArgs.java 2009-05-30 06:00:25 UTC (rev 6425) @@ -2,11 +2,11 @@ package org.python.core; public class ReflectedArgs { - public Class[] args; + public Class<?>[] args; public Object data; - public Class declaringClass; + public Class<?> declaringClass; public boolean isStatic; @@ -18,8 +18,7 @@ public static final int PyArgsKeywordsCall = 2; - public ReflectedArgs(Object data, Class[] args, Class declaringClass, - boolean isStatic) { + public ReflectedArgs(Object data, Class<?>[] args, Class<?> declaringClass, boolean isStatic) { this.data = data; this.args = args; this.declaringClass = declaringClass; @@ -129,7 +128,7 @@ return true; } - public static int precedence(Class arg) { + public static int precedence(Class<?> arg) { if (arg == Object.class) { return 3000; } @@ -166,7 +165,7 @@ } if (arg.isArray()) { - Class componentType = arg.getComponentType(); + Class<?> componentType = arg.getComponentType(); if (componentType == Object.class) { return 2500; } @@ -180,7 +179,7 @@ * unimportantly different Returns +/-2 iff arg1 and arg2 are significantly * different */ - public static int compare(Class arg1, Class arg2) { + public static int compare(Class<?> arg1, Class<?> arg2) { int p1 = precedence(arg1); int p2 = precedence(arg2); // Special code if they are both nonprimitives @@ -207,7 +206,7 @@ public static final int REPLACE = 1998; public int compareTo(ReflectedArgs other) { - Class[] oargs = other.args; + Class<?>[] oargs = other.args; // First decision based on flags if (other.flags != this.flags) { @@ -258,6 +257,7 @@ return replace ? REPLACE : 0; } + @Override public String toString() { String s = declaringClass + ", " + isStatic + ", " + flags + ", " + data + "\n"; s = s + "\t("; Modified: trunk/jython/src/org/python/core/codecs.java =================================================================== --- trunk/jython/src/org/python/core/codecs.java 2009-05-30 02:08:23 UTC (rev 6424) +++ trunk/jython/src/org/python/core/codecs.java 2009-05-30 06:00:25 UTC (rev 6425) @@ -1116,7 +1116,7 @@ int input_size = input.length(); int output_size = 0; - ArrayList<Integer> ucs4 = new ArrayList(input_size); + ArrayList<Integer> ucs4 = new ArrayList<Integer>(input_size); int j = 0; for (; j < input_size; j++) { int c = input.charAt(j); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |