NativeBigInteger.java

Index Score
net.i2p.util
Freenet

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
JAVA0068JAVA0068 Modifiers not declared in recommended order
JAVA0267JAVA0267 Use of System.err
JAVA0144JAVA0144 Line exceeds maximum M characters
JAVA0170JAVA0170 Caught exception not derived from java.lang.Exception
RETURNSNumber of return points from functions
CYCLOMATICCyclomatic complexity
SIZESize of the file in bytes
JAVA0177JAVA0177 Variable declaration missing initializer
DOC_COMMENTNumber of javadoc comment lines
JAVA0108JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
INTERFACE_COMPLEXITYInterface complexity
EXITSProcedure exits
JAVA0117JAVA0117 Missing javadoc: method 'method'
PROGRAM_VOCABHalstead program vocabulary
JAVA0049JAVA0049 Nested block at depth N (maximum: M)
UNIQUE_OPERANDSNumber of unique operands
NEST_DEPTHMaximum nesting depth
JAVA0150JAVA0150 java.lang.Error (or subclass) thrown
OPERATORSNumber of operators
ELOCEffective lines of code
LOGICAL_LINESNumber of statements
JAVA0008JAVA0008 Empty catch block
JAVA0166JAVA0166 Generic exception caught
UNIQUE_OPERATORSNumber of unique operators
COMPARISONSNumber of comparison operators
PROGRAM_LENGTHHalstead program length
PROGRAM_VOLUMEHalstead program volume
JAVA0136JAVA0136 N methods defined in class (maximum: M)
COMMENTSComment lines
JAVA0110JAVA0110 Incorrect javadoc: no @return tag
LOCLines of code
LINESNumber of lines in the source file
LOOPSNumber of loops
WHITESPACENumber of whitespace lines
BLOCKSNumber of blocks
LINE_COMMENTNumber of line comments
package net.i2p.util; /* * free (adj.): unencumbered; not under the control of others * Written by jrandom in 2003 and released into the public domain * with no warranty of any kind, either expressed or implied. * It probably won't make your computer catch on fire, or eat * your children, but it might. Use at your own risk. * */ import java.math.BigInteger; import java.util.Random; import java.net.URL; import java.io.FileOutputStream; import java.io.InputStream; import java.io.IOException; import java.io.FileNotFoundException; import java.io.File; import freenet.support.HexUtil; import freenet.support.Logger; import freenet.support.CPUInformation.AMDCPUInfo; import freenet.support.CPUInformation.CPUID; import freenet.support.CPUInformation.CPUInfo; import freenet.support.CPUInformation.IntelCPUInfo; import freenet.support.CPUInformation.UnknownCPUException; import freenet.support.io.Closer; /** * <p>BigInteger that takes advantage of the jbigi library for the modPow operation, * which accounts for a massive segment of the processing cost of asymmetric * crypto. It also takes advantage of the jbigi library for converting a BigInteger * value to a double. Sun's implementation of the 'doubleValue()' method is _very_ lousy. * * The jbigi library itself is basically just a JNI wrapper around the * GMP library - a collection of insanely efficient routines for dealing with * big numbers.</p> * * There are three environmental properties for configuring this component: <ul> * <li><b>jbigi.enable</b>: whether to use the native library (defaults to "true")</li> * <li><b>jbigi.impl</b>: select which resource to use as the native implementation</li> * <li><b>jbigi.ref</b>: the file specified in this parameter may contain a resource * name to override jbigi.impl (defaults to "jbigi.cfg")</li> * </ul> * * <p>If jbigi.enable is set to false, this class won't even attempt to use the * native library, but if it is set to true (or is not specified), it will first * check the platform specific library path for the "jbigi" library, as defined by * {@link Runtime#loadLibrary} - e.g. C:\windows\jbigi.dll or /lib/libjbigi.so. * If that fails, it reviews the jbigi.impl environment property - if that is set, * it checks all of the components in the CLASSPATH for the file specified and * attempts to load it as the native library. If jbigi.impl is not set, if there * is no matching resource, or if that resource is not a valid OS/architecture * specific library, the NativeBigInteger will revert to using the pure java * implementation.</p> * * <p>That means <b>NativeBigInteger will not attempt to guess the correct * platform/OS/whatever</b> - applications using this class should define that * property prior to <i>referencing</i> the NativeBigInteger (or before loading * the JVM, of course). Alternately, people with custom built jbigi implementations * in their OS's standard search path (LD_LIBRARY_PATH, etc) needn't bother.</p> * * <p>One way to deploy the native library is to create a jbigi.jar file containing * all of the native implementations with filenames such as "win-athlon", "linux-p2", * "freebsd-sparcv4", where those files are the OS specific libraries (the contents of * the DLL or .so file built for those OSes / architectures). The user would then * simply specify -Djbigi.impl=win-athlon and this component would pick up that * library.</p> * * <p>Another way is to create a seperate jbigi.jar file for each platform containing * one file - "native", where that file is the OS / architecture specific library * implementation, as above. This way the user would download the correct jbigi.jar * (and not all of the libraries for platforms/OSes they don't need) and would specify * -Djbigi.impl=native.</p> * * <p>Running this class by itself does a basic unit test and benchmarks the * NativeBigInteger.modPow/doubleValue vs. the BigInteger.modPow/doubleValue by running a 2Kbit op 100 * times. At the end of each test, if the native implementation is loaded this will output * something like:</p> * <pre> * native run time: 6090ms (60ms each) * java run time: 68067ms (673ms each) * native = 8.947066860593239% of pure java time * </pre> * * <p>If the native implementation is not loaded, it will start by saying:</p> * <pre> * WARN: Native BigInteger library jbigi not loaded - using pure java * </pre> * <p>Then go on to run the test, finally outputting:</p> * <pre> * java run time: 64653ms (640ms each) * However, we couldn't load the native library, so this doesn't test much * </pre> * */ public class NativeBigInteger extends BigInteger { /** did we load the native lib correctly? */ private static boolean _nativeOk = false; /** * do we want to dump some basic success/failure info to stderr during * initialization? this would otherwise use the Log component, but this makes * it easier for other systems to reuse this class */ private static final boolean _doLog = true; private final static String JBIGI_OPTIMIZATION_K6 = "k6"; private final static String JBIGI_OPTIMIZATION_K6_2 = "k62"; private final static String JBIGI_OPTIMIZATION_K6_3 = "k63"; private final static String JBIGI_OPTIMIZATION_ATHLON = "athlon"; private final static String JBIGI_OPTIMIZATION_X86_64 = "x86_64"; private final static String JBIGI_OPTIMIZATION_X86_64_32 = "x86_64_32"; private final static String JBIGI_OPTIMIZATION_PENTIUM = "pentium"; private final static String JBIGI_OPTIMIZATION_PENTIUMMMX = "pentiummmx"; private final static String JBIGI_OPTIMIZATION_PENTIUM2 = "pentium2"; private final static String JBIGI_OPTIMIZATION_PENTIUM3 = "pentium3"; private final static String JBIGI_OPTIMIZATION_PENTIUM4 = "pentium4"; private final static String JBIGI_OPTIMIZATION_PPC = "ppc"; private final static String sCPUType; //The CPU Type to optimize for (one of the above strings) private static final long serialVersionUID = 0xc5392a97bb283dd2L; static { sCPUType = resolveCPUType(); loadNative(); } /** Tries to resolve the best type of CPU that we have an optimized jbigi-dll/so for. * @return A string containing the CPU-type or null if CPU type is unknown */ private static String resolveCPUType() { try { if(System.getProperty("os.arch").toLowerCase().matches("(i?[x0-9]86_64|amd64)")) return JBIGI_OPTIMIZATION_X86_64; else if(System.getProperty("os.arch").toLowerCase().matches("(ppc)")) { System.out.println("Detected PowerPC!"); return JBIGI_OPTIMIZATION_PPC; } else { CPUInfo c = CPUID.getInfo(); if(c instanceof AMDCPUInfo) { AMDCPUInfo amdcpu = (AMDCPUInfo) c; if(amdcpu.IsAthlon64Compatible()) return JBIGI_OPTIMIZATION_X86_64_32; if(amdcpu.IsAthlonCompatible()) return JBIGI_OPTIMIZATION_ATHLON; if(amdcpu.IsK6_3_Compatible()) return JBIGI_OPTIMIZATION_K6_3; if(amdcpu.IsK6_2_Compatible()) return JBIGI_OPTIMIZATION_K6_2; if(amdcpu.IsK6Compatible()) return JBIGI_OPTIMIZATION_K6; } else if(c instanceof IntelCPUInfo) { IntelCPUInfo intelcpu = (IntelCPUInfo) c; if(intelcpu.IsPentium4Compatible()) return JBIGI_OPTIMIZATION_PENTIUM4; if(intelcpu.IsPentium3Compatible()) return JBIGI_OPTIMIZATION_PENTIUM3; if(intelcpu.IsPentium2Compatible()) return JBIGI_OPTIMIZATION_PENTIUM2; if(intelcpu.IsPentiumMMXCompatible()) return JBIGI_OPTIMIZATION_PENTIUMMMX; if(intelcpu.IsPentiumCompatible()) return JBIGI_OPTIMIZATION_PENTIUM; } } return null; } catch(UnknownCPUException e) { return null; //TODO: Log something here maybe.. } } /** * calculate (base ^ exponent) % modulus. * * @param base * big endian twos complement representation of the base (but it must be positive) * @param exponent * big endian twos complement representation of the exponent * @param modulus * big endian twos complement representation of the modulus * @return big endian twos complement representation of (base ^ exponent) % modulus */ public native static byte[] nativeModPow(byte base[], byte exponent[], byte modulus[]); /** * Converts a BigInteger byte-array to a 'double' * @param ba Big endian twos complement representation of the BigInteger to convert to a double * @return The plain double-value represented by 'ba' */ public native static double nativeDoubleValue(byte ba[]); private byte[] cachedBa = null; public NativeBigInteger(byte val[]) { super(val); // Takes up too much RAM // int targetLength = bitLength() / 8 + 1; // if(val.length == targetLength) // cachedBa = val; } public NativeBigInteger(int signum, byte magnitude[]) { super(signum, magnitude); } public NativeBigInteger(int bitlen, int certainty, Random rnd) { super(bitlen, certainty, rnd); } public NativeBigInteger(int numbits, Random rnd) { super(numbits, rnd); } public NativeBigInteger(String val) { super(val); } public NativeBigInteger(String val, int radix) { super(val, radix); } /**Creates a new NativeBigInteger with the same value * as the supplied BigInteger. Warning!, not very efficent */ public NativeBigInteger(BigInteger integer) { //Now, why doesn't sun provide a constructor //like this one in BigInteger? this(integer.toByteArray()); } public BigInteger modPow(BigInteger exponent, BigInteger m) { if(_nativeOk) return new NativeBigInteger(nativeModPow(toByteArray(), exponent.toByteArray(), m.toByteArray())); else return new NativeBigInteger(super.modPow(exponent, m)); } public byte[] toByteArray() { if(cachedBa == null) //Since we are immutable it is safe to never update the cached ba after it has initially been generated cachedBa = super.toByteArray(); return cachedBa; } public String toString(int radix) { if(radix == 16) return toHexString(); return super.toString(radix); } public String toHexString() { byte[] buf = toByteArray(); return HexUtil.bytesToHex(buf); } public double doubleValue() { if(_nativeOk) return nativeDoubleValue(toByteArray()); else return super.doubleValue(); } /** * * @return True iff native methods will be used by this class */ public static boolean isNative() { return _nativeOk; } /** * <p>Do whatever we can to load up the native library backing this BigInteger's native methods. * If it can find a custom built jbigi.dll / libjbigi.so, it'll use that. Otherwise * it'll try to look in the classpath for the correct library (see loadFromResource). * If the user specifies -Djbigi.enable=false it'll skip all of this.</p> * */ private static final void loadNative() { try { String wantedProp = System.getProperty("jbigi.enable", "true"); boolean wantNative = "true".equalsIgnoreCase(wantedProp); if(wantNative) { boolean loaded = loadFromResource(true); if(loaded) { _nativeOk = true; if(_doLog) System.err.println("INFO: Optimized native BigInteger library '" + getResourceName(true) + "' loaded from resource"); } else { loaded = loadGeneric(true); if(loaded) { _nativeOk = true; if(_doLog) System.err.println("INFO: Optimized native BigInteger library '" + getMiddleName(true) + "' loaded from somewhere in the path"); } else { loaded = loadFromResource(false); if(loaded) { _nativeOk = true; if(_doLog) System.err.println("INFO: Non-optimized native BigInteger library '" + getResourceName(false) + "' loaded from resource"); } else { loaded = loadGeneric(false); if(loaded) { _nativeOk = true; if(_doLog) System.err.println("INFO: Non-optimized native BigInteger library '" + getMiddleName(false) + "' loaded from somewhere in the path"); } else _nativeOk = false; } } } } if(_doLog && !_nativeOk) System.err.println("INFO: Native BigInteger library jbigi not loaded - using pure java"); } catch(Throwable e) { if(_doLog) System.err.println("INFO: Native BigInteger library jbigi not loaded, reason: '" + e.getMessage() + "' - using pure java"); } } /** * <p>Try loading it from an explictly build jbigi.dll / libjbigi.so first, before * looking into a jbigi.jar for any other libraries.</p> * * @return true if it was loaded successfully, else false * */ private static final boolean loadGeneric(boolean optimized) { try { String name = getMiddleName(optimized); if(name == null) return false; System.loadLibrary(name); return true; } catch(UnsatisfiedLinkError ule) { return false; } } /** * A helper function to make loading the native library easier. * @param f The File to which to write the library * @param URL The URL of the resource * @return True is the library was loaded, false on error * @throws FileNotFoundException If the library could not be read from the reference * @throws UnsatisfiedLinkError If and only if the library is incompatible with this system */ private static final boolean tryLoadResource(File f, URL resource) throws FileNotFoundException, UnsatisfiedLinkError { InputStream is; try { is = resource.openStream(); } catch(IOException e) { f.delete(); throw new FileNotFoundException(); } FileOutputStream fos = null; try { f.deleteOnExit(); fos = new FileOutputStream(f); byte[] buf = new byte[4096 * 1024]; int read; while((read = is.read(buf)) > 0) { fos.write(buf, 0, read); } fos.close(); fos = null; System.load(f.getAbsolutePath()); return true; } catch(IOException e) { } catch(UnsatisfiedLinkError ule) { // likely to be "noexec" if(ule.toString().toLowerCase().indexOf("not permitted") == -1) throw ule; } finally { Closer.close(fos); f.delete(); } return false; } /** * <p>Check all of the jars in the classpath for the file specified by the * environmental property "jbigi.impl" and load it as the native library * implementation. For instance, a windows user on a p4 would define * -Djbigi.impl=win-686 if there is a jbigi.jar in the classpath containing the * files "win-686", "win-athlon", "freebsd-p4", "linux-p3", where each * of those files contain the correct binary file for a native library (e.g. * windows DLL, or a *nix .so). </p> * * <p>This is a pretty ugly hack, using the general technique illustrated by the * onion FEC libraries. It works by pulling the resource, writing out the * byte stream to a temporary file, loading the native library from that file, * then deleting the file.</p> * * @return true if it was loaded successfully, else false * */ private static final boolean loadFromResource(boolean optimized) { String resourceName = getResourceName(optimized); if(resourceName == null) return false; URL resource = NativeBigInteger.class.getClassLoader().getResource(resourceName); if(resource == null) { if(_doLog) System.err.println("NOTICE: Resource name [" + getResourceName(true) + "] was not found"); return false; } File temp = null; try { try { temp = File.createTempFile("jbigi", "lib.tmp"); if(tryLoadResource(temp, resource)) return true; } catch(IOException e) { } finally { if(temp != null) temp.delete(); } Logger.error(NativeBigInteger.class, "Can't load from " + System.getProperty("java.io.tmpdir")); System.err.println("Can't load from " + System.getProperty("java.io.tmpdir")); temp = new File("jbigi-lib.tmp"); if(tryLoadResource(temp, resource)) return true; } catch(Exception fnf) { Logger.error(NativeBigInteger.class, "Error reading jbigi resource", fnf); System.err.println("Error reading jbigi resource"); } catch(UnsatisfiedLinkError ule) { Logger.error(NativeBigInteger.class, "Library " + resourceName + " is not appropriate for this system."); System.err.println("Library " + resourceName + " is not appropriate for this system."); } finally { if(temp != null) temp.delete(); } return false; } private static final String getResourceName(boolean optimized) { String pname = NativeBigInteger.class.getPackage().getName().replace('.', '/'); String pref = getLibraryPrefix(); String middle = getMiddleName(optimized); String suff = getLibrarySuffix(); if((pref == null) || (middle == null) || (suff == null)) return null; return pname + '/' + pref + middle + '.' + suff; } private static final String getMiddleName(boolean optimized) { String sAppend; if(optimized) if(sCPUType == null) return null; else sAppend = '-' + sCPUType; else sAppend = "-none"; boolean isWindows = (System.getProperty("os.name").toLowerCase().indexOf("windows") != -1); boolean isLinux = (System.getProperty("os.name").toLowerCase().indexOf("linux") != -1); boolean isFreebsd = (System.getProperty("os.name").toLowerCase().indexOf("freebsd") != -1); boolean isMacOS = (System.getProperty("os.name").toLowerCase().indexOf("mac os x") != -1); if(isWindows) return "jbigi-windows" + sAppend; // The convention on Windows if(isLinux) return "jbigi-linux" + sAppend; // The convention on linux... if(isFreebsd) return "jbigi-freebsd" + sAppend; // The convention on freebsd... if(isMacOS) return "jbigi-osx" + sAppend; // The convention on Mac OS X... throw new RuntimeException("Dont know jbigi library name for os type '" + System.getProperty("os.name") + '\''); } private static final String getLibrarySuffix() { boolean isWindows = System.getProperty("os.name").toLowerCase().indexOf("windows") != -1; boolean isMacOS = (System.getProperty("os.name").toLowerCase().indexOf("mac os x") != -1); if(isWindows) return "dll"; else if(isMacOS) return "jnilib"; else return "so"; } private static final String getLibraryPrefix() { boolean isWindows = System.getProperty("os.name").toLowerCase().indexOf("windows") != -1; if(isWindows) return ""; else return "lib"; } }

The table below shows all metrics for NativeBigInteger.java.

MetricValueDescription
BLOCKS56.00Number of blocks
BLOCK_COMMENT 8.00Number of block comment lines
COMMENTS154.00Comment lines
COMMENT_DENSITY 0.59Comment density
COMPARISONS43.00Number of comparison operators
CYCLOMATIC84.00Cyclomatic complexity
DECL_COMMENTS13.00Comments in declarations
DOC_COMMENT139.00Number of javadoc comment lines
ELOC263.00Effective lines of code
EXEC_COMMENTS 6.00Comments in executable code
EXITS53.00Procedure exits
FUNCTIONS24.00Number of function declarations
HALSTEAD_DIFFICULTY64.48Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY79.00Interface complexity
JAVA0001 1.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 2.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 1.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
JAVA003446.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 2.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 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
JAVA006815.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 0.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 1.00JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA0110 0.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 7.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 1.00JAVA0126 Method declares unchecked exception in throws
JAVA0128 0.00JAVA0128 Public constructor in non-public class
JAVA0130 0.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 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
JAVA0143 0.00JAVA0143 Synchronized method
JAVA0144 5.00JAVA0144 Line exceeds maximum M characters
JAVA0145895.00JAVA0145 Tab character used in source file
JAVA0150 1.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 2.00JAVA0166 Generic exception caught
JAVA0167 0.00JAVA0167 ThreadDeath not rethrown
JAVA0169 0.00JAVA0169 Unnecessary catch block: exception 'exception'
JAVA0170 4.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 3.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 0.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 1.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 1.00JAVA0266 Use of System.out
JAVA026710.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
LINES489.00Number of lines in the source file
LINE_COMMENT 7.00Number of line comments
LOC302.00Lines of code
LOGICAL_LINES160.00Number of statements
LOOPS 1.00Number of loops
NEST_DEPTH 7.00Maximum nesting depth
OPERANDS619.00Number of operands
OPERATORS1385.00Number of operators
PARAMS25.00Number of formal parameter declarations
PROGRAM_LENGTH2004.00Halstead program length
PROGRAM_VOCAB290.00Halstead program vocabulary
PROGRAM_VOLUME 0.00Halstead program volume
RETURNS54.00Number of return points from functions
SIZE18215.00Size of the file in bytes
UNIQUE_OPERANDS240.00Number of unique operands
UNIQUE_OPERATORS50.00Number of unique operators
WHITESPACE33.00Number of whitespace lines