From 0a893e1de1335a59834b7e13ce9a16e61d98e2e3 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Tue, 22 Jul 2008 14:36:54 +0000 Subject: [PATCH] ZOMG, Narya now perfectly passes our coding standards as enforced by CheckStyle. The checks are slightly looser than I'd like but way better than nothing and we get a bunch of other useful warnings like shadowed names and other handy bits. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5253 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../presents/net/BootstrapData.java | 7 +- .../presents/server/ClientResolver.java | 5 +- .../presents/server/InvocationManager.java | 22 +++--- .../presents/server/PresentsClient.java | 22 +++--- .../presents/server/PresentsDObjectMgr.java | 46 ++++++++---- .../presents/server/ShutdownManager.java | 2 +- .../server/net/ConnectionManager.java | 20 ++--- .../presents/tools/ActionScriptSource.java | 16 ++-- .../tools/GenActionScriptBundlesTask.java | 1 - .../presents/tools/GenActionScriptTask.java | 2 +- .../presents/tools/GenDObjectTask.java | 2 +- .../presents/tools/GenServiceTask.java | 6 ++ .../presents/tools/GenStreamableTask.java | 2 +- .../threerings/presents/tools/ImportSet.java | 75 +++++++++---------- .../tools/InstrumentStreamableTask.java | 4 +- .../presents/tools/InvocationTask.java | 2 +- .../threerings/presents/util/ClassUtil.java | 6 +- .../presents/util/IgnoreConfirmAdapter.java | 2 + .../presents/util/PersistingUnit.java | 2 +- .../presents/util/ResultAdapter.java | 2 + .../presents/util/SafeSubscriber.java | 2 + .../com/threerings/util/DependencyGraph.java | 2 +- .../com/threerings/util/MessageBundle.java | 5 +- .../com/threerings/util/MessageManager.java | 3 +- src/java/com/threerings/util/RandomUtil.java | 2 +- .../threerings/util/StreamableArrayList.java | 1 + .../threerings/util/StreamableEnumSet.java | 1 + .../threerings/util/StreamableHashIntMap.java | 1 + .../threerings/util/StreamableHashMap.java | 6 +- .../threerings/util/StreamableHashSet.java | 1 + .../com/threerings/util/StreamablePoint.java | 3 + .../com/threerings/util/StreamableTuple.java | 2 + .../com/threerings/util/TrackedObject.java | 8 +- 33 files changed, 159 insertions(+), 124 deletions(-) diff --git a/src/java/com/threerings/presents/net/BootstrapData.java b/src/java/com/threerings/presents/net/BootstrapData.java index 56ab8b57a..1610622a4 100644 --- a/src/java/com/threerings/presents/net/BootstrapData.java +++ b/src/java/com/threerings/presents/net/BootstrapData.java @@ -27,10 +27,9 @@ import com.threerings.util.StreamableArrayList; import com.threerings.presents.data.InvocationMarshaller; /** - * A BootstrapData object is communicated back to the client - * after authentication has succeeded and after the server is fully - * prepared to deal with the client. It contains information the client - * will need to interact with the server. + * A BootstrapData object is communicated back to the client after authentication has + * succeeded and after the server is fully prepared to deal with the client. It contains + * information the client will need to interact with the server. */ public class BootstrapData extends SimpleStreamableObject { diff --git a/src/java/com/threerings/presents/server/ClientResolver.java b/src/java/com/threerings/presents/server/ClientResolver.java index 182e17559..f6e6fa486 100644 --- a/src/java/com/threerings/presents/server/ClientResolver.java +++ b/src/java/com/threerings/presents/server/ClientResolver.java @@ -193,6 +193,7 @@ public class ClientResolver extends Invoker.Unit /** A place to keep an exception around for a moment. */ protected Exception _failure; - @Inject @MainInvoker Invoker _invoker; - @Inject RootDObjectManager _omgr; + // dependencies + protected @Inject @MainInvoker Invoker _invoker; + protected @Inject RootDObjectManager _omgr; } diff --git a/src/java/com/threerings/presents/server/InvocationManager.java b/src/java/com/threerings/presents/server/InvocationManager.java index c5521d911..3de6b874d 100644 --- a/src/java/com/threerings/presents/server/InvocationManager.java +++ b/src/java/com/threerings/presents/server/InvocationManager.java @@ -21,8 +21,10 @@ package com.threerings.presents.server; +import java.util.List; import java.util.Map; +import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.inject.Inject; import com.google.inject.Singleton; @@ -33,7 +35,6 @@ import com.samskivert.util.LRUHashMap; import com.samskivert.util.StringUtil; import com.threerings.io.Streamable; -import com.threerings.util.StreamableArrayList; import com.threerings.presents.data.ClientObject; import com.threerings.presents.data.InvocationMarshaller.ListenerMarshaller; @@ -100,7 +101,8 @@ public class InvocationManager * * @param dispatcher the dispatcher to be registered. */ - public T registerDispatcher (InvocationDispatcher dispatcher) + public T registerDispatcher ( + InvocationDispatcher dispatcher) { return registerDispatcher(dispatcher, null); } @@ -139,9 +141,9 @@ public class InvocationManager // if it's a bootstrap service, slap it in the list if (group != null) { - StreamableArrayList list = _bootlists.get(group); + List list = _bootlists.get(group); if (list == null) { - _bootlists.put(group, list = new StreamableArrayList()); + _bootlists.put(group, list = Lists.newArrayList()); } list.add(marsh); } @@ -175,12 +177,11 @@ public class InvocationManager /** * Constructs a list of all bootstrap services registered in any of the supplied groups. */ - public StreamableArrayList getBootstrapServices (String[] bootGroups) + public List getBootstrapServices (String[] bootGroups) { - StreamableArrayList services = - new StreamableArrayList(); + List services = Lists.newArrayList(); for (String group : bootGroups) { - StreamableArrayList list = _bootlists.get(group); + List list = _bootlists.get(group); if (list != null) { services.addAll(list); } @@ -319,10 +320,11 @@ public class InvocationManager protected IntMap _dispatchers = IntMaps.newHashIntMap(); /** Maps bootstrap group to lists of services to be provided to clients at boot time. */ - protected Map> _bootlists = Maps.newHashMap(); + protected Map> _bootlists = Maps.newHashMap(); // debugging action... - protected final Map _recentRegServices = new LRUHashMap(10000); + protected final Map _recentRegServices = + new LRUHashMap(10000); /** The text appended to the procedure name when generating a failure response. */ protected static final String FAILED_SUFFIX = "Failed"; diff --git a/src/java/com/threerings/presents/server/PresentsClient.java b/src/java/com/threerings/presents/server/PresentsClient.java index 5e4933550..889a7f154 100644 --- a/src/java/com/threerings/presents/server/PresentsClient.java +++ b/src/java/com/threerings/presents/server/PresentsClient.java @@ -538,7 +538,7 @@ public class PresentsClient */ protected void handleThrottleExceeded () { - log.warning("Client sent more than 100 messages in 10 seconds, disconnecting " + this + "."); + log.warning("Client sent more than 100 msgs in 10 seconds, disconnecting " + this + "."); safeEndSession(); _throttle = null; } @@ -676,11 +676,11 @@ public class PresentsClient data.clientOid = _clobj.getOid(); // fill in the list of bootstrap services + data.services = new StreamableArrayList(); if (_areq.getBootGroups() == null) { log.warning("Client provided no invocation service boot groups? " + this); - data.services = new StreamableArrayList(); } else { - data.services = _invmgr.getBootstrapServices(_areq.getBootGroups()); + data.services.addAll(_invmgr.getBootstrapServices(_areq.getBootGroups())); } } @@ -847,20 +847,20 @@ public class PresentsClient } // from interface ProxySubscriber - public void objectAvailable (DObject object) + public void objectAvailable (DObject dobj) { - if (postMessage(new ObjectResponse(object))) { + if (postMessage(new ObjectResponse(dobj))) { _firstEventId = _omgr.getNextEventId(false); - this.object = object; + object = dobj; synchronized (_subscrips) { // make a note of this new subscription - _subscrips.put(object.getOid(), this); + _subscrips.put(dobj.getOid(), this); } - subscribedToObject(object); + subscribedToObject(dobj); } else { // if we failed to send the object response, unsubscribe - object.removeSubscriber(this); + dobj.removeSubscriber(this); } } @@ -903,7 +903,7 @@ public class PresentsClient /** * Dispatch the supplied message for the specified client. */ - public void dispatch (PresentsClient client, UpstreamMessage mge); + void dispatch (PresentsClient client, UpstreamMessage mge); } /** @@ -1025,7 +1025,7 @@ public class PresentsClient protected int _messagesDropped; /** A mapping of message dispatchers. */ - protected static Map,MessageDispatcher> _disps = Maps.newHashMap(); + protected static Map, MessageDispatcher> _disps = Maps.newHashMap(); /** The amount of time after disconnection a user is allowed before their session is forcibly * ended. */ diff --git a/src/java/com/threerings/presents/server/PresentsDObjectMgr.java b/src/java/com/threerings/presents/server/PresentsDObjectMgr.java index 26cdd6206..90234c689 100644 --- a/src/java/com/threerings/presents/server/PresentsDObjectMgr.java +++ b/src/java/com/threerings/presents/server/PresentsDObjectMgr.java @@ -21,7 +21,9 @@ package com.threerings.presents.server; -import java.lang.reflect.*; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; import java.util.List; import java.util.Map; @@ -39,7 +41,20 @@ import com.samskivert.util.RunQueue; import com.samskivert.util.StringUtil; import com.samskivert.util.Throttle; -import com.threerings.presents.dobj.*; +import com.threerings.presents.dobj.AccessController; +import com.threerings.presents.dobj.CompoundEvent; +import com.threerings.presents.dobj.DEvent; +import com.threerings.presents.dobj.DObject; +import com.threerings.presents.dobj.DObjectManager; +import com.threerings.presents.dobj.InvocationRequestEvent; +import com.threerings.presents.dobj.NoSuchObjectException; +import com.threerings.presents.dobj.ObjectAccessException; +import com.threerings.presents.dobj.ObjectAddedEvent; +import com.threerings.presents.dobj.ObjectDestroyedEvent; +import com.threerings.presents.dobj.ObjectRemovedEvent; +import com.threerings.presents.dobj.OidList; +import com.threerings.presents.dobj.RootDObjectManager; +import com.threerings.presents.dobj.Subscriber; import static com.threerings.presents.Log.log; @@ -338,7 +353,7 @@ public class PresentsDObjectMgr */ public void dumpUnitProfiles () { - for (Map.Entry entry : _profiles.entrySet()) { + for (Map.Entry entry : _profiles.entrySet()) { log.info("P: " + entry.getKey() + " => " + entry.getValue()); } } @@ -534,7 +549,7 @@ public class PresentsDObjectMgr if (UNIT_PROF_ENABLED) { report.append("- Unit profiles: ").append(_profiles.size()).append("\n"); - for (Map.Entry entry : _profiles.entrySet()) { + for (Map.Entry entry : _profiles.entrySet()) { report.append(" ").append(entry.getKey()); report.append(" ").append(entry.getValue()).append("\n"); } @@ -910,15 +925,13 @@ public class PresentsDObjectMgr public String field; public int reffedOid; - public Reference (int reffingOid, String field, int reffedOid) - { + public Reference (int reffingOid, String field, int reffedOid) { this.reffingOid = reffingOid; this.field = field; this.reffedOid = reffedOid; } - public boolean equals (Reference other) - { + public boolean equals (Reference other) { if (other == null) { return false; } else { @@ -926,14 +939,15 @@ public class PresentsDObjectMgr } } - public boolean equals (int reffingOid, String field) - { - return (this.reffingOid == reffingOid && this.field.equals(field)); + public boolean equals (int oReffingOid, String oField) { + return (reffingOid == oReffingOid && field.equals(oField)); } - @Override - public String toString () - { + @Override public int hashCode () { + return reffingOid ^ field.hashCode(); + } + + @Override public String toString () { return "[reffingOid=" + reffingOid + ", field=" + field + ", reffedOid=" + reffedOid + "]"; } @@ -1010,13 +1024,13 @@ public class PresentsDObjectMgr protected long _nextEventId = 1; /** Used to profile our events and runnable units. */ - protected Map _profiles = Maps.newHashMap(); + protected Map _profiles = Maps.newHashMap(); /** Used to track runtime statistics. */ protected Stats _recent = new Stats(), _current = _recent; /** Maps event classes to helpers that perform additional processing for particular events. */ - protected Map _helpers = Maps.newHashMap(); + protected Map _helpers = Maps.newHashMap(); /** Used to resolve unit names when profiling. Injected by the invmgr when it's created. */ protected InvocationManager _invmgr; diff --git a/src/java/com/threerings/presents/server/ShutdownManager.java b/src/java/com/threerings/presents/server/ShutdownManager.java index e5c95ddd7..832c59a6c 100644 --- a/src/java/com/threerings/presents/server/ShutdownManager.java +++ b/src/java/com/threerings/presents/server/ShutdownManager.java @@ -48,6 +48,7 @@ public class ShutdownManager void shutdown (); } + /** Constraints for use with {@link #addConstraint}. */ public static enum Constraint { RUNS_BEFORE, RUNS_AFTER }; @Inject ShutdownManager (@EventQueue RunQueue dobjq) @@ -75,7 +76,6 @@ public class ShutdownManager * Adds a constraint that a certain shutdowner must be run before another. */ public void addConstraint (Shutdowner lhs, Constraint constraint, Shutdowner rhs) - throws IllegalArgumentException { if (lhs == null || rhs == null) { throw new IllegalArgumentException("Cannot add constraint about null shutdowner."); diff --git a/src/java/com/threerings/presents/server/net/ConnectionManager.java b/src/java/com/threerings/presents/server/net/ConnectionManager.java index 98c43bb8a..f21b3454d 100644 --- a/src/java/com/threerings/presents/server/net/ConnectionManager.java +++ b/src/java/com/threerings/presents/server/net/ConnectionManager.java @@ -283,7 +283,7 @@ public class ConnectionManager extends LoopingThread protected void willStart () { int successes = 0; - IOException _failure = null; + IOException failure = null; for (int ii = 0; ii < _ports.length; ii++) { try { // create a listening socket and add it to the select set @@ -299,7 +299,7 @@ public class ConnectionManager extends LoopingThread } catch (IOException ioe) { log.warning("Failure listening to socket on port '" + _ports[ii] + "'.", ioe); - _failure = ioe; + failure = ioe; } } @@ -332,7 +332,7 @@ public class ConnectionManager extends LoopingThread // if we failed to listen on at least one port, give up the ghost if (successes == 0) { if (_startlist != null) { - _startlist.requestFailed(_failure); + _startlist.requestFailed(failure); } return; } @@ -581,7 +581,7 @@ public class ConnectionManager extends LoopingThread } // then send any new messages - Tuple tup; + Tuple tup; while ((tup = _outq.getNonBlocking()) != null) { Connection conn = tup.left; @@ -882,7 +882,7 @@ public class ConnectionManager extends LoopingThread // log.info("Flattened " + msg + " into " + data.length + " bytes."); // and slap both on the queue - _outq.append(new Tuple(conn, data)); + _outq.append(new Tuple(conn, data)); } catch (Exception e) { log.warning("Failure flattening message [conn=" + conn + @@ -1017,7 +1017,7 @@ public class ConnectionManager extends LoopingThread } // documentation inherited - public void handlePartialWrite (Connection conn, ByteBuffer buffer) + public void handlePartialWrite (Connection wconn, ByteBuffer buffer) { // set up our _partial buffer _partial = ByteBuffer.allocateDirect(buffer.remaining()); @@ -1062,7 +1062,7 @@ public class ConnectionManager extends LoopingThread protected int _runtimeExceptionCount; /** Maps selection keys to network event handlers. */ - protected Map _handlers = Maps.newHashMap(); + protected Map _handlers = Maps.newHashMap(); /** Connections mapped by identifier. */ protected IntMap _connections = IntMaps.newHashIntMap(); @@ -1070,14 +1070,14 @@ public class ConnectionManager extends LoopingThread protected Queue _deathq = new Queue(); protected Queue _authq = new Queue(); - protected Queue> _outq = new Queue>(); - protected Queue> _dataq = new Queue>(); + protected Queue> _outq = new Queue>(); + protected Queue> _dataq = new Queue>(); protected FramingOutputStream _framer; protected ByteArrayOutputStream _flattener; protected ByteBuffer _outbuf = ByteBuffer.allocateDirect(64 * 1024); protected ByteBuffer _databuf = ByteBuffer.allocateDirect(Client.MAX_DATAGRAM_SIZE); - protected Map _oflowqs = Maps.newHashMap(); + protected Map _oflowqs = Maps.newHashMap(); protected List _observers = Lists.newArrayList(); diff --git a/src/java/com/threerings/presents/tools/ActionScriptSource.java b/src/java/com/threerings/presents/tools/ActionScriptSource.java index 5444d10ea..ca37b9c07 100644 --- a/src/java/com/threerings/presents/tools/ActionScriptSource.java +++ b/src/java/com/threerings/presents/tools/ActionScriptSource.java @@ -78,17 +78,18 @@ public class ActionScriptSource definition = definition.substring(0, definition.length()-1) + " = " + initValue + ";"; } - public void setComment (String comment) { - if (comment.indexOf("@Override") != -1) { - comment = comment.replaceAll("@Override ?", ""); - comment = comment.replaceFirst("// //", "//"); // handle // @Override // comment + public void setComment (String newComment) { + if (newComment.indexOf("@Override") != -1) { + newComment = newComment.replaceAll("@Override ?", ""); + // handle // @Override // comment + newComment = newComment.replaceFirst("// //", "//"); definition = "override " + definition; } // trim blank lines from start - while (comment.startsWith("\n")) { - comment = comment.substring(1); + while (newComment.startsWith("\n")) { + newComment = newComment.substring(1); } - this.comment = StringUtil.isBlank(comment) ? "" : comment; + comment = StringUtil.isBlank(newComment) ? "" : newComment; } public void write (PrintWriter writer) { @@ -1035,6 +1036,7 @@ public class ActionScriptSource return true; } + /** Denotes various phases of class file parsing. */ protected static enum Mode { PREAMBLE, IMPORTS, CLASSCOMMENT, CLASSDECL, CLASSBODY, METHODBODY, POSTCLASS, POSTPKG }; diff --git a/src/java/com/threerings/presents/tools/GenActionScriptBundlesTask.java b/src/java/com/threerings/presents/tools/GenActionScriptBundlesTask.java index 7679a473c..549a688f8 100644 --- a/src/java/com/threerings/presents/tools/GenActionScriptBundlesTask.java +++ b/src/java/com/threerings/presents/tools/GenActionScriptBundlesTask.java @@ -56,7 +56,6 @@ public class GenActionScriptBundlesTask extends Task @Override public void execute () - throws BuildException { // boilerplate for (FileSet fs : _filesets) { diff --git a/src/java/com/threerings/presents/tools/GenActionScriptTask.java b/src/java/com/threerings/presents/tools/GenActionScriptTask.java index 6f581f12c..250d96b4f 100644 --- a/src/java/com/threerings/presents/tools/GenActionScriptTask.java +++ b/src/java/com/threerings/presents/tools/GenActionScriptTask.java @@ -86,7 +86,7 @@ public class GenActionScriptTask extends Task * Performs the actual work of the task. */ @Override - public void execute () throws BuildException + public void execute () { try { _velocity = VelocityUtil.createEngine(); diff --git a/src/java/com/threerings/presents/tools/GenDObjectTask.java b/src/java/com/threerings/presents/tools/GenDObjectTask.java index f002cc5ea..2d25b06b8 100644 --- a/src/java/com/threerings/presents/tools/GenDObjectTask.java +++ b/src/java/com/threerings/presents/tools/GenDObjectTask.java @@ -80,7 +80,7 @@ public class GenDObjectTask extends Task } @Override - public void execute () throws BuildException + public void execute () { if (_cloader == null) { String errmsg = "This task requires a 'classpathref' attribute " + diff --git a/src/java/com/threerings/presents/tools/GenServiceTask.java b/src/java/com/threerings/presents/tools/GenServiceTask.java index 38aa8e0f1..145c74d92 100644 --- a/src/java/com/threerings/presents/tools/GenServiceTask.java +++ b/src/java/com/threerings/presents/tools/GenServiceTask.java @@ -101,6 +101,12 @@ public class GenServiceTask extends InvocationTask listener.equals(((ServiceListener)other).listener); } + @Override + public int hashCode () + { + return listener.getName().hashCode(); + } + public String getName () { String name = GenUtil.simpleName(listener); diff --git a/src/java/com/threerings/presents/tools/GenStreamableTask.java b/src/java/com/threerings/presents/tools/GenStreamableTask.java index a0576da20..55d780802 100644 --- a/src/java/com/threerings/presents/tools/GenStreamableTask.java +++ b/src/java/com/threerings/presents/tools/GenStreamableTask.java @@ -55,7 +55,7 @@ public class GenStreamableTask extends Task } @Override - public void execute () throws BuildException + public void execute () { for (FileSet fs : _filesets) { DirectoryScanner ds = fs.getDirectoryScanner(getProject()); diff --git a/src/java/com/threerings/presents/tools/ImportSet.java b/src/java/com/threerings/presents/tools/ImportSet.java index 82adfe195..949712da3 100644 --- a/src/java/com/threerings/presents/tools/ImportSet.java +++ b/src/java/com/threerings/presents/tools/ImportSet.java @@ -31,17 +31,17 @@ import com.samskivert.util.ComparableArrayList; import com.samskivert.util.StringUtil; /** - * Manages a set of strings to be used as a set of imports. Provides useful functions for + * Manages a set of strings to be used as a set of imports. Provides useful functions for * manipulating the set and sorts results. - * - *

Some methods in this class use a variable length String parameter 'replace'. This is a - * convenience for easily specifying multiple find/replace pairs. For example, to replace "Foo" - * with "Bar" and "123" with "ABC", a function can be called with the 4 arguments "Foo", "Bar", + * + *

Some methods in this class use a variable length String parameter 'replace'. This is a + * convenience for easily specifying multiple find/replace pairs. For example, to replace "Foo" + * with "Bar" and "123" with "ABC", a function can be called with the 4 arguments "Foo", "Bar", * "123", "ABC" for the String... replace argument. - * - *

A few methods also use a "pattern" string parameter that is used to match a class name. - * This is a dumbed down regular expression (to avoid many \.) where "*" means .* and no other - * characters have special meaning. The pattern is also implicitly enclosed with ^$ so that the + * + *

A few methods also use a "pattern" string parameter that is used to match a class name. + * This is a dumbed down regular expression (to avoid many \.) where "*" means .* and no other + * characters have special meaning. The pattern is also implicitly enclosed with ^$ so that the * pattern must match the class name in its entirity. Callers will mostly use this to specify a * prefix like "something*" or a suffix like "*something". */ @@ -75,9 +75,9 @@ public class ImportSet { _imports.addAll(other._imports); } - + /** - * Adds a class' name to the imports but first performs the given list of search/replaces as + * Adds a class' name to the imports but first performs the given list of search/replaces as * described above. * @param clazz the class whose name is munged and added * @param replace array of pairs to search/replace on the name before adding @@ -85,8 +85,8 @@ public class ImportSet public void addMunged (Class clazz, String... replace) { String name = clazz.getName(); - for (int i = 0 ; i < replace.length; i+=2) { - name = name.replace(replace[i], replace[i + 1]); + for (int ii = 0; ii < replace.length; ii += 2) { + name = name.replace(replace[ii], replace[ii+1]); } _imports.add(name); } @@ -98,7 +98,7 @@ public class ImportSet newset.addAll(this); return newset; } - + /** * Gets rid of primitive and java.lang imports. */ @@ -109,13 +109,12 @@ public class ImportSet String name = i.next(); if (name.indexOf('.') == -1) { i.remove(); - } - else if (name.startsWith("java.lang")) { + } else if (name.startsWith("java.lang")) { i.remove(); } } } - + /** * Gets rid of array imports. */ @@ -123,7 +122,7 @@ public class ImportSet { return removeAll("[*"); } - + /** * Remove all classes that are in the same package. * @param pkg package to remove @@ -133,13 +132,13 @@ public class ImportSet Iterator i = _imports.iterator(); while (i.hasNext()) { String name = i.next(); - if (name.startsWith(pkg) && + if (name.startsWith(pkg) && name.indexOf('.', pkg.length() + 1) == -1) { i.remove(); } } } - + /** * Replaces inner class imports (those with a '$') with an import of the parent class. */ @@ -155,12 +154,12 @@ public class ImportSet declarers.add(name.substring(0, dollar)); } } - + addAll(declarers); } /** - * Replace all inner classes' separator characters ('$') with an underscore ('_') for use + * Replace all inner classes' separator characters ('$') with an underscore ('_') for use * when generating ActionScript. */ public void translateInnerClasses () @@ -175,10 +174,10 @@ public class ImportSet inner.add(name.replace("$", "_")); } } - + addAll(inner); } - + /** * Inserts imports for the non-primitive classes contained in all array imports. */ @@ -194,7 +193,7 @@ public class ImportSet arrayTypes.add(name.substring(bracket + 2, name.length() - 1)); } } - + addAll(arrayTypes); } @@ -220,7 +219,7 @@ public class ImportSet } /** - * Re-adds the most recently popped import to the set. If a null value was pushed, does + * Re-adds the most recently popped import to the set. If a null value was pushed, does * nothing. * @throws IndexOutOfBoundsException if there is nothing to pop */ @@ -231,7 +230,7 @@ public class ImportSet _imports.add(front); } } - + /** * Removes the name of a class from the imports. * @param clazz the class whose name should be removed @@ -240,9 +239,9 @@ public class ImportSet { _imports.remove(clazz.getName()); } - + /** - * Replaces any import exactly each find string with the corresponding replace string. + * Replaces any import exactly each find string with the corresponding replace string. * See the description above. * @param replace array of pairs for search/replace */ @@ -282,12 +281,12 @@ public class ImportSet } return removed; } - + /** - * Adds a new munged import for each existing import that matches a pattern. The new entry is - * a copy of the old entry but modified according to the given find/replace pairs (see + * Adds a new munged import for each existing import that matches a pattern. The new entry is + * a copy of the old entry but modified according to the given find/replace pairs (see * description above). - * @param pattern to qualify imports to duplicate + * @param pattern to qualify imports to duplicate * @param replace pairs to find/replace on the new import */ public void duplicateAndMunge (String pattern, String... replace) @@ -301,7 +300,7 @@ public class ImportSet } for (String name : toMunge) { String newname = name; - for (int i = 0; i < replace.length; i+=2) { + for (int i = 0; i < replace.length; i += 2) { newname = newname.replace(replace[i], replace[i + 1]); } _imports.add(newname); @@ -336,8 +335,7 @@ public class ImportSet StringBuilder pattern = new StringBuilder(); pattern.append("^"); - while (true) - { + while (true) { String[] parts = _splitter.split(input, 2); pattern.append(Pattern.quote(parts[0])); if (parts.length == 1) { @@ -347,8 +345,7 @@ public class ImportSet String wildcard = input.substring(length, length + 1); if (wildcard.equals("*")) { pattern.append(".*"); - } - else { + } else { System.err.println("Bad wildcard " + wildcard); } input = parts[1]; @@ -360,6 +357,6 @@ public class ImportSet protected HashSet _imports = new HashSet(); protected List _pushed = new ArrayList(); - + protected static Pattern _splitter = Pattern.compile("\\*"); } diff --git a/src/java/com/threerings/presents/tools/InstrumentStreamableTask.java b/src/java/com/threerings/presents/tools/InstrumentStreamableTask.java index e811558d7..46be57978 100644 --- a/src/java/com/threerings/presents/tools/InstrumentStreamableTask.java +++ b/src/java/com/threerings/presents/tools/InstrumentStreamableTask.java @@ -80,7 +80,7 @@ public class InstrumentStreamableTask extends Task } @Override - public void execute () throws BuildException + public void execute () { // configure our ClassPool with our classpath for (Path path : _paths) { @@ -311,7 +311,7 @@ public class InstrumentStreamableTask extends Task if (field.getType().isPrimitive()) { return body; } else { - return "if (ins.readBoolean()) {\n" + + return "if (ins.readBoolean()) {\n" + " " + body + "\n" + " } else {\n" + " " + field.getName() + " = null;\n" + diff --git a/src/java/com/threerings/presents/tools/InvocationTask.java b/src/java/com/threerings/presents/tools/InvocationTask.java index 1ed1b990a..1504e7cae 100644 --- a/src/java/com/threerings/presents/tools/InvocationTask.java +++ b/src/java/com/threerings/presents/tools/InvocationTask.java @@ -326,7 +326,7 @@ public abstract class InvocationTask extends Task } @Override - public void execute () throws BuildException + public void execute () { if (_cloader == null) { String errmsg = "This task requires a 'classpathref' attribute " + diff --git a/src/java/com/threerings/presents/util/ClassUtil.java b/src/java/com/threerings/presents/util/ClassUtil.java index e0368fa1c..e51f527e1 100644 --- a/src/java/com/threerings/presents/util/ClassUtil.java +++ b/src/java/com/threerings/presents/util/ClassUtil.java @@ -22,7 +22,7 @@ package com.threerings.presents.util; import java.lang.reflect.Method; -import java.util.HashMap; +import java.util.Map; import com.samskivert.util.MethodFinder; import com.samskivert.util.StringUtil; @@ -43,7 +43,7 @@ public class ClassUtil * @return the method with the specified name or null if no method with that name could be * found. */ - public static Method getMethod (String name, Object target, HashMap cache) + public static Method getMethod (String name, Object target, Map cache) { Class tclass = target.getClass(); String key = tclass.getName() + ":" + name; @@ -80,7 +80,7 @@ public class ClassUtil } catch (NoSuchMethodException nsme) { // nothing to do here but fall through and return null - log.info("No such method [name=" + name + ", tclass=" + tclass.getName() + + log.info("No such method [name=" + name + ", tclass=" + tclass.getName() + ", args=" + StringUtil.toString(args) + ", error=" + nsme + "]."); } catch (SecurityException se) { diff --git a/src/java/com/threerings/presents/util/IgnoreConfirmAdapter.java b/src/java/com/threerings/presents/util/IgnoreConfirmAdapter.java index 4dd14318a..6f1732946 100644 --- a/src/java/com/threerings/presents/util/IgnoreConfirmAdapter.java +++ b/src/java/com/threerings/presents/util/IgnoreConfirmAdapter.java @@ -34,6 +34,8 @@ import static com.threerings.presents.Log.log; * result is ignored. If the failure is an instance fo {@link InvocationException} the message will * be passed on to the confirm listener, otherwise they will be provided with {@link * InvocationCodes#INTERNAL_ERROR}. + * + * @param the type of result expected by the listener. */ public class IgnoreConfirmAdapter implements ResultListener { diff --git a/src/java/com/threerings/presents/util/PersistingUnit.java b/src/java/com/threerings/presents/util/PersistingUnit.java index 1f7e123ef..048c529c5 100644 --- a/src/java/com/threerings/presents/util/PersistingUnit.java +++ b/src/java/com/threerings/presents/util/PersistingUnit.java @@ -110,7 +110,7 @@ public abstract class PersistingUnit extends Invoker.Unit * If the listener is known to be a ResultListener, this will cast it and report that the * request was processed. */ - protected void reportRequestProcessed (Object result ) + protected void reportRequestProcessed (Object result) { ((InvocationService.ResultListener)_listener).requestProcessed(result); } diff --git a/src/java/com/threerings/presents/util/ResultAdapter.java b/src/java/com/threerings/presents/util/ResultAdapter.java index 4626ab76a..c52670c10 100644 --- a/src/java/com/threerings/presents/util/ResultAdapter.java +++ b/src/java/com/threerings/presents/util/ResultAdapter.java @@ -33,6 +33,8 @@ import static com.threerings.presents.Log.log; * Adapts the response from a {@link ResultListener} to an InvocationService.ResultListener if the * failure is an instance of {@link InvocationException} the message will be passed on to the * result listener, otherwise they will be provided with {@link InvocationCodes#INTERNAL_ERROR}. + * + * @param the type of result expected by the listener. */ public class ResultAdapter implements ResultListener { diff --git a/src/java/com/threerings/presents/util/SafeSubscriber.java b/src/java/com/threerings/presents/util/SafeSubscriber.java index 7e80354a8..1b01c21f3 100644 --- a/src/java/com/threerings/presents/util/SafeSubscriber.java +++ b/src/java/com/threerings/presents/util/SafeSubscriber.java @@ -35,6 +35,8 @@ import static com.threerings.presents.Log.log; * distributed object when it is not know if the subscription will * complete before the subscriber decides they no longer wish to be * subscribed. + * + * @param the type of object to which we are subscribing. */ public class SafeSubscriber implements Subscriber diff --git a/src/java/com/threerings/util/DependencyGraph.java b/src/java/com/threerings/util/DependencyGraph.java index 8f12ae3c8..df78c4fbb 100644 --- a/src/java/com/threerings/util/DependencyGraph.java +++ b/src/java/com/threerings/util/DependencyGraph.java @@ -77,7 +77,6 @@ public class DependencyGraph * Records a new dependency of the dependant upon the dependee. */ public void addDependency (T dependant, T dependee) - throws IllegalArgumentException { _orphans.remove(dependant); DependencyNode dependantNode = _nodes.get(dependant); @@ -132,6 +131,7 @@ public class DependencyGraph /** Nodes in the graph with no parents/dependencies. */ protected ArrayList _orphans = new ArrayList(); + /** Represents a node in our dependency graph. */ protected class DependencyNode { public T content; diff --git a/src/java/com/threerings/util/MessageBundle.java b/src/java/com/threerings/util/MessageBundle.java index a4ae58b48..69f5597ec 100644 --- a/src/java/com/threerings/util/MessageBundle.java +++ b/src/java/com/threerings/util/MessageBundle.java @@ -325,9 +325,8 @@ public class MessageBundle } } - return (msg != null) ? - MessageFormat.format(MessageUtil.escape(msg), args) - : (key + StringUtil.toString(args)); + return (msg != null) ? MessageFormat.format(MessageUtil.escape(msg), args) : + (key + StringUtil.toString(args)); } /** diff --git a/src/java/com/threerings/util/MessageManager.java b/src/java/com/threerings/util/MessageManager.java index 21bd879da..cc2b0382a 100644 --- a/src/java/com/threerings/util/MessageManager.java +++ b/src/java/com/threerings/util/MessageManager.java @@ -202,8 +202,7 @@ public class MessageManager protected ClassLoader _loader; /** A cache of instantiated message bundles. */ - protected HashMap _cache = - new HashMap(); + protected HashMap _cache = new HashMap(); /** Our top-level message bundle, from which others obtain messages if * they can't find them within themselves. */ diff --git a/src/java/com/threerings/util/RandomUtil.java b/src/java/com/threerings/util/RandomUtil.java index 0eb45e772..e9d6cb70a 100644 --- a/src/java/com/threerings/util/RandomUtil.java +++ b/src/java/com/threerings/util/RandomUtil.java @@ -28,7 +28,7 @@ import java.util.Random; /** * Maintained for backwards compatibility with old Game Gardens games. - * + * * @deprecated moved to {@link com.samskivert.util.RandomUtil}. */ @Deprecated diff --git a/src/java/com/threerings/util/StreamableArrayList.java b/src/java/com/threerings/util/StreamableArrayList.java index 94bd1f798..84a20fc17 100644 --- a/src/java/com/threerings/util/StreamableArrayList.java +++ b/src/java/com/threerings/util/StreamableArrayList.java @@ -33,6 +33,7 @@ import com.threerings.io.Streamable; * the list must also be of streamable types. * * @see Streamable + * @param the type of elements stored in this list. */ public class StreamableArrayList extends ArrayList implements Streamable diff --git a/src/java/com/threerings/util/StreamableEnumSet.java b/src/java/com/threerings/util/StreamableEnumSet.java index 7f67c853f..93cdef4fe 100644 --- a/src/java/com/threerings/util/StreamableEnumSet.java +++ b/src/java/com/threerings/util/StreamableEnumSet.java @@ -38,6 +38,7 @@ import com.threerings.io.Streamable; * that can be streamed. * * @see Streamable + * @param the type of enum being stored in this set. */ public class StreamableEnumSet> extends AbstractSet implements Cloneable, Streamable diff --git a/src/java/com/threerings/util/StreamableHashIntMap.java b/src/java/com/threerings/util/StreamableHashIntMap.java index daeae9783..382c4fc0b 100644 --- a/src/java/com/threerings/util/StreamableHashIntMap.java +++ b/src/java/com/threerings/util/StreamableHashIntMap.java @@ -35,6 +35,7 @@ import com.threerings.io.Streamable; * values in the map must also be of streamable types. * * @see Streamable + * @param the type of value stored in this map. */ public class StreamableHashIntMap extends HashIntMap implements Streamable diff --git a/src/java/com/threerings/util/StreamableHashMap.java b/src/java/com/threerings/util/StreamableHashMap.java index d3199c511..75cd53cbc 100644 --- a/src/java/com/threerings/util/StreamableHashMap.java +++ b/src/java/com/threerings/util/StreamableHashMap.java @@ -34,8 +34,10 @@ import com.threerings.io.Streamable; * in the map must also be of streamable types. * * @see Streamable + * @param the type of key stored in this map. + * @param the type of value stored in this map. */ -public class StreamableHashMap extends HashMap +public class StreamableHashMap extends HashMap implements Streamable { /** @@ -64,7 +66,7 @@ public class StreamableHashMap extends HashMap { int ecount = size(); out.writeInt(ecount); - for (Map.Entry entry : entrySet()) { + for (Map.Entry entry : entrySet()) { out.writeObject(entry.getKey()); out.writeObject(entry.getValue()); } diff --git a/src/java/com/threerings/util/StreamableHashSet.java b/src/java/com/threerings/util/StreamableHashSet.java index 0747da4ce..825e7432a 100644 --- a/src/java/com/threerings/util/StreamableHashSet.java +++ b/src/java/com/threerings/util/StreamableHashSet.java @@ -33,6 +33,7 @@ import com.threerings.io.Streamable; * streamable types. * * @see Streamable + * @param the type of element stored in this set. */ public class StreamableHashSet extends HashSet implements Streamable diff --git a/src/java/com/threerings/util/StreamablePoint.java b/src/java/com/threerings/util/StreamablePoint.java index a2c6ea53c..ba4dad0d3 100644 --- a/src/java/com/threerings/util/StreamablePoint.java +++ b/src/java/com/threerings/util/StreamablePoint.java @@ -25,6 +25,9 @@ import java.awt.Point; import com.threerings.io.Streamable; +/** + * A point that can be sent over the network. + */ public class StreamablePoint extends Point implements Streamable { diff --git a/src/java/com/threerings/util/StreamableTuple.java b/src/java/com/threerings/util/StreamableTuple.java index 8c2a54e25..f037647e7 100644 --- a/src/java/com/threerings/util/StreamableTuple.java +++ b/src/java/com/threerings/util/StreamableTuple.java @@ -30,6 +30,8 @@ import com.threerings.io.Streamable; * must also be of streamable types. * * @see Streamable + * @param the type of the left-hand side of this tuple. + * @param the type of the right-hand side of this tuple. */ public class StreamableTuple extends Tuple implements Streamable diff --git a/src/java/com/threerings/util/TrackedObject.java b/src/java/com/threerings/util/TrackedObject.java index 3957ee2a8..a5771db6e 100644 --- a/src/java/com/threerings/util/TrackedObject.java +++ b/src/java/com/threerings/util/TrackedObject.java @@ -90,7 +90,7 @@ public class TrackedObject * instances and an int[] array that represent the number * of outstanding instance of all {@link TrackedObject}s in the VM. */ - public static Tuple getSnapshot () + public static Tuple getSnapshot () { Class[] classes = null; int[] counts = null; @@ -98,15 +98,15 @@ public class TrackedObject classes = new Class[_map.size()]; counts = new int[_map.size()]; int idx = 0; - for (Map.Entry entry : _map.entrySet()) { + for (Map.Entry entry : _map.entrySet()) { classes[idx] = entry.getKey(); counts[idx] = entry.getValue()[0]; idx++; } } - return new Tuple(classes, counts); + return new Tuple(classes, counts); } /** Tracks a mapping from {@link Class} object to active count. */ - protected static HashMap _map = new HashMap(); + protected static HashMap _map = new HashMap(); }