RouteTable.java

Index Score
com.limegroup.gnutella
FrostWire

View: Reasons, Metrics, Source Code

These are the metrics that contribute to the Enerjy Score for this file, ranked by impact. So the metrics listed at the top influence the score to a greater extent that the metrics listed at the bottom.

MetricDescription
JAVA0034JAVA0034 Missing braces in if statement
JAVA0143JAVA0143 Synchronized method
JAVA0108JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
DECL_COMMENTSComments in declarations
JAVA0020JAVA0020 Field name does not have required form
JAVA0110JAVA0110 Incorrect javadoc: no @return tag
SIZESize of the file in bytes
LINE_COMMENTNumber of line comments
EXEC_COMMENTSComments in executable code
COMMENTSComment lines
DOC_COMMENTNumber of javadoc comment lines
INTERFACE_COMPLEXITYInterface complexity
PARAMSNumber of formal parameter declarations
EXITSProcedure exits
PROGRAM_VOCABHalstead program vocabulary
UNIQUE_OPERANDSNumber of unique operands
OPERATORSNumber of operators
RETURNSNumber of return points from functions
PROGRAM_LENGTHHalstead program length
LOGICAL_LINESNumber of statements
LINESNumber of lines in the source file
FUNCTIONSNumber of function declarations
OPERANDSNumber of operands
UNIQUE_OPERATORSNumber of unique operators
CYCLOMATICCyclomatic complexity
JAVA0065JAVA0065 Unnecessary final modifier for method in final class
ELOCEffective lines of code
PROGRAM_VOLUMEHalstead program volume
LOCLines of code
JAVA0126JAVA0126 Method declares unchecked exception in throws
JAVA0130JAVA0130 Non-static method does not use instance fields
JAVA0075JAVA0075 Method parameter hides field
COMPARISONSNumber of comparison operators
LOOPSNumber of loops
JAVA0145JAVA0145 Tab character used in source file
package com.limegroup.gnutella; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.TreeMap; import org.limewire.collection.MultiIterable; import org.limewire.inspection.Inspectable; import org.limewire.util.Base32; import com.limegroup.gnutella.messages.QueryReply; import com.limegroup.gnutella.messages.Message.Network; import com.limegroup.gnutella.search.ResultCounter; import com.limegroup.gnutella.settings.MessageSettings; import com.limegroup.gnutella.util.ClassCNetworks; /** * The reply routing table. Given a GUID from a reply message header, * this tells you where to route the reply. It is mutable mapping * from globally unique 16-byte message IDs to connections. Old * mappings may be purged without warning, preferably using a FIFO * policy. This class makes a distinction between not having a mapping * for a GUID and mapping that GUID to null (in the case of a removed * ReplyHandler).<p> * * This class can also optionally keep track of the number of reply bytes * routed per guid. This can be useful for implementing fair flow-control * strategies. */ public final class RouteTable implements Inspectable { /** * The obvious implementation of this class is a mapping from GUID to * ReplyHandler's. The problem with this representation is it's hard to * implement removeReplyHandler efficiently. You either have to keep the * references to the ReplyHandler (which wastes memory) or iterate through * the entire table to clean all references (which wastes time AND removes * valuable information for preventing duplicate queries). * * Instead we use a layer of indirection. _newMap/_oldMap maps GUIDs to * integers, which act as IDs for each connection. _idMap maps IDs to * ReplyHandlers. _handlerMap maps ReplyHandler to IDs. So to clean up a * connection, we just purge the entries from _handlerMap and _idMap; there * is no need to iterate through the entire GUID mapping. Adding GUIDs and * routing replies are still constant-time operations. * * IDs are allocated sequentially according with the nextID variable. The * field does "wrap around" after reaching the maximum integer value. * Though no two open connections will have the same ID--we check * _idMap--there is a very low probability that an ID in _map could be * prematurely reused. * * To approximate FIFO behavior, we keep two sets around, _newMap and * _oldMap. Every few seconds, when the system time is greater than * nextSwitch, we clear _oldMap and replace it with _newMap. * (DuplicateFilter uses the same trick.) In this way, we remember the last * N to 2N minutes worth of GUIDs. This is superior to a fixed size route * table. * * For flow-control reasons, we also store the number of bytes routed per * GUID in each table. Hence the RouteTableEntry class. * * INVARIANT: keys of _newMap and _oldMap are disjoint * INVARIANT: _idMap and _replyMap are inverses * * TODO3: if IDs were stored in each ReplyHandler, we would not need * _replyMap. Better yet, if the values of _map were indices (with tags) * into ConnectionManager._initialized[Client]Connections, we would not * need _idMap either. However, this increases dependenceies. */ private Map<byte[], RouteTableEntry> _newMap = new ExperimentalGUIDMap(); private Map<byte[], RouteTableEntry> _oldMap= new ExperimentalGUIDMap(); private int _mseconds; private long _nextSwitchTime; private int _maxSize; private Map<Integer, ReplyHandler> _idMap = new HashMap<Integer, ReplyHandler>(); private Map<ReplyHandler, Integer> _handlerMap = new HashMap<ReplyHandler, Integer>(); private int _nextID; /** Values stored in _newMap/_oldMap. */ private static final class RouteTableEntry implements ResultCounter { /** The numericID of the reply connection. */ private int handlerID; /** The bytes already routed for this GUID. */ private int bytesRouted; /** The number of replies already routed for this GUID. */ private int repliesRouted; /** The number of replies for partial files already routed for this GUID */ private int partialRepliesRouted; /** The ttl associated with this RTE - meaningful only if > 0. */ private byte ttl = 0; /** The class C networks that have returned a reply for this query */ private final ClassCNetworks classCnetworks = new ClassCNetworks(); /** Timestamp when this entry was created */ private final long creationTime = System.currentTimeMillis(); /** The times when results for this query arrived */ private final List<Double> resultTimeStamps = new ArrayList<Double>(); /** The number of results that came each time */ private final List<Double> resultCounts = new ArrayList<Double>(); /** The network from which the replies came */ private final int[] networks = new int[4]; /** The hops of the replies */ private final int[] hops = new int[5]; /** The ttls of the replies */ private final int[] ttls = new int[5]; /** Creates a new entry for the given ID, with zero bytes routed. */ RouteTableEntry(int handlerID) { this.handlerID = handlerID; this.bytesRouted = 0; this.repliesRouted = 0; } public void setTTL(byte ttl) { this.ttl = ttl; } public byte getTTL() { return ttl; } /** Accessor for the number of results for this entry. */ public int getNumResults() { return Math.max(0,repliesRouted - partialRepliesRouted); } void updateClassCNetworks(int classCNetwork, int numReplies) { classCnetworks.add(classCNetwork, numReplies); } void timeStampResults(int count) { resultTimeStamps.add((double)(System.currentTimeMillis() - creationTime)); resultCounts.add((double)count); } void countHopsTTLNet(Network network, byte hop, byte ttl) { networks[Math.max(0,Math.min(network.ordinal(),networks.length - 1))]++; hops[Math.min(hops.length - 1, Math.max(0,hop-1))]++; ttls[Math.min(ttls.length - 1, Math.max(0,ttl-1))]++; } } /** * Creates a new route table with enough space to hold the last seconds to * 2*seconds worth of entries, or maxSize elements, whichever is smaller * [sic]. * * Typically maxSize is very large, and serves only as a guarantee to * prevent worst case behavior. Actually 2*maxSize elements can be held in * this in the worst case. */ public RouteTable(int seconds, int maxSize) { this._mseconds=seconds*1000; this._nextSwitchTime=System.currentTimeMillis()+_mseconds; this._maxSize=maxSize; } /** * Adds a new routing entry. * * @requires guid and c are non-null, guid.length==16 * @modifies this * @effects if replyHandler is open, adds the routing entry to this, * replacing any routing entries for guid. This has effect of * "renewing" guid. Otherwise returns without modifying this. * * @return the <tt>RouteTableEntry</tt> entered into the routing * tables, or <tt>null</tt> if it could not be entered */ public synchronized ResultCounter routeReply(byte[] guid, ReplyHandler replyHandler) { repOk(); purge(); if(replyHandler == null) { throw new NullPointerException("null reply handler"); } if (! replyHandler.isOpen()) return null; //First clear out any old entries for the guid, memorizing the volume //routed if found. Note that if the guid is found in _newMap, we don't //need to look in _oldMap. int id=handler2id(replyHandler).intValue(); RouteTableEntry entry = _newMap.remove(guid); if (entry==null) entry = _oldMap.remove(guid); //Now map the guid to the new reply handler, using the volume routed if //found, or zero otherwise. if (entry==null) entry=new RouteTableEntry(id); else entry.handlerID=id; //avoids allocation _newMap.put(guid, entry); return entry; } /** * Adds a new routing entry if one doesn't exist. * * @requires guid and c are non-null, guid.length==16 * @modifies this * @effects if no routing table entry for guid exists in this * (including null mappings from calls to removeReplyHandler) and * replyHandler is still open, adds the routing entry to this * and returns true. Otherwise returns false, without modifying this. */ public synchronized ResultCounter tryToRouteReply(byte[] guid, ReplyHandler replyHandler) { repOk(); purge(); assert replyHandler != null; assert guid!=null : "Null GUID in tryToRouteReply"; if (! replyHandler.isOpen()) return null; if(!_newMap.containsKey(guid) && !_oldMap.containsKey(guid)) { int id=handler2id(replyHandler).intValue(); RouteTableEntry entry = new RouteTableEntry(id); _newMap.put(guid, entry); //_newMap.put(guid, new RouteTableEntry(id)); return entry; } else { return null; } } /** Optional operation - if you want to remember the TTL associated with a * counter, in order to allow for extendable execution, you can set the TTL * a message (guid). * @param ttl should be greater than 0. * @exception IllegalArgumentException thrown if !(ttl > 0), or if entry is * null or is not something I recognize. So only put in what I dole out. */ public synchronized void setTTL(ResultCounter entry, byte ttl) { if (entry == null) throw new IllegalArgumentException("Null entry!!"); if (!(entry instanceof RouteTableEntry)) throw new IllegalArgumentException("entry is not recognized."); if (!(ttl > 0)) throw new IllegalArgumentException("Input TTL too small: " + ttl); ((RouteTableEntry)entry).setTTL(ttl); } /** Synchronizes a TTL get test with a set test. * @param getTTL the ttl you want getTTL() to be in order to setTTL(). * @param setTTL the ttl you want to setTTL() if getTTL() was correct. * @return true if the TTL was set as you desired. * @throws IllegalArgumentException if getTTL or setTTL is less than 1, or * if setTTL < getTTL */ public synchronized boolean getAndSetTTL(byte[] guid, byte getTTL, byte setTTL) { if ((getTTL < 1) || (setTTL <= getTTL)) throw new IllegalArgumentException("Bad ttl input (get/set): " + getTTL + "/" + setTTL); RouteTableEntry entry = _newMap.get(guid); if (entry==null) entry = _oldMap.get(guid); if ((entry != null) && (entry.getTTL() == getTTL)) { entry.setTTL(setTTL); return true; } return false; } /** * Looks up the reply route for a given guid. * * @requires guid.length==16 * @effects returns the corresponding ReplyHandler for this GUID. * Returns null if no mapping for guid, or guid maps to null (i.e., * to a removed ReplyHandler. */ public synchronized ReplyHandler getReplyHandler(byte[] guid) { //no purge repOk(); //Look up guid in _newMap. If not there, check _oldMap. RouteTableEntry entry = _newMap.get(guid); if (entry==null) entry = _oldMap.get(guid); //Note that id2handler may return null. return (entry==null) ? null : id2handler(new Integer(entry.handlerID)); } public synchronized ReplyRoutePair getReplyHandler(byte[] guid, int replyBytes, short numReplies, short partialReplies) { return getReplyHandler(guid, replyBytes, numReplies, partialReplies, 0); } /** * Looks up the reply route and route volume for a given guid, incrementing * the count of bytes routed for that GUID. * * @param classCNetwork integer representing the classC network the replies * came from. 0 if it should not be counted (as 0 is not a valid classC network). * @requires guid.length==16 * @effects if no mapping for guid, or guid maps to null (i.e., to a removed * ReplyHandler) returns null. Otherwise returns a tuple containing the * corresponding ReplyHandler for this GUID along with the volume of * messages already routed for that guid. Afterwards, increments the reply * count by replyBytes. */ public synchronized ReplyRoutePair getReplyHandler(byte[] guid, int replyBytes, short numReplies, short partialReplies, int classCNetwork) { //no purge repOk(); //Look up guid in _newMap. If not there, check _oldMap. RouteTableEntry entry = _newMap.get(guid); if (entry==null) entry = _oldMap.get(guid); //If no mapping for guid, or guid maps to a removed reply handler, //return null. if (entry==null) return null; ReplyHandler handler=id2handler(new Integer(entry.handlerID)); if (handler==null) return null; //Increment count, returning old count in tuple. ReplyRoutePair ret = new ReplyRoutePair(handler, entry.bytesRouted, entry.repliesRouted); entry.bytesRouted += replyBytes; entry.repliesRouted += numReplies; entry.partialRepliesRouted += partialReplies; if (classCNetwork != 0) entry.updateClassCNetworks(classCNetwork, numReplies); return ret; } /** Remembers that the specified number of results came now */ public synchronized void timeStampResults(QueryReply reply) { RouteTableEntry entry = _newMap.get(reply.getGUID()); if (entry==null) entry = _oldMap.get(reply.getGUID()); if (entry==null) return; entry.timeStampResults(reply.getUniqueResultCount()); } public synchronized void countHopsTTLNet(QueryReply reply) { RouteTableEntry entry = _newMap.get(reply.getGUID()); if (entry==null) entry = _oldMap.get(reply.getGUID()); if (entry==null) return; entry.countHopsTTLNet(reply.getNetwork(), reply.getHops(), reply.getTTL()); } /** The return value from getReplyHandler. */ public static final class ReplyRoutePair { private final ReplyHandler handler; private final int volume; private final int REPLIES_ROUTED; ReplyRoutePair(ReplyHandler handler, int volume, int hits) { this.handler = handler; this.volume = volume; REPLIES_ROUTED = hits; } /** Returns the ReplyHandler to route your message */ public ReplyHandler getReplyHandler() { return handler; } /** Returns the volume of messages already routed for the given GUID. */ public int getBytesRouted() { return volume; } /** * Accessor for the number of query results that have been routed * for the GUID that identifies this <tt>ReplyRoutePair</tt>. * * @return the number of query results that have been routed for this * guid */ public int getResultsRouted() { return REPLIES_ROUTED; } } /** * Clears references to a given ReplyHandler. * * @modifies this * @effects replaces all entries [guid, rh2] s.t. * rh2.equals(replyHandler) with entries [guid, null]. This operation * runs in constant time. [sic] */ public synchronized void removeReplyHandler(ReplyHandler replyHandler) { //no purge repOk(); //The aggressive asserts below are to make sure bug X75 has been fixed. assert replyHandler!=null : "Null replyHandler in removeReplyHandler"; //Note that _map is not modified. See overview of class for rationale. //Also, handler2id may actually allocate a new ID for replyHandler, when //killing a connection for which we've routed no replies. That's ok; //we'll just clean up the new ID immediately. Integer id=handler2id(replyHandler); _idMap.remove(id); _handlerMap.remove(replyHandler); } /** * @modifies nextID, _handlerMap, _idMap * @effects returns a unique ID for the given handler, updating * _handlerMap and _idMap if handler has not been encountered before. * With very low probability, the returned id may be a value _map. */ private Integer handler2id(ReplyHandler handler) { //Have we encountered this handler recently? If so, return the id. Integer id = _handlerMap.get(handler); if (id!=null) return id; //Otherwise return the next free id, searching in extremely rare cases //if needed. Note that his enters an infinite loop if all 2^32 IDs are //taken up. BFD. while (true) { //don't worry about overflow; Java wraps around TODO1? id=new Integer(_nextID++); if (_idMap.get(id)==null) break; } _handlerMap.put(handler, id); _idMap.put(id, handler); return id; } /** * Returns the ReplyHandler associated with the following ID, or * null if none. */ private ReplyHandler id2handler(Integer id) { return _idMap.get(id); } /** * Purges old entries. * * @modifies _nextSwitchTime, _newMap, _oldMap * @effects if the system time is less than _nextSwitchTime, returns * false. Otherwise, clears _oldMap and swaps _oldMap and _newMap, * updates _nextSwitchTime, and returns true. */ private final boolean purge() { long now=System.currentTimeMillis(); if (now<_nextSwitchTime && _newMap.size()<_maxSize) //not enough time has elapsed and sets too small return false; //System.out.println(now+" "+this.hashCode()+" purging " // +_oldMap.size()+" old, " // +_newMap.size()+" new"); _oldMap.clear(); Map<byte[], RouteTableEntry> tmp=_oldMap; _oldMap=_newMap; _newMap=tmp; _nextSwitchTime=now+_mseconds; return true; } public synchronized String toString() { //Inefficient, but this is only for debugging anyway. StringBuilder buf=new StringBuilder("{"); Map<byte[], RouteTableEntry> bothMaps=new TreeMap<byte[], RouteTableEntry>(new GUID.GUIDByteComparator()); bothMaps.putAll(_oldMap); bothMaps.putAll(_newMap); Iterator<byte[]> iter=bothMaps.keySet().iterator(); while (iter.hasNext()) { byte[] key = iter.next(); buf.append(new GUID(key)); // GUID buf.append("->"); int id= bothMaps.get(key).handlerID; ReplyHandler handler=id2handler(new Integer(id)); buf.append(handler==null ? "null" : handler.toString());//connection if (iter.hasNext()) buf.append(", "); } buf.append("}"); return buf.toString(); } // private static boolean warned=false; /** Tests internal consistency. VERY slow. */ private final void repOk() { /* if (!warned) { System.err.println( "WARNING: RouteTable.repOk enabled. Expect performance problems!"); warned=true; } //Check that _idMap is inverse of _handlerMap... for (Iterator iter=_idMap.keySet().iterator(); iter.hasNext(); ) { Integer key=(Integer)iter.next(); ReplyHandler value=(ReplyHandler)_idMap.get(key); Assert.that(_handlerMap.get(value)==key); } //..and vice versa for (Iterator iter=_handlerMap.keySet().iterator(); iter.hasNext(); ) { ReplyHandler key=(ReplyHandler)iter.next(); Integer value=(Integer)_handlerMap.get(key); Assert.that(_idMap.get(value)==key); } //Check that keys of _newMap aren't in _oldMap, values are RouteTableEntry for (Iterator iter=_newMap.keySet().iterator(); iter.hasNext(); ) { byte[] guid=(byte[])iter.next(); Assert.that(! _oldMap.containsKey(guid)); Assert.that(_newMap.get(guid) instanceof RouteTableEntry); } //Check that keys of _oldMap aren't in _newMap for (Iterator iter=_oldMap.keySet().iterator(); iter.hasNext(); ) { byte[] guid=(byte[])iter.next(); Assert.that(! _newMap.containsKey(guid)); Assert.that(_oldMap.get(guid) instanceof RouteTableEntry); } */ } /** * @param guid a guid of a message we wish to route * @return the same guid if the zero guid experiment is enabled, * otherwise a clone with the oob-affected bytes zeroed. */ private static final byte [] zeroOOBBytes(byte [] guid) { if (!MessageSettings.GUID_ZERO_EXPERIMENT.getValue()) return guid; guid = guid.clone(); for (int i : new int[]{0,1,2,3,13,14}) guid[i] = 0; return guid; } /** * A map that can optionally zero out the OOB-mutated bytes of a guid. */ private static class ExperimentalGUIDMap extends TreeMap<byte [], RouteTableEntry> { ExperimentalGUIDMap() { super(new GUID.GUIDByteComparator()); } @Override public boolean containsKey(Object key) { if (key instanceof byte[]) key = zeroOOBBytes((byte[]) key); return super.containsKey(key); } @Override public RouteTableEntry get(Object key) { if (key instanceof byte[]) key = zeroOOBBytes((byte[]) key); return super.get(key); } @Override public RouteTableEntry put(byte[] key, RouteTableEntry value) { key = zeroOOBBytes(key); return super.put(key, value); } @Override public RouteTableEntry remove(Object key) { if (key instanceof byte[]) key = zeroOOBBytes((byte[]) key); return super.remove(key); } } /** * An actual dump of the routing table. May get big, so * its a good idea to first inspect the stats to see how many * entries there are. */ public Object inspect() { Map<String, Object> ret = new HashMap<String, Object>(); Iterable<Map.Entry<byte[], RouteTableEntry>> bothMaps = new MultiIterable<Map.Entry<byte[],RouteTableEntry>>(_newMap.entrySet(),_oldMap.entrySet()); for (Map.Entry<byte[], RouteTableEntry> entry : bothMaps) { RouteTableEntry e = entry.getValue(); Map<String, Object> m = new HashMap<String, Object>(); m.put("br", e.bytesRouted); m.put("ttl", e.ttl); m.put("rr", e.repliesRouted); m.put("prr", e.partialRepliesRouted); m.put("cc", e.classCnetworks.getMap()); m.put("rt", e.resultTimeStamps); m.put("rc", e.resultCounts); m.put("ct", e.creationTime); m.put("id", e.handlerID); m.put("nets", getBytes(e.networks)); m.put("hops", getBytes(e.hops)); m.put("ttls", getBytes(e.ttls)); ret.put(Base32.encode(entry.getKey()), m); } for (int id : _idMap.keySet()) { ReplyHandler r = _idMap.get(id); Map<String,Object> m = new HashMap<String,Object>(); m.put("ip",r.getAddress()); m.put("port", r.getPort()); m.put("cguid",r.getClientGUID()); ret.put(String.valueOf(id),m); } return ret; } private byte [] getBytes(int []ints) { ByteBuffer b = ByteBuffer.allocate(ints.length * 4); b.asIntBuffer().put(ints); return b.array(); } }

The table below shows all metrics for RouteTable.java.

MetricValueDescription
BLOCKS43.00Number of blocks
BLOCK_COMMENT34.00Number of block comment lines
COMMENTS249.00Comment lines
COMMENT_DENSITY 0.90Comment density
COMPARISONS39.00Number of comparison operators
CYCLOMATIC72.00Cyclomatic complexity
DECL_COMMENTS38.00Comments in declarations
DOC_COMMENT184.00Number of javadoc comment lines
ELOC277.00Effective lines of code
EXEC_COMMENTS20.00Comments in executable code
EXITS63.00Procedure exits
FUNCTIONS35.00Number of function declarations
HALSTEAD_DIFFICULTY85.35Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY95.00Interface complexity
JAVA0001 0.00JAVA0001 Package name does not contain only lower case letters
JAVA0002 0.00JAVA0002 Package name does not begin with a top level domain name or country code
JAVA0003 0.00JAVA0003 Minimize use of on-demand (.*) imports
JAVA0004 0.00JAVA0004 Unnecessary import from java.lang
JAVA0005 0.00JAVA0005 Imports not in specified order
JAVA0006 0.00JAVA0006 Empty finally block
JAVA0007 0.00JAVA0007 Should not declare public field
JAVA0008 0.00JAVA0008 Empty catch block
JAVA0009 0.00JAVA0009 Protected member in final class
JAVA0010 0.00JAVA0010 Non-instantiable class does not contain a non-private static member
JAVA0011 0.00JAVA0011 Abstract class does not contain an abstract method
JAVA0012 0.00JAVA0012 Non-constructor method with same name as declaring class
JAVA0013 0.00JAVA0013 Non-blank final field is not static
JAVA0014 0.00JAVA0014 Class with only static members has non-private constructor
JAVA0015 0.00JAVA0015 Package class contains public nested type
JAVA0016 0.00JAVA0016 Abstract class contains public constructor
JAVA0017 0.00JAVA0017 Class name does not have required form
JAVA0018 0.00JAVA0018 Method name does not have required form
JAVA0019 0.00JAVA0019 Interface name does not have required form
JAVA0020 8.00JAVA0020 Field name does not have required form
JAVA0021 0.00JAVA0021 Interface method name does not have required form
JAVA0022 0.00JAVA0022 Static final field name does not have required form
JAVA0023 0.00JAVA0023 Empty finalize method
JAVA0024 0.00JAVA0024 Empty class
JAVA0025 0.00JAVA0025 Method override is empty
JAVA0026 0.00JAVA0026 Finalize method with parameters
JAVA0029 0.00JAVA0029 Private method not used
JAVA0030 0.00JAVA0030 Private field not used
JAVA0031 0.00JAVA0031 Case statement not properly closed
JAVA0032 0.00JAVA0032 Switch statement missing default
JAVA0033 0.00JAVA0033 default: not last case in switch statement
JAVA003427.00JAVA0034 Missing braces in if statement
JAVA0035 0.00JAVA0035 Missing braces in for statement
JAVA0036 0.00JAVA0036 Missing braces in while statement
JAVA0038 0.00JAVA0038 Non-case label in switch statement
JAVA0039 0.00JAVA0039 Break statement with label
JAVA0040 0.00JAVA0040 Switch statement contains N cases (maximum: M)
JAVA0041 0.00JAVA0041 Nested synchronized block
JAVA0042 0.00JAVA0042 Empty synchronized statement
JAVA0043 0.00JAVA0043 Inner class does not use outer class
JAVA0044 0.00JAVA0044 Serializable class with no instance variables
JAVA0045 0.00JAVA0045 Serializable class with only transient fields
JAVA0046 0.00JAVA0046 Name of class not derived from Exception ends with 'Exception'
JAVA0047 0.00JAVA0047 Serializable class derives from invalid base class
JAVA0048 0.00JAVA0048 Name of class derived from Exception does not end with 'Exception'
JAVA0049 0.00JAVA0049 Nested block at depth N (maximum: M)
JAVA0050 0.00JAVA0050 Class derives from java.lang.Error
JAVA0051 0.00JAVA0051 Class derives from java.lang.RuntimeException
JAVA0052 0.00JAVA0052 Class derives from java.lang.Throwable
JAVA0053 0.00JAVA0053 Unused label
JAVA0054 0.00JAVA0054 Inheritance depth N exceeds maximum M
JAVA0055 0.00JAVA0055 Class should be interface
JAVA0056 0.00JAVA0056 Unnecessary abstract modifier for interface or annotation
JAVA0057 0.00JAVA0057 Unnecessary default constructor
JAVA0058 0.00JAVA0058 Constructor calls super()
JAVA0059 0.00JAVA0059 Method override only calls super()
JAVA0061 0.00JAVA0061 Inaccessible member in anonymous class
JAVA0062 0.00JAVA0062 Public class missing public member or protected constructor
JAVA0063 0.00JAVA0063 Identifier name should not contain '$'
JAVA0064 0.00JAVA0064 N variations of identifier name (maximum: M)
JAVA0065 3.00JAVA0065 Unnecessary final modifier for method in final class
JAVA0066 0.00JAVA0066 Unnecessary modifier for interface nested type
JAVA0067 0.00JAVA0067 Array descriptor on identifier name
JAVA0068 0.00JAVA0068 Modifiers not declared in recommended order
JAVA0071 0.00JAVA0071 Strings compared with ==
JAVA0073 0.00JAVA0073 Integer division in floating-point context
JAVA0074 0.00JAVA0074 Use of Object.notify()
JAVA0075 1.00JAVA0075 Method parameter hides field
JAVA0076 0.00JAVA0076 Use of magic number
JAVA0077 0.00JAVA0077 Private field not used in declaring class
JAVA0078 0.00JAVA0078 Floating point values compared with ==
JAVA0079 0.00JAVA0079 Use of instance to reference static member
JAVA0080 0.00JAVA0080 Import declaration not used
JAVA0081 0.00JAVA0081 Boolean literal in comparison
JAVA0082 0.00JAVA0082 Unnecessary widening cast
JAVA0083 0.00JAVA0083 Unnecessary instanceof test
JAVA0084 0.00JAVA0084 Should use compound assignment operator
JAVA0085 0.00JAVA0085 Use of sun.* class
JAVA0087 0.00JAVA0087 Use of Thread.sleep()
JAVA0089 0.00JAVA0089 Use of restricted package
JAVA0092 0.00JAVA0092 Use of restricted type
JAVA0093 0.00JAVA0093 Redundant assignment
JAVA0094 0.00JAVA0094 Field hides a superclass field
JAVA0095 0.00JAVA0095 Uninitialized private field
JAVA0096 0.00JAVA0096 Field in nested class hides outer field
JAVA0098 0.00JAVA0098 Minimize use of implicit field initializers
JAVA0100 0.00JAVA0100 Class contains N non-final fields (maximum: M)
JAVA0101 0.00JAVA0101 Unnecessary modifier for field in interface
JAVA0102 0.00JAVA0102 Last statement in finalize() not super.finalize()
JAVA0103 0.00JAVA0103 Explicit call to finalize()
JAVA0104 0.00JAVA0104 finalize() only calls super.finalize()
JAVA0105 0.00JAVA0105 Duplicate import declaration
JAVA0106 0.00JAVA0106 Unnecessary import from current package
JAVA010818.00JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0109 0.00JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA011010.00JAVA0110 Incorrect javadoc: no @return tag
JAVA0111 0.00JAVA0111 Incorrect javadoc: @return tag for void method
JAVA0112 0.00JAVA0112 Incorrect javadoc: no exception 'exception' in throws
JAVA0113 1.00JAVA0113 Incorrect javadoc: no @author tag
JAVA0114 1.00JAVA0114 Incorrect javadoc: no @version tag
JAVA0115 0.00JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
JAVA0116 0.00JAVA0116 Missing javadoc: field 'field'
JAVA0117 4.00JAVA0117 Missing javadoc: method 'method'
JAVA0118 0.00JAVA0118 Missing javadoc: type 'type'
JAVA0119 0.00JAVA0119 Control variable changed within body of for loop
JAVA0123 0.00JAVA0123 Use all three components of for loop
JAVA0125 0.00JAVA0125 Continue statement with label
JAVA0126 0.00JAVA0126 Method declares unchecked exception in throws
JAVA0128 0.00JAVA0128 Public constructor in non-public class
JAVA0130 1.00JAVA0130 Non-static method does not use instance fields
JAVA0131 0.00JAVA0131 Compatible method does not override base
JAVA0132 0.00JAVA0132 Method overload with compatible signature
JAVA0133 0.00JAVA0133 Non-synchronized method overrides synchronized method
JAVA0135 0.00JAVA0135 Only one of Object.equals and Object.hashCode defined: missing 'method'
JAVA0136 0.00JAVA0136 N methods defined in class (maximum: M)
JAVA0137 0.00JAVA0137 Non-abstract class missing constructor
JAVA0138 0.00JAVA0138 N parameters defined for method (maximum: M)
JAVA0139 0.00JAVA0139 Definition of main other than public static void main(java.lang.String[])
JAVA0141 0.00JAVA0141 Unnecessary modifier for method in interface
JAVA014311.00JAVA0143 Synchronized method
JAVA0144 0.00JAVA0144 Line exceeds maximum M characters
JAVA014576.00JAVA0145 Tab character used in source file
JAVA0150 0.00JAVA0150 java.lang.Error (or subclass) thrown
JAVA0153 0.00JAVA0153 Inefficient conversion of integer to string
JAVA0159 0.00JAVA0159 Inefficient conversion of string to integer
JAVA0160 0.00JAVA0160 Method does not throw specified exception
JAVA0161 0.00JAVA0161 Conditional wait() not in loop
JAVA0163 0.00JAVA0163 Empty statement
JAVA0165 0.00JAVA0165 Conflicting return statement in finally block
JAVA0166 0.00JAVA0166 Generic exception caught
JAVA0167 0.00JAVA0167 ThreadDeath not rethrown
JAVA0169 0.00JAVA0169 Unnecessary catch block: exception 'exception'
JAVA0170 0.00JAVA0170 Caught exception not derived from java.lang.Exception
JAVA0171 0.00JAVA0171 Unused local variable
JAVA0173 0.00JAVA0173 Unused method parameter
JAVA0174 0.00JAVA0174 Assigned local variable never used
JAVA0175 0.00JAVA0175 Successive assignment to variable
JAVA0176 0.00JAVA0176 Local variable name does not have required form
JAVA0177 0.00JAVA0177 Variable declaration missing initializer
JAVA0179 0.00JAVA0179 Local variable hides visible field
JAVA0233 0.00JAVA0233 Definition of serialVersionUID other than 'private static final long serialVersionUID'
JAVA0234 1.00JAVA0234 Class is Serializable but does not define serialVersionUID
JAVA0235 0.00JAVA0235 Class defines serialVersionUID but does not implement Serializable
JAVA0236 0.00JAVA0236 Attempt to clone an object which does not implement Cloneable
JAVA0237 0.00JAVA0237 Class implements Cloneable but does not have public clone method
JAVA0238 0.00JAVA0238 Clone method does not call super.clone()
JAVA0239 0.00JAVA0239 Class declares 'readObject' or 'writeObject' but does not implement Serializable
JAVA0240 0.00JAVA0240 Serializable class which declares readObject or writeObject but not both
JAVA0241 0.00JAVA0241 'readObject' or 'writeObject' should be declared private in Serializable class
JAVA0242 0.00JAVA0242 Transient field in non-Serializable class
JAVA0243 0.00JAVA0243 'readResolve' or 'writeReplace' should be declared private or protected
JAVA0244 0.00JAVA0244 Field or method name in subclass differs only by case from inherited field or method
JAVA0245 0.00JAVA0245 JUnit TestCase with non-trivial constructor
JAVA0246 0.00JAVA0246 JUnit assertXXX statement missing message parameter
JAVA0247 0.00JAVA0247 JUnit 'setUp()' and 'tearDown()' should call super method
JAVA0248 0.00JAVA0248 JUnit method 'setUp' or 'tearDown' with incorrect signature
JAVA0249 0.00JAVA0249 JUnit TestCase 'suite()' should be declared static
JAVA0250 0.00JAVA0250 JUnit TestCase declares testXXX method with incorrect signature
JAVA0251 0.00JAVA0251 Use '%n' for line breaks in printf/format for platform independence
JAVA0252 0.00JAVA0252 'enum' is a Java 1.5 reserved word
JAVA0253 0.00JAVA0253 Not all enum constants consumed in switch statement
JAVA0254 0.00JAVA0254 Use enhanced for loop construct instead of Iterator
JAVA0255 0.00JAVA0255 Result of method invocation not used
JAVA0256 0.00JAVA0256 Assignment of external collection/array to field
JAVA0257 0.00JAVA0257 Use of 'Constant Interface' anti-pattern
JAVA0258 0.00JAVA0258 Implement Iterable for foreach compatibility
JAVA0259 0.00JAVA0259 Return of collection/array field
JAVA0260 0.00JAVA0260 Use 'enum' instead of Enumerated Type pattern
JAVA0261 0.00JAVA0261 Use specialized Enum collection types
JAVA0262 0.00JAVA0262 Use of char in integer context
JAVA0263 0.00JAVA0263 Long literal ends with 'l' instead of 'L'
JAVA0264 0.00JAVA0264 Integer math in long context - check for overflow
JAVA0265 0.00JAVA0265 Use of Throwable.printStackTrace()
JAVA0266 0.00JAVA0266 Use of System.out
JAVA0267 0.00JAVA0267 Use of System.err
JAVA0269 0.00JAVA0269 Contents of StringBuffer never used
JAVA0270 0.00JAVA0270 Use Java 5.0 enhanced for loop construct to iterate over all elements in an array
JAVA0271 0.00JAVA0271 Minimize use of on-demand (.*) static imports
JAVA0272 0.00JAVA0272 Thread.run() called
JAVA0273 0.00JAVA0273 Non-final derivative of Thread calls start() in constructor
JAVA0274 0.00JAVA0274 Serializable class has a synchronized readObject()
JAVA0275 0.00JAVA0275 Serializable class has a synchronized writeObject() and no other synchronized methods
JAVA0276 0.00JAVA0276 Unnecessary use of String constructor
JAVA0277 0.00JAVA0277 Iterator.next() implementation does not throw NoSuchElementException
JAVA0278 0.00JAVA0278 Unnecessary use of Boolean constructor
JAVA0279 0.00JAVA0279 Serialization method readObject or readObjectNoData calls an overridable method
JAVA0280 0.00JAVA0280 IllegalMonitorStateException caught
JAVA0281 0.00JAVA0281 Iterator.next() not called in loop
JAVA0282 0.00JAVA0282 Call to Iterator.next() in loop which does not test Iterator.hasNext()
JAVA0283 0.00JAVA0283 Control variable not updated in loop body
JAVA0284 0.00JAVA0284 Explicit garbage collection
JAVA0285 0.00JAVA0285 Dereference of potentially null variable
JAVA0286 0.00JAVA0286 Dereference of null variable
JAVA0287 0.00JAVA0287 Unnecessary null check
JAVA0288 0.00JAVA0288 Inconsistent null check
LINES631.00Number of lines in the source file
LINE_COMMENT31.00Number of line comments
LOC317.00Lines of code
LOGICAL_LINES191.00Number of statements
LOOPS 2.00Number of loops
NEST_DEPTH 2.00Maximum nesting depth
OPERANDS839.00Number of operands
OPERATORS1692.00Number of operators
PARAMS44.00Number of formal parameter declarations
PROGRAM_LENGTH2531.00Halstead program length
PROGRAM_VOCAB349.00Halstead program vocabulary
PROGRAM_VOLUME 0.00Halstead program volume
RETURNS51.00Number of return points from functions
SIZE24989.00Size of the file in bytes
UNIQUE_OPERANDS290.00Number of unique operands
UNIQUE_OPERATORS59.00Number of unique operators
WHITESPACE65.00Number of whitespace lines