propagate from branch 'i2p.i2p' (head d12a1fd746cd9314de5de5e1000c02cf4c59100d)

to branch 'i2p.i2p.str4d.cleanup' (head e20c143dd50a9c802999068a95e12198b07e4c36)
This commit is contained in:
str4d
2013-11-25 22:36:27 +00:00
64 changed files with 161 additions and 219 deletions

View File

@@ -535,11 +535,12 @@ public class I2PAppContext {
*
* @return set of Strings containing the names of defined system properties
*/
public Set<String> getPropertyNames() {
@SuppressWarnings({ "unchecked", "rawtypes" })
public Set<String> getPropertyNames() {
// clone to avoid ConcurrentModificationException
Set names = new HashSet(((Properties) System.getProperties().clone()).keySet());
Set<String> names = new HashSet<String>((Set<String>) (Set) ((Properties) System.getProperties().clone()).keySet()); // TODO-Java6: s/keySet()/stringPropertyNames()/
if (_overrideProps != null)
names.addAll(_overrideProps.keySet());
names.addAll((Set<String>) (Set) _overrideProps.keySet()); // TODO-Java6: s/keySet()/stringPropertyNames()/
return names;
}

View File

@@ -38,8 +38,8 @@ public class MetaNamingService extends DummyNamingService {
_services = new CopyOnWriteArrayList<NamingService>();
while (tok.hasMoreTokens()) {
try {
Class cls = Class.forName(tok.nextToken());
Constructor con = cls.getConstructor(new Class[] { I2PAppContext.class });
Class<?> cls = Class.forName(tok.nextToken());
Constructor<?> con = cls.getConstructor(new Class[] { I2PAppContext.class });
addNamingService((NamingService)con.newInstance(new Object[] { context }), false);
} catch (Exception ex) {
}

View File

@@ -462,8 +462,8 @@ public abstract class NamingService {
NamingService instance = null;
String impl = context.getProperty(PROP_IMPL, DEFAULT_IMPL);
try {
Class cls = Class.forName(impl);
Constructor con = cls.getConstructor(new Class[] { I2PAppContext.class });
Class<?> cls = Class.forName(impl);
Constructor<?> con = cls.getConstructor(new Class[] { I2PAppContext.class });
instance = (NamingService)con.newInstance(new Object[] { context });
} catch (Exception ex) {
Log log = context.logManager().getLog(NamingService.class);

View File

@@ -41,8 +41,8 @@ class ECConstants {
boolean loaded;
if (Security.getProvider("BC") == null) {
try {
Class cls = Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider");
Constructor con = cls.getConstructor(new Class[0]);
Class<?> cls = Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider");
Constructor<?> con = cls.getConstructor(new Class[0]);
Provider bc = (Provider)con.newInstance(new Object[0]);
Security.addProvider(bc);
log("Added BC provider");

View File

@@ -226,7 +226,7 @@ public class DataHelper {
p = props;
}
ByteArrayOutputStream baos = new ByteArrayOutputStream(p.size() * 64);
for (Map.Entry entry : p.entrySet()) {
for (Map.Entry<Object, Object> entry : p.entrySet()) {
String key = (String) entry.getKey();
String val = (String) entry.getValue();
if (utf8)
@@ -273,7 +273,7 @@ public class DataHelper {
OrderedProperties p = new OrderedProperties();
p.putAll(props);
ByteArrayOutputStream baos = new ByteArrayOutputStream(p.size() * 64);
for (Map.Entry entry : p.entrySet()) {
for (Map.Entry<Object, Object> entry : p.entrySet()) {
String key = (String) entry.getKey();
String val = (String) entry.getValue();
writeStringUTF8(baos, key);
@@ -367,7 +367,7 @@ public class DataHelper {
* (unless the options param is an OrderedProperties)
*/
public static String toString(Properties options) {
return toString((Map) options);
return toString((Map<?, ?>) options);
}
/**
@@ -378,7 +378,7 @@ public class DataHelper {
public static String toString(Map<?, ?> options) {
StringBuilder buf = new StringBuilder();
if (options != null) {
for (Map.Entry entry : options.entrySet()) {
for (Map.Entry<?, ?> entry : options.entrySet()) {
String key = (String) entry.getKey();
String val = (String) entry.getValue();
buf.append("[").append(key).append("] = [").append(val).append("]");
@@ -470,7 +470,7 @@ public class DataHelper {
try {
out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new SecureFileOutputStream(file), "UTF-8")));
out.println("# NOTE: This I2P config file must use UTF-8 encoding");
for (Map.Entry entry : props.entrySet()) {
for (Map.Entry<Object, Object> entry : props.entrySet()) {
String name = (String) entry.getKey();
String val = (String) entry.getValue();
if (name.contains("#") ||

View File

@@ -6,7 +6,6 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
@@ -402,8 +401,7 @@ public class PrivateKeyFile {
System.out.println("Attempting to verify using " + sz + " hosts, this may take a while");
}
for (Iterator iter = hosts.entrySet().iterator(); iter.hasNext(); ) {
Map.Entry entry = (Map.Entry)iter.next();
for (Map.Entry<Object, Object> entry : hosts.entrySet()) {
String s = (String) entry.getValue();
Destination signer = new Destination(s);
// make it go faster if we have the signerHash hint

View File

@@ -157,7 +157,7 @@ public class RouterAddress extends DataStructureImpl {
* @return an unmodifiable view, non-null, sorted
* @since 0.8.13
*/
public Map getOptionsMap() {
public Map<Object, Object> getOptionsMap() {
return Collections.unmodifiableMap(_options);
}
@@ -324,7 +324,7 @@ public class RouterAddress extends DataStructureImpl {
buf.append("\n\tCost: ").append(_cost);
//buf.append("\n\tExpiration: ").append(_expiration);
buf.append("\n\tOptions (").append(_options.size()).append("):");
for (Map.Entry e : _options.entrySet()) {
for (Map.Entry<Object, Object> e : _options.entrySet()) {
String key = (String) e.getKey();
String val = (String) e.getValue();
buf.append("\n\t\t[").append(key).append("] = [").append(val).append("]");

View File

@@ -244,7 +244,7 @@ public class RouterInfo extends DatabaseEntry {
* @return an unmodifiable view, non-null, sorted
* @since 0.8.13
*/
public Map getOptionsMap() {
public Map<Object, Object> getOptionsMap() {
return Collections.unmodifiableMap(_options);
}
@@ -626,7 +626,7 @@ public class RouterInfo extends DatabaseEntry {
}
}
buf.append("\n\tOptions (").append(_options.size()).append("):");
for (Map.Entry e : _options.entrySet()) {
for (Map.Entry<Object, Object> e : _options.entrySet()) {
String key = (String) e.getKey();
String val = (String) e.getValue();
buf.append("\n\t\t[").append(key).append("] = [").append(val).append("]");

View File

@@ -225,7 +225,7 @@ public class SessionConfig extends DataStructureImpl {
buf.append("\n\tOptions: #: ").append(_options.size());
Properties sorted = new OrderedProperties();
sorted.putAll(_options);
for (Map.Entry e : sorted.entrySet()) {
for (Map.Entry<Object, Object> e : sorted.entrySet()) {
String key = (String) e.getKey();
String val = (String) e.getValue();
buf.append("\n\t\t[").append(key).append("] = [").append(val).append("]");

View File

@@ -295,7 +295,7 @@ public class FileUtil {
//Pack200.newUnpacker().unpack(in, out);
if (!_failedOracle) {
try {
Class p200 = Class.forName("java.util.jar.Pack200", true, ClassLoader.getSystemClassLoader());
Class<?> p200 = Class.forName("java.util.jar.Pack200", true, ClassLoader.getSystemClassLoader());
Method newUnpacker = p200.getMethod("newUnpacker", (Class[]) null);
Object unpacker = newUnpacker.invoke(null,(Object[]) null);
Method unpack = unpacker.getClass().getMethod("unpack", new Class[] {InputStream.class, JarOutputStream.class});
@@ -316,8 +316,8 @@ public class FileUtil {
//(new Archive(in, out)).unpack();
if (!_failedApache) {
try {
Class p200 = Class.forName("org.apache.harmony.unpack200.Archive", true, ClassLoader.getSystemClassLoader());
Constructor newUnpacker = p200.getConstructor(new Class[] {InputStream.class, JarOutputStream.class});
Class<?> p200 = Class.forName("org.apache.harmony.unpack200.Archive", true, ClassLoader.getSystemClassLoader());
Constructor<?> newUnpacker = p200.getConstructor(new Class[] {InputStream.class, JarOutputStream.class});
Object unpacker = newUnpacker.newInstance(new Object[] {in, out});
Method unpack = unpacker.getClass().getMethod("unpack", (Class[]) null);
// throws IOException or Pack200Exception

View File

@@ -25,7 +25,7 @@ import net.i2p.I2PAppContext;
* @author jrandom
*/
public class Log {
private final Class _class;
private final Class<?> _class;
private final String _className;
private final String _name;
private int _minPriority;
@@ -75,7 +75,7 @@ public class Log {
* Warning - not recommended.
* Use I2PAppContext.getGlobalContext().logManager().getLog(cls)
*/
public Log(Class cls) {
public Log(Class<?> cls) {
this(I2PAppContext.getGlobalContext().logManager(), cls, null);
_manager.addLog(this);
}
@@ -89,7 +89,7 @@ public class Log {
_manager.addLog(this);
}
Log(LogManager manager, Class cls) {
Log(LogManager manager, Class<?> cls) {
this(manager, cls, null);
}
@@ -97,7 +97,7 @@ public class Log {
this(manager, null, name);
}
Log(LogManager manager, Class cls, String name) {
Log(LogManager manager, Class<?> cls, String name) {
_manager = manager;
_class = cls;
_className = cls != null ? cls.getName() : null;
@@ -229,7 +229,7 @@ public class Log {
/** @return the LogScope (private class) */
public Object getScope() { return _scope; }
static String getScope(String name, Class cls) {
static String getScope(String name, Class<?> cls) {
if ( (name == null) && (cls == null) ) return "f00";
if (cls == null) return name;
if (name == null) return cls.getName();
@@ -239,7 +239,7 @@ public class Log {
private static final class LogScope {
private final String _scopeCache;
public LogScope(String name, Class cls) {
public LogScope(String name, Class<?> cls) {
_scopeCache = getScope(name, cls);
}

View File

@@ -166,9 +166,9 @@ public class LogManager {
t.start();
}
public Log getLog(Class cls) { return getLog(cls, null); }
public Log getLog(Class<?> cls) { return getLog(cls, null); }
public Log getLog(String name) { return getLog(null, name); }
public Log getLog(Class cls, String name) {
public Log getLog(Class<?> cls, String name) {
String scope = Log.getScope(name, cls);
boolean isNew = false;
Log rv = _logs.get(scope);
@@ -186,7 +186,7 @@ public class LogManager {
/** now used by ConfigLogingHelper */
public List<Log> getLogs() {
return new ArrayList(_logs.values());
return new ArrayList<Log>(_logs.values());
}
/**
@@ -407,7 +407,7 @@ public class LogManager {
private void parseLimits(Properties config, String recordPrefix) {
_limits.clear();
if (config != null) {
for (Map.Entry e : config.entrySet()) {
for (Map.Entry<Object, Object> e : config.entrySet()) {
String key = (String) e.getKey();
// if we're filtering the records (e.g. logger.record.*) then

View File

@@ -15,14 +15,14 @@ package net.i2p.util;
*/
class LogRecord {
private final long _date;
private final Class _source;
private final Class<?> _source;
private final String _name;
private final String _threadName;
private final int _priority;
private final String _message;
private final Throwable _throwable;
public LogRecord(Class src, String name, String threadName, int priority, String msg, Throwable t) {
public LogRecord(Class<?> src, String name, String threadName, int priority, String msg, Throwable t) {
_date = Clock.getInstance().now();
_source = src;
_name = name;
@@ -36,7 +36,7 @@ class LogRecord {
return _date;
}
public Class getSource() {
public Class<?> getSource() {
return _source;
}

View File

@@ -35,19 +35,19 @@ public class OrderedProperties extends Properties {
}
@Override
public Set keySet() {
return Collections.unmodifiableSortedSet(new TreeSet(super.keySet()));
public Set<Object> keySet() {
return Collections.unmodifiableSortedSet(new TreeSet<Object>(super.keySet()));
}
@Override
public Set<Map.Entry<Object, Object>> entrySet() {
TreeSet<Map.Entry<Object, Object>> rv = new TreeSet(new EntryComparator());
TreeSet<Map.Entry<Object, Object>> rv = new TreeSet<Map.Entry<Object, Object>>(new EntryComparator());
rv.addAll(super.entrySet());
return Collections.unmodifiableSortedSet(rv);
}
private static class EntryComparator implements Comparator<Map.Entry> {
public int compare(Map.Entry l, Map.Entry r) {
private static class EntryComparator implements Comparator<Map.Entry<Object, Object>> {
public int compare(Map.Entry<Object, Object> l, Map.Entry<Object, Object> r) {
return ((String)l.getKey()).compareTo(((String)r.getKey()));
}
}

View File

@@ -47,7 +47,7 @@ public abstract class SystemVersion {
int sdk = 0;
if (_isAndroid) {
try {
Class ver = Class.forName("android.os.Build.VERSION", true, ClassLoader.getSystemClassLoader());
Class<?> ver = Class.forName("android.os.Build.VERSION", true, ClassLoader.getSystemClassLoader());
Field field = ver.getField("SDK_INT");
sdk = field.getInt(null);
} catch (Exception e) {}

View File

@@ -11,6 +11,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Properties;
import java.util.Set;
import net.i2p.I2PAppContext;
import net.i2p.data.DataHelper;
@@ -22,7 +23,8 @@ public class BlockfileNamingServiceTest extends TestCase {
List<String> _names;
File hostsTxt, routerDir;
public void setUp() throws Exception {
@SuppressWarnings({ "unchecked", "rawtypes" })
public void setUp() throws Exception {
I2PAppContext ctx = new I2PAppContext();
routerDir = ctx.getRouterDir();
@@ -31,7 +33,7 @@ public class BlockfileNamingServiceTest extends TestCase {
Properties props = new Properties();
assertNotNull("test classpath not set correctly",is);
DataHelper.loadProps(props, is, true);
_names = new ArrayList(props.keySet());
_names = new ArrayList<String>((Set<String>) (Set) props.keySet()); // TODO-Java6: s/keySet()/stringPropertyNames()/
Collections.shuffle(_names);
is.close();