ReadWriteCache.java

Index Score
org.hibernate.cache
Hibernate

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
JAVA0110JAVA0110 Incorrect javadoc: no @return tag
JAVA0126JAVA0126 Method declares unchecked exception in throws
JAVA0034JAVA0034 Missing braces in if statement
INTERFACE_COMPLEXITYInterface complexity
JAVA0143JAVA0143 Synchronized method
JAVA0115JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
RETURNSNumber of return points from functions
PARAMSNumber of formal parameter declarations
DECL_COMMENTSComments in declarations
FUNCTIONSNumber of function declarations
JAVA0117JAVA0117 Missing javadoc: method 'method'
CYCLOMATICCyclomatic complexity
JAVA0108JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
BLOCKSNumber of blocks
DOC_COMMENTNumber of javadoc comment lines
COMMENTSComment lines
JAVA0075JAVA0075 Method parameter hides field
LINESNumber of lines in the source file
JAVA0244JAVA0244 Field or method name in subclass differs only by case from inherited field or method
PROGRAM_VOLUMEHalstead program volume
JAVA0136JAVA0136 N methods defined in class (maximum: M)
COMPARISONSNumber of comparison operators
JAVA0285JAVA0285 Dereference of potentially null variable
UNIQUE_OPERATORSNumber of unique operators
PROGRAM_VOCABHalstead program vocabulary
SIZESize of the file in bytes
LOOPSNumber of loops
UNIQUE_OPERANDSNumber of unique operands
JAVA0130JAVA0130 Non-static method does not use instance fields
LOCLines of code
NEST_DEPTHMaximum nesting depth
JAVA0141JAVA0141 Unnecessary modifier for method in interface
/* * Hibernate, Relational Persistence for Idiomatic Java * * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as * indicated by the @author tags or express copyright attribution * statements applied by the authors. All third-party contributions are * distributed under license by Red Hat Middleware LLC. * * This copyrighted material is made available to anyone wishing to use, modify, * copy, or redistribute it subject to the terms and conditions of the GNU * Lesser General Public License, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this distribution; if not, write to: * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA * */ package org.hibernate.cache; import java.io.Serializable; import java.util.Comparator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.hibernate.cache.access.SoftLock; /** * Caches data that is sometimes updated while maintaining the semantics of * "read committed" isolation level. If the database is set to "repeatable * read", this concurrency strategy <em>almost</em> maintains the semantics. * Repeatable read isolation is compromised in the case of concurrent writes. * This is an "asynchronous" concurrency strategy.<br> * <br> * If this strategy is used in a cluster, the underlying cache implementation * must support distributed hard locks (which are held only momentarily). This * strategy also assumes that the underlying cache implementation does not do * asynchronous replication and that state has been fully replicated as soon * as the lock is released. * * @see NonstrictReadWriteCache for a faster algorithm * @see CacheConcurrencyStrategy */ public class ReadWriteCache implements CacheConcurrencyStrategy { private static final Logger log = LoggerFactory.getLogger(ReadWriteCache.class); private Cache cache; private int nextLockId; public ReadWriteCache() {} public void setCache(Cache cache) { this.cache=cache; } public Cache getCache() { return cache; } public String getRegionName() { return cache.getRegionName(); } /** * Generate an id for a new lock. Uniqueness per cache instance is very * desirable but not absolutely critical. Must be called from one of the * synchronized methods of this class. */ private int nextLockId() { if (nextLockId==Integer.MAX_VALUE) nextLockId = Integer.MIN_VALUE; return nextLockId++; } /** * Do not return an item whose timestamp is later than the current * transaction timestamp. (Otherwise we might compromise repeatable * read unnecessarily.) Do not return an item which is soft-locked. * Always go straight to the database instead.<br> * <br> * Note that since reading an item from that cache does not actually * go to the database, it is possible to see a kind of phantom read * due to the underlying row being updated after we have read it * from the cache. This would not be possible in a lock-based * implementation of repeatable read isolation. It is also possible * to overwrite changes made and committed by another transaction * after the current transaction read the item from the cache. This * problem would be caught by the update-time version-checking, if * the data is versioned or timestamped. */ public synchronized Object get(Object key, long txTimestamp) throws CacheException { if ( log.isTraceEnabled() ) log.trace("Cache lookup: " + key); /*try { cache.lock(key);*/ Lockable lockable = (Lockable) cache.get(key); boolean gettable = lockable!=null && lockable.isGettable(txTimestamp); if (gettable) { if ( log.isTraceEnabled() ) log.trace("Cache hit: " + key); return ( (Item) lockable ).getValue(); } else { if ( log.isTraceEnabled() ) { if (lockable==null) { log.trace("Cache miss: " + key); } else { log.trace("Cached item was locked: " + key); } } return null; } /*} finally { cache.unlock(key); }*/ } /** * Stop any other transactions reading or writing this item to/from * the cache. Send them straight to the database instead. (The lock * does time out eventually.) This implementation tracks concurrent * locks of transactions which simultaneously attempt to write to an * item. */ public synchronized SoftLock lock(Object key, Object version) throws CacheException { if ( log.isTraceEnabled() ) log.trace("Invalidating: " + key); try { cache.lock(key); Lockable lockable = (Lockable) cache.get(key); long timeout = cache.nextTimestamp() + cache.getTimeout(); final Lock lock = (lockable==null) ? new Lock( timeout, nextLockId(), version ) : lockable.lock( timeout, nextLockId() ); cache.update(key, lock); return lock; } finally { cache.unlock(key); } } /** * Do not add an item to the cache unless the current transaction * timestamp is later than the timestamp at which the item was * invalidated. (Otherwise, a stale item might be re-added if the * database is operating in repeatable read isolation mode.) * For versioned data, don't add the item unless it is the later * version. */ public synchronized boolean put( Object key, Object value, long txTimestamp, Object version, Comparator versionComparator, boolean minimalPut) throws CacheException { if ( log.isTraceEnabled() ) log.trace("Caching: " + key); try { cache.lock(key); Lockable lockable = (Lockable) cache.get(key); boolean puttable = lockable==null || lockable.isPuttable(txTimestamp, version, versionComparator); if (puttable) { cache.put( key, new Item( value, version, cache.nextTimestamp() ) ); if ( log.isTraceEnabled() ) log.trace("Cached: " + key); return true; } else { if ( log.isTraceEnabled() ) { if ( lockable.isLock() ) { log.trace("Item was locked: " + key); } else { log.trace("Item was already cached: " + key); } } return false; } } finally { cache.unlock(key); } } /** * decrement a lock and put it back in the cache */ private void decrementLock(Object key, Lock lock) throws CacheException { //decrement the lock lock.unlock( cache.nextTimestamp() ); cache.update(key, lock); } /** * Release the soft lock on the item. Other transactions may now * re-cache the item (assuming that no other transaction holds a * simultaneous lock). */ public synchronized void release(Object key, SoftLock clientLock) throws CacheException { if ( log.isTraceEnabled() ) log.trace("Releasing: " + key); try { cache.lock(key); Lockable lockable = (Lockable) cache.get(key); if ( isUnlockable(clientLock, lockable) ) { decrementLock(key, (Lock) lockable); } else { handleLockExpiry(key); } } finally { cache.unlock(key); } } void handleLockExpiry(Object key) throws CacheException { log.warn("An item was expired by the cache while it was locked (increase your cache timeout): " + key); long ts = cache.nextTimestamp() + cache.getTimeout(); // create new lock that times out immediately Lock lock = new Lock( ts, nextLockId(), null ); lock.unlock(ts); cache.update(key, lock); } public void clear() throws CacheException { cache.clear(); } public void remove(Object key) throws CacheException { cache.remove(key); } public void destroy() { try { cache.destroy(); } catch (Exception e) { log.warn("could not destroy cache", e); } } /** * Re-cache the updated state, if and only if there there are * no other concurrent soft locks. Release our lock. */ public synchronized boolean afterUpdate(Object key, Object value, Object version, SoftLock clientLock) throws CacheException { if ( log.isTraceEnabled() ) log.trace("Updating: " + key); try { cache.lock(key); Lockable lockable = (Lockable) cache.get(key); if ( isUnlockable(clientLock, lockable) ) { Lock lock = (Lock) lockable; if ( lock.wasLockedConcurrently() ) { // just decrement the lock, don't recache // (we don't know which transaction won) decrementLock(key, lock); return false; } else { //recache the updated state cache.update( key, new Item( value, version, cache.nextTimestamp() ) ); if ( log.isTraceEnabled() ) log.trace("Updated: " + key); return true; } } else { handleLockExpiry(key); return false; } } finally { cache.unlock(key); } } /** * Add the new item to the cache, checking that no other transaction has * accessed the item. */ public synchronized boolean afterInsert(Object key, Object value, Object version) throws CacheException { if ( log.isTraceEnabled() ) log.trace("Inserting: " + key); try { cache.lock(key); Lockable lockable = (Lockable) cache.get(key); if (lockable==null) { cache.update( key, new Item( value, version, cache.nextTimestamp() ) ); if ( log.isTraceEnabled() ) log.trace("Inserted: " + key); return true; } else { return false; } } finally { cache.unlock(key); } } /** * Do nothing. */ public void evict(Object key) throws CacheException { // noop } /** * Do nothing. */ public boolean insert(Object key, Object value, Object currentVersion) { return false; } /** * Do nothing. */ public boolean update(Object key, Object value, Object currentVersion, Object previousVersion) { return false; } /** * Is the client's lock commensurate with the item in the cache? * If it is not, we know that the cache expired the original * lock. */ private boolean isUnlockable(SoftLock clientLock, Lockable myLock) throws CacheException { //null clientLock is remotely possible but will never happen in practice return myLock!=null && myLock.isLock() && clientLock!=null && ( (Lock) clientLock ).getId()==( (Lock) myLock ).getId(); } public static interface Lockable { public Lock lock(long timeout, int id); public boolean isLock(); public boolean isGettable(long txTimestamp); public boolean isPuttable(long txTimestamp, Object newVersion, Comparator comparator); } /** * An item of cached data, timestamped with the time it was cached,. * @see ReadWriteCache */ public static final class Item implements Serializable, Lockable { private final long freshTimestamp; private final Object value; private final Object version; public Item(Object value, Object version, long currentTimestamp) { this.value = value; this.version = version; freshTimestamp = currentTimestamp; } /** * The timestamp on the cached data */ public long getFreshTimestamp() { return freshTimestamp; } /** * The actual cached data */ public Object getValue() { return value; } /** * Lock the item */ public Lock lock(long timeout, int id) { return new Lock(timeout, id, version); } /** * Not a lock! */ public boolean isLock() { return false; } /** * Is this item visible to the timestamped * transaction? */ public boolean isGettable(long txTimestamp) { return freshTimestamp < txTimestamp; } /** * Don't overwite already cached items */ public boolean isPuttable(long txTimestamp, Object newVersion, Comparator comparator) { // we really could refresh the item if it // is not a lock, but it might be slower //return freshTimestamp < txTimestamp return version!=null && comparator.compare(version, newVersion) < 0; } public String toString() { return "Item{version=" + version + ",freshTimestamp=" + freshTimestamp; } } /** * A soft lock which supports concurrent locking, * timestamped with the time it was released * @author Gavin King */ public static final class Lock implements Serializable, Lockable, SoftLock { private long unlockTimestamp = -1; private int multiplicity = 1; private boolean concurrentLock = false; private long timeout; private final int id; private final Object version; public Lock(long timeout, int id, Object version) { this.timeout = timeout; this.id = id; this.version = version; } public long getUnlockTimestamp() { return unlockTimestamp; } /** * Increment the lock, setting the * new lock timeout */ public Lock lock(long timeout, int id) { concurrentLock = true; multiplicity++; this.timeout = timeout; return this; } /** * Decrement the lock, setting the unlock * timestamp if now unlocked * @param currentTimestamp */ public void unlock(long currentTimestamp) { if ( --multiplicity == 0 ) { unlockTimestamp = currentTimestamp; } } /** * Can the timestamped transaction re-cache this * locked item now? */ public boolean isPuttable(long txTimestamp, Object newVersion, Comparator comparator) { if (timeout < txTimestamp) return true; if (multiplicity>0) return false; return version==null ? unlockTimestamp < txTimestamp : comparator.compare(version, newVersion) < 0; //by requiring <, we rely on lock timeout in the case of an unsuccessful update! } /** * Was this lock held concurrently by multiple * transactions? */ public boolean wasLockedConcurrently() { return concurrentLock; } /** * Yes, this is a lock */ public boolean isLock() { return true; } /** * locks are not returned to the client! */ public boolean isGettable(long txTimestamp) { return false; } public int getId() { return id; } public String toString() { return "Lock{id=" + id + ",version=" + version + ",multiplicity=" + multiplicity + ",unlockTimestamp=" + unlockTimestamp; } } public String toString() { return cache + "(read-write)"; } }

The table below shows all metrics for ReadWriteCache.java.

MetricValueDescription
BLOCKS70.00Number of blocks
BLOCK_COMMENT30.00Number of block comment lines
COMMENTS173.00Comment lines
COMMENT_DENSITY 0.80Comment density
COMPARISONS42.00Number of comparison operators
CYCLOMATIC76.00Cyclomatic complexity
DECL_COMMENTS28.00Comments in declarations
DOC_COMMENT133.00Number of javadoc comment lines
ELOC217.00Effective lines of code
EXEC_COMMENTS 9.00Comments in executable code
EXITS29.00Procedure exits
FUNCTIONS43.00Number of function declarations
HALSTEAD_DIFFICULTY67.60Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY135.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 1.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 0.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
JAVA003413.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 1.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 0.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 2.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
JAVA0108 4.00JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0109 0.00JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA011020.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 9.00JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
JAVA0116 0.00JAVA0116 Missing javadoc: field 'field'
JAVA0117 9.00JAVA0117 Missing javadoc: method 'method'
JAVA0118 1.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
JAVA012612.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 1.00JAVA0136 N methods defined in class (maximum: M)
JAVA0137 0.00JAVA0137 Non-abstract class missing constructor
JAVA0138 1.00JAVA0138 N parameters defined for method (maximum: M)
JAVA0139 0.00JAVA0139 Definition of main other than public static void main(java.lang.String[])
JAVA0141 4.00JAVA0141 Unnecessary modifier for method in interface
JAVA0143 6.00JAVA0143 Synchronized method
JAVA0144 1.00JAVA0144 Line exceeds maximum M characters
JAVA0145920.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 1.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 2.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 1.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 1.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
LINES531.00Number of lines in the source file
LINE_COMMENT10.00Number of line comments
LOC289.00Lines of code
LOGICAL_LINES122.00Number of statements
LOOPS 0.00Number of loops
NEST_DEPTH 5.00Maximum nesting depth
OPERANDS579.00Number of operands
OPERATORS1151.00Number of operators
PARAMS59.00Number of formal parameter declarations
PROGRAM_LENGTH1730.00Halstead program length
PROGRAM_VOCAB243.00Halstead program vocabulary
PROGRAM_VOLUME 0.00Halstead program volume
RETURNS76.00Number of return points from functions
SIZE14163.00Size of the file in bytes
UNIQUE_OPERANDS197.00Number of unique operands
UNIQUE_OPERATORS46.00Number of unique operators
WHITESPACE69.00Number of whitespace lines