Java Hints

There are 261 total hints/inspections, 0 of them in current development version only.

There are 26 total suggestions/actions, 0 of them in current development version only.

Contents

APIs

Be aware that this API will be optional in Java EE 7 platform.
Warn user about usage of APIs from technologies which will be made optional in Java EE 7 specification. These APIs are not deprecated and can be used but because they will be optional they may or may not be available in future Java EE 7 compliant platforms. Since NetBeans 7.0
Exporting non-public type through public API
Checks that return types and parameter types of all public methods and all types of public fields are publicly available from other packages. Having private or package private types in a package API is useless. In NetBeans 6.8 or earlier
Utility class with visible constructor[ Disabled by default ]
Finds out classes containing only static elements with public or protected constructors. In NetBeans 6.8 or earlier
Utility class without constructor[ Disabled by default ]
Finds out classes containing only static elements and still being instantiable. In NetBeans 6.8 or earlier

Abstraction

Type cast is too strong[ Disabled by default ]
Reports type casts, which are too strict and casting to a more general type would be sufficient for the actual expression. Sometimes, an instance is casted to a specific subtype, but methods invoked or fields used from the casted instance are actually defined by some supertype. In that case cast to too specific type introduces an unnecessary coupling to the code and limits its extensibility. <p/>This inspection will suggest to use the most general type which would satisfy the expression's needs. Since NetBeans 7.4

Assignment Issues

Assignment replaceable with operator-assignment[ Disabled by default ]
Reports instances of assignment operations which can be replaced by operator-assignment. Code using operator-assignment may be clearer, and theoretically more performant. Since NetBeans 6.9
Assignment to catch-block parameter[ Disabled by default ]
Reports any instances of assignment to variable declared as a catch block parameter. While occasionally intended, this construct can be confusing. Since NetBeans 6.9
Assignment to for-loop parameter[ Disabled by default ]
Reports any instances of assignment to variable declared in a for statement in the body of that statement. It also reports any attempt to increment or decrement the variable. While occasionally intended, this construct can be extremely confusing, and is often the result of a typo. Since NetBeans 6.9
Assignment to method parameter[ Disabled by default ]
Reports any instances of assignment to a variable declared as a method parameter. It also reports any attempt to increment or decrement the variable. While occasionally intended, this construct can be extremely confusing, and is often the result of a typo. Since NetBeans 6.9
Nested assignment[ Disabled by default ]
Reports any instances of assignment expressions nested inside other expressions. While admirably terse, such expressions may be confusing, and violate the general design principle that a given construct should do precisely one thing. Since NetBeans 6.9
Value of increment/decrement expression used[ Disabled by default ]
Reports any instances of increment or decrement expressions nested inside other expressions. While admirably terse, such expressions may be confusing, and violate the general design principle that a given construct should do precisely one thing. Since NetBeans 6.9

Bitwise Operations

Incompatible mask
This inspection reports any instances of bitwise mask expressions which are guaranteed to evaluate to false. Expressions checked are of the form (var & constant1) == constant2 or (var | constant1) == constant2, where constant1and constant2 are incompatible bitmask constants. Since NetBeans 6.9
Pointless bitwise expression
This inspection reports any instances of pointless bitwise expressions. Such expressions include anding with zero, oring by zero, and shift by zero. Such expressions may be the result of automated refactorings not completely followed through to completion, and in any case are unlikely to be what the developer intended to do. Since NetBeans 6.9
Shift operation outside of the reasonable range
This inspection reports any instances of shift operations where the value shifted by is constant and outside of the reasonable range. Integer shift operations outside of the range 0..31 and long shift operations outside of therange 0..63 are reported. Shifting by negative or overly large values is almost certainly a coding error. Since NetBeans 6.9

Braces

Do-While Loops Should Use Braces[ Disabled by default ]
Do-While Loops Should Use Braces In NetBeans 6.8 or earlier
For Loops Should Use Braces[ Disabled by default ]
Warns if a for loop does not have its body wrapped in curly braces.
In NetBeans 6.8 or earlier
If-Else Statements Should Use Braces[ Disabled by default ]
If-Else Statements Should Use Braces In NetBeans 6.8 or earlier
While Loops Should Use Braces[ Disabled by default ]
While Loops Should Use Braces In NetBeans 6.8 or earlier

Class Structure

Class may be interface[ Disabled by default ]
Reports any concrete or abstract classes which may be simplified to be interfaces. This occurs if the class has no superclass (other than Object), has no fields declared that are not static, final, and public, and has no methods declared that are not public and abstract, and no inner classes that cannot themselves be interfaces. Since NetBeans 6.9
Final class[ Disabled by default ]
Reports any instances of classes being declared final. Some coding standards discourage final classes. Since NetBeans 6.9
Final method[ Disabled by default ]
Reports any instances of methods being declared final. Some coding standards discourage final classes. Since NetBeans 6.9
Final method in final class[ Disabled by default ]
Reports any instances of methods being declared final in classes that are declared final. This is unnecessary, and may be confusing. Since NetBeans 6.9
Final private method
Reports any instances of methods being declared final and private. As private methods cannot be meaningfully overridden, declaring them final is redundant. Since NetBeans 6.9
Initializer may be static
The initializer does not access any instance variables or methods, it can be static and execute just once, not during each instance creation. Since NetBeans 8.0
Marker interface[ Disabled by default ]
Reports marker interfaces which have no methods or fields. Such interfaces may be confusing, and normally indicate a design failure. Interfaces which extend two or more other interfaces will not be reported. Since NetBeans 6.9
Multiple top-level classes in file[ Disabled by default ]
Reports any instances of multiple top-level classes in a single java file. Putting multiple top-level classes in a file can be confusing, and may degrade the usefulness of various software tools. Since NetBeans 6.9
No-op method in abstract class[ Disabled by default ]
Reports any instances of no-op methods in abstract classes. It is usually a better design to make such methods abstract themselves, so that classes which inherit the methods will not forget to provide their own implementations. Since NetBeans 6.9
Organize members[ Disabled by default ]
Checks whether members order corresponds to the specified code style rules Since NetBeans 7.3
Protected member in final class[ Disabled by default ]
Reports any instances of members being declared protected in classes that are declared final. Such members may be declared private or package-visible instead. Since NetBeans 6.9
Public constructor in non-public class[ Disabled by default ]
Reports all constructors in non-public classes that are declared public. Since NetBeans 6.9

Code Maturity Issues

Obsolete Collection
This inspection reports any uses of java.util.Vector or java.util.Hashtable. While still supported, these classes were made obsolete by the JDK1.2 collection classes, and should probably not be used in new development. Since NetBeans 6.9
Print Stack Trace
This inspection reports any uses Throwable.printStackTrace() without arguments. These are often temporary debugging statements, and should probably be either removed from production code, or replaced by a more robust logging facility. Since NetBeans 6.9
System out / err[ Disabled by default ]
This inspection reports any uses of System.out or System.err. These are often temporary debugging statements, and should probably be either removed from production code, or replaced by a more robust logging facility. Since NetBeans 6.9
Thread Dump Stack
This inspection reports any uses Thread.dumpStack(). These are often temporary debugging statements, and should probably be either removed from production code,or replaced by a more robust logging facility. Since NetBeans 6.9

Empty Statements

'
In NetBeans 6.8 or earlier
Empty statement
Checks for empty statements in blocks usually represented as superfluous semicolon. Since NetBeans 6.9
Empty statement after 'do'
Checks for 'do/while' statements in form
do;
while
. Since NetBeans 6.9
Empty statement after 'for'
Checks for 'for' statements in form
for(...);. Since NetBeans 6.9
Empty statement after 'if/else'[ Disabled by default ]
Checks for 'if/else' statements in form
if(...);
else;
. Since NetBeans 6.9
Empty statement after 'while'
Checks for 'while' statements in form
while(...);. Since NetBeans 6.9

Encapsulation

Access of Private Field of Another Object[ Disabled by default ]
Warns about access of private fields of another objects Since NetBeans 6.9
Assignment to Array Field from Parameter[ Disabled by default ]
Warns about assignment of array into fields Since NetBeans 6.9
Assignment to Collection Field from Parameter[ Disabled by default ]
Warns about assignment of java.util.Collection into fields Since NetBeans 6.9
Assignment to Date or Calendar Field from Parameter[ Disabled by default ]
Warns about assignment of java.util.Date or java.util.Calendar into fields Since NetBeans 6.9
Package Field[ Disabled by default ]
Warns about existence of package visible variables Since NetBeans 6.9
Package Visible Inner Class[ Disabled by default ]
Warns about existence of package visible inner class Since NetBeans 6.9
Protected Field[ Disabled by default ]
Warns about existence of protected variables Since NetBeans 6.9
Protected Inner Class[ Disabled by default ]
Warns about existence of protected visible inner class Since NetBeans 6.9
Public Field[ Disabled by default ]
Warns about existence of public variables Since NetBeans 6.9
Public Inner Class[ Disabled by default ]
Warns about existence of public visible inner class Since NetBeans 6.9
Return of Array Field[ Disabled by default ]
Warns about return of array fields Since NetBeans 6.9
Return of Collection Field[ Disabled by default ]
Warns about return of collection fields Since NetBeans 6.9
Return of Date or Calendar Field[ Disabled by default ]
Warns about return of java.util.Date or java.util.Calendar fields Since NetBeans 6.9

Enterprise Java Beans

@Remote uses value in business interface
If an interface is annotated with @Remote, then value attribute must not be specified. In other words, if value is specified for @Remote, then it must be annotating a class (not an interface). Since NetBeans 7.4
Annotation @PostConstruct
Checks usage of @PostConstruct annotation. Its return value, singularity per class, parameters etc. Since NetBeans 7.4
Asynchronous method invocation
Checks usage of @Asynchronous. Tests whether it's used within supported project and interface type. Since NetBeans 7.4
Bean doesn't implement business interface
It is recommended that a bean class implement its business interface. Since NetBeans 7.4
Inheritance of session beans
A session bean must not extend another session bean. Since NetBeans 7.4
Instantiation replaceable with @EJB injection
Finds instantiations of a bean which can be injected by @EJB annotation Since NetBeans 7.4
Local and Remote business inteface together
The same business interface cannot be both a local and a remote business interface of the bean. Since NetBeans 7.4
Method definition in local and remote interface
When a session bean has remote and local business interfaces, there should not be method common to both of them. Since NetBeans 7.4
Method not exposed in business interface.
Method is not exposed in any business interface. Since NetBeans 7.4
Modifiers of the EJB bean
Checks whether the defined EJB beans have correct modifiers - are public, not final and not abstract. Since NetBeans 7.4
No-arg contructor in the EJB bean
EJB class must have a public or protected no-arg constructor. Since NetBeans 7.4
Persistent timer within EJB Lite
Persistent timer (@Schedule annotation) can't be used in case of EJB 3.2 Lite and timer can't be used at all within EJB 3.1 Lite targeting project. Since NetBeans 7.4
SessionSynchronization implemted by non-SFSB
Only stateful session bean (SFSB) can implement SessionSynchronization interface. Since NetBeans 7.4
Uncomplete LBI Session bean
If a session bean is annotated as @Local, then it must have a local business interface. Since NetBeans 7.4
Uncomplete RBI Session bean
If a session bean is annotated as @Remote, then it must have a remote business interface. Since NetBeans 7.4
WebService must be designated as session bean
If a class is part of ejb-jar and is annotated as @WebService, then it must be designated as a stateless or as a singleton session bean. Since NetBeans 7.4

Error Fixes

Create Field
Settings for Create Field Fix Since NetBeans 6.9
Create Local Variable
Settings for the Create Local Variable error fix Since NetBeans 6.9
Implementation of EJBContainer is missing on project's classpath
Find out whether implementation of EJBContainer necessary for successful execution of unit test is available. Since NetBeans 7.0
Java EE API is missing on project classpath.
Find out whether Java EE API is available on project classpath. Java EE API is necessary for successful test execution. This hint also warns about incorrect usage of javaee-web-api artifact - that artifact is suitable only for compilation but not for test execution because body of all API methods was removed from the bytecode. Since NetBeans 7.0
Surround with try-catch
Settings for the Surround with try-catch error fix Since NetBeans 6.9

Finalization

finalize() called explicitly
Warns about an explicit call of the Object.finalize() Since NetBeans 6.9
finalize() declared
Warns about implementations of Object.finalize() Since NetBeans 6.9
finalize() does not call super.finalize()
Warns about implementations of Object.finalize() which do not call supertype implementation Since NetBeans 6.9
finalize() not declared protected[ Disabled by default ]
Warns about non protected implementations of Object.finalize() Since NetBeans 6.9

General

.equals Method not Checking Type
Implementation of .equals methods not checking the type of the input parameter In NetBeans 6.8 or earlier
Accessing static via reference
Java language allows access to static fields thru instance variables, however this is often misleading and harder to read. In NetBeans 6.8 or earlier
Assignment To Itself
Assignment To Itself In NetBeans 6.8 or earlier
Comparing Strings using == or !=
Checks for usages of == or != operator for comparing Strings.
String comparisons should generally be done using the equals() method. In NetBeans 6.8 or earlier
Field hides another field
Declaration of a field in a class can hide declaration of another field in superclasses. Although possible, this is not very good programming style. In NetBeans 6.8 or earlier
Generate missing hashCode or equals
Checks whether a class which overrides equals method also overrides hashCode. In NetBeans 6.8 or earlier
Local variable hides a field
Declaration of a variable in a method can hide declaration of a field declared in the surrounding class. Although possible, this is not very good programming style. In NetBeans 6.8 or earlier
Redundant conditional statement
Redundant conditional statement Since NetBeans 7.4
Redundant if statement
Redundant if statement Since NetBeans 7.4
Remove Unnecessary Continue Statement
Remove Unnecessary Continue Statement Since NetBeans 7.4
Remove Unnecessary Label in break
Remove Unnecessary Label in break statement Since NetBeans 7.4
Remove Unnecessary Label in continue
Remove Unnecessary Label in continue statement Since NetBeans 7.4
Remove Unnecessary Return Statement
Remove Unnecessary Return Statement Since NetBeans 7.1
Unnecessary Throwable.initCause
Finds invocations of Throwable.initCause which can be replaced with simple constructor invocation. When the "Never alter result of getMessage()" checkbox is unchecked, (IllegalStateException) new IllegalStateException().initCause(ex) will be rewritten to new IllegalStateException(ex), which will alter the value of getMessage(). When the checkbox is checked, the code will become new IllegalStateException(null, ex). Similar rule holds for creating the exception from getMessage() or getLocalizedMessage() of the cause. Since NetBeans 6.9
Use Functional Operations
Use functional operations instead of imperative style loop. Since NetBeans 7.4
Wrong Package
Wrong Package In NetBeans 6.8 or earlier

Imports

Import From The Same Package
Import From The Same Package In NetBeans 6.8 or earlier
Import From java.lang Package
Import From java.lang Package In NetBeans 6.8 or earlier
Import from Excluded
Import from package or class which has been labelled "Excluded" in the Code Completer In NetBeans 6.8 or earlier
Organize imports[ Disabled by default ]
Checks whether import statements correspond to the specified code style rules Since NetBeans 7.1
Star import[ Disabled by default ]
Star import In NetBeans 6.8 or earlier
Unused Import
Unused Import In NetBeans 6.8 or earlier

Initialization

Passing suspicious parameter in the constructor
Using this as parameter can be dangerous in the contructor because the object is not fully initialized. Since NetBeans 6.9
Problematic call in the constructor
Calling methods that can be overridden can be dangerous in the contructor because in the moment when the overridden method is called the object is not fully initialized. Since NetBeans 6.9
Static non-final variable used during initialization
Using static non-final variables can be dangerous in the initialization code because their values may depend on the order of initialization statements Since NetBeans 6.9

JDK Migration Support

AbstractProcessor.getSupportedAnnotationTypes() is overridden
Overriding Processor.getSupportedAnnotationTypes() may lead to unnecessary classloading during development, and may prevent important optimalizations. consider using @javax.annotation.processing.SupportedAnnotationTypes Since NetBeans 7.2
Add @Override Annotation
Add @Override Annotation In NetBeans 6.8 or earlier
Add Underscores[ Disabled by default ]
Proposed to add underscores to integer literals to improve their readability Since NetBeans 7.2
Can Use Diamond
Warns about places where the diamond operator in JDK 7 can be used instead of explicit type parameters Since NetBeans 7.1
Convert to Lambda or Member Reference
Converts anonymous inner classes to lambda expressions or member references Since NetBeans 7.4
Convert to try-with-resources
Converts try finally block to try-with-resources Since NetBeans 7.0
Don't use Annotation as super interface
Despite the compiler permitting such constructs, Annotations should not be used as superinterfaces. In NetBeans 6.8 or earlier
Join catch sections using multicatch
Join catch sections using multicatch Since NetBeans 7.0
Static imports[ Disabled by default ]
Convert method to static import. Feedback to http://www.netbeans.org/issues/show_bug.cgi?id=89258 Since NetBeans 6.9
String.indexOf can be replaced with String.contains
Finds usages of String.indexOf that can be replaced with String.contains Since NetBeans 8.0
Too broad 'catch' clause
Reports catch clauses, which catch a supertype rather than the actually thrown exception type. Such broad catches may provide inappropriate reports or overly general exception handling. <p/>Sometimes the method produces more than one exception type which can be handled by catching their common supertype. "Report common supertypes" option controls whether such situations will be reported. The generic exceptions configured for the Use Specific Catch hint are always reported. Since NetBeans 7.4
Unnecessary boxing
Explicit boxing using e.g. new Integer(x) or Integer.valueOf(x) is not necessary in JDK 5+. This hint detects such situations, and suggest to remove the boxing call. Since NetBeans 8.0
Unnecessary unboxing
Explicit unboxing using e.g. x.intValue() is not necessary under JDK 5+. The hint finds such calls and suggests the removal. Since NetBeans 8.0
Use JDK 5 for-loop
Replaces simple uses of Iterator with a corresponding for-loop. Since NetBeans 7.3
Use specific catch
Converts catch (Throwable) or catch (Exception) to multicatch (when java source level is 7 and above) or to several catch clauses (for earlier Java platforms) catching the exceptions thrown by the try body. The watched exception types can be configured; fully qualified names must be used. Since NetBeans 7.0
Use switch over Strings where possible.
Marks cascades of ifs which can be converted to switch over Strings . Since NetBeans 6.9

Java Code Metrics

Anonymous class has too many methods[ Disabled by default ]
Reports anonymous class with many methods. Anonymous classes typically implement a very simple interface, and should be very simple. It is recommended to create at least named local class, if the anonymous class' complexity grows. Since NetBeans 7.4
Anonymous class is too complex[ Disabled by default ]
Reports anonymous classes, whose cyclomatic complexity exceeds the configured limit. The complexity of a class is computed as a sum of complexities of its methods. Anonymous classes should have far less responsibilities and lower complexity than a regular class Since NetBeans 7.4
Arithmetic expression too complex[ Disabled by default ]
Reports arithmetic expressions, which include more than the defined number of operations. Expression with many operands are harder to read and often could be split into several assignment statements to interim result variables. Since NetBeans 7.4
Class has too many constructors[ Disabled by default ]
Reports classes which define too many constructors. Since NetBeans 7.4
Class has too many fields[ Disabled by default ]
Reports a class which holds too many fields. The state kept by the class is too large and it should be investigated if the state can be split into several state classes, often also separating manipulation methods and reduce the overall class complexity. Since NetBeans 7.4
Class has too many methods[ Disabled by default ]
Reports class, which contains too many methods. The options allows to ignore simple bean property accessors - lazy getters, or setters which fire change events are not considered 'simple'. Implementations of superclass (not implementation of interface methods) abstract methods can be also ignored. Since NetBeans 7.4
Class is too complex[ Disabled by default ]
Reports classes, whose cyclomatic complexity exceeds the configured limit. The complexity of a class is computed as a sum of complexities of its methods. Since NetBeans 7.4
Class is too coupled[ Disabled by default ]
Reports classes which are too coupled (use too many) other types. References to Java system libraries (java.** and javax.**) can be ignored. Since NetBeans 7.4
Constructor declares too many parameters[ Disabled by default ]
Reports constructor that take too many parameters. Constructors typically take more parameters than a regular method, especially when initializing a large object.<p/>Large number of parameters indicate a bad design. It's likely that yet more parameters will be added in the future, so creational patterns like Builder should be considered. Since NetBeans 7.4
Logical expression too complex[ Disabled by default ]
Reports logical expressions, which include more than the defined number of operations. Expression with many operands are harder to read and often could be split into several assignment statements to interim result variables. Since NetBeans 7.4
Method body is too long[ Disabled by default ]
Reports methods, which have too long body. Longer methods require scrolling back and forth, and typically can be refactored into several methods called from a mediating method. Splitting a long method into several named pieces may also help code reuse. Some coding practices even demand that a method should fit a screen size, so it can be easily scanned and understood by the developer. Since NetBeans 7.4
Method declares too many parameters[ Disabled by default ]
Reports method that take too many parameters. Methods with large number of parameters indicate a bad design. It's likely that yet more parameters will be added in the future, so the parameters should be grouped into a Command Object, improving maintenance costs. Alternatively, the method could be refactored into several methods, each doing part of the task and requiring less parameters at input. Since NetBeans 7.4
Method is too complex[ Disabled by default ]
The inspection reports method, whose Cyclomatic Complexity exceeds a configurable value. The Cyclomatic Complexity measures a number of potential branching points (or cycles) in a method. It is believed that methods with high cyclomatic complexity usually do too much and should be split to several, more focused, methods. Such complex methods are also prone to code duplication between their execution paths and are hard to sustain. Usually it is recommended that cyclomatic complexity of a method is 5 or below; less than 10 may be also acceptable for more elaborate algorithms. Since NetBeans 7.4
Method or constructor declares too many exceptions[ Disabled by default ]
Reports methods which declare many exceptions in their throws clause. Method that produce a large number of exception types are hard to use, as the caller must handle all the outcomes or complicate its own declaration with exceptions. The error handling code grows more complex. <p/>The inspection also processes constructors. Since NetBeans 7.4
Method with multiple loops[ Disabled by default ]
Methods that contains multiple loop statements. Since NetBeans 7.4
Method with multiple negations[ Disabled by default ]
Methods with multiple negated expressions (unary ! or !=) are said to confuse readers, true (non-negated) expressions are considered easier to read and understand. Consider to change the logic to use true instead of false values. Since NetBeans 7.4
Method with multiple return points[ Disabled by default ]
Reports methods, which exit at multiple places using return statement. Such methods may be confusing and are harder to refactor. The inspection can ignore conditional guard returns - a return statement, which is the sole statement in an if branch. Optionally, all equals methods can be ignored, as contents of equals is traditionally generated using early returns on type or value mismatch. Since NetBeans 7.4
Too coupled method[ Disabled by default ]
Reports methods which are too coupled - that refer to too many other types. Methods that refer to large number of types are fragile: they tend to fail or require refactoring if the referenced type(s) change. It is also more difficult to move the method which has many dependencies to another module. <p/>References to the method class' itself and its superclasses are ignored. With Ignore dependencies on Java Platform, references to java.** and javax.** classes are also ignored. Since NetBeans 7.4
Too deep nesting[ Disabled by default ]
Reports methods whose bodies contain statements nested too deep. Such methods are less readable, contain indent space and allow less screen space for code reading. Methods can be often refactored and split to improve code readability. Since NetBeans 7.4

Java Persistence API

Check access types for jpa classes
JPA classes need to have consistent access types for fields/properties Since NetBeans 8.0
Default public/protected constructor
JPA classes need to have default public/protected no arg constructor Since NetBeans 8.0
Entity impleents Serializable verification
If an entity instance is to be passed by value as a detached object (e.g., through a remote interface), the entity class must implement the Serializable interface. Since NetBeans 8.0
Entity table name verification
Entity table name must be valid QL intentifier Since NetBeans 8.0
JPQL validation
Parse and find errors in a jpql query Since NetBeans 8.0
Presece of persistence.xml
Check if project with jpa usage contain persistence.xml with persistence unit Since NetBeans 8.0
The IdClass must override equals(Object o) and hashCode() method.
The IdClass must override equals(Object o) and hashCode() method. Since NetBeans 8.0
Verify @IdClass location
Only Entity or MappedSuperclass can use IdClass. Since NetBeans 8.0
Verify IdClass in entity subclass
An entity sub-class cannot have IdClass because it will result in multiple IDs in the entity hierarchy. Since NetBeans 8.0
Verify access level for IdClass
IdClass need to be public Since NetBeans 8.0
Verify attributes of jpa classes
This validation cover nimber of issues like valid column name, valid attribute modifiers, valid basic type, relationships etc Since NetBeans 8.0
Verify combinations of jpa annitations
Some JPA annotations may not be applied to the same element at the same time Since NetBeans 8.0
Verify entity have defined promary key
Id is required for entities Since NetBeans 8.0
Verify entity name is unique
Entity names must not be the same in one persistence unit Since NetBeans 8.0
Verify jpa annotations on accessors
JPA annotations should be applied to getter methods only Since NetBeans 8.0
Verify jpa class is top level class
JPA classes must not be inner classes Since NetBeans 8.0
Verify jpa class isn't final
JPA classes must not be final Since NetBeans 8.0
Verify named query location
Named queries can be defined only on an Entity or MappedSuperclass class. Since NetBeans 8.0

JavaDoc

Create Javadoc
Create Javadoc In NetBeans 6.8 or earlier
Error in Javadoc
Error in Javadoc In NetBeans 6.8 or earlier

JavaServer Faces

@FlowScoped bean in the non-CDI capable project
@FlowScoped bean in the non-CDI capable project Since NetBeans 8.0
Classes of javax.faces.bean are gonna be deprecated
Annotations from the package javax.faces.bean will be deprecated in the next JSF version. CDI and Java EE ones are recommended instead. Since NetBeans 8.0

Logging

Logger declaration is not static final
Each class should have one unique logger. If declared as a field it should be static and final. Since NetBeans 6.9
Multiple loggers
There are several loggers declared for a single class. Since NetBeans 6.9
No loggers[ Disabled by default ]
There is no logger declared for a class. Since NetBeans 6.9
String concatenation in logger
It is not performance efficient to concatenate strings in logger messages. It is better to use a template message with placeholders that are replaced by concrete values only when the message is really going to be logged. Since NetBeans 6.9

Maven

Resolve Missing Class Dependency
Resolve missing class dependency and add to project POM Since NetBeans 6.9

NetBeans Development

Empty cancel() for cancelable tasks[ Disabled by default ]
Warn about empty cancel() methods for cancelable tasks In NetBeans 6.8 or earlier
HelpCtx issues
Warnings about misuse of org.openide.util.HelpCtx. Since NetBeans 7.2
Illegal Use of instanceOf operator[ Disabled by default ]
Show illegal use of instanceof on javax.lang.model.elements, javax.lang.model.type and com.sun.source.tree In NetBeans 6.8 or earlier
Use @NbBundle.Messages
Use @NbBundle.Messages in preference to Bundle.properties plus NbBundle.getMessage(...). Since NetBeans 7.0

Performance

.getClass() replaceable with .class[ Disabled by default ]
Finds instantions of a class directly followed by invocation of .getClass() on the newly constructed object Since NetBeans 6.9
Boxing of already boxed value
Reports boxing of already boxed value. Constructor or valueOf take a primitive parameter, so a boxed value is unboxed first, then boxed again, which may create an extra instance of the wrapper and impact the performance. Since NetBeans 8.0
Collections without initial capacity[ Disabled by default ]
Looks for instatiations of collections with missing initial capacity. Only collections backed-up with an array are tested. Since NetBeans 6.9
Creating new Boolean
Creating new Boolean is inefficient and typically useless. Since NetBeans 6.9
Length one String in String.indexOf[ Disabled by default ]
Length one String literal in String.indexOf can be replaced with a character literal Since NetBeans 6.9
Manual array copy
Finds occurrences of manual array copying via for loop Since NetBeans 6.9
Map replaceable with EnumMap
Finds instantiations of Maps that can be replaced with EnumMap Since NetBeans 6.9
Redundant String.toString()
Reports calls of String.toString(), which is entirely useless, the String can be used directly. Since NetBeans 8.0
Replace StringBuffer/StringBuilder by String
The hint will find and offer to replace instances of StringBuffer or StringBuilder which are accessed using ordinary String methods and are never passed out of the method, or assigned to another variable. Keeping such data in StringBuffer/Builder is pointless, and String would be more efficient. Since NetBeans 8.0
Set replaceable with EnumSet
Finds instantiations of Sets that can be replaced with EnumSet Since NetBeans 6.9
String concatenation in StringBuilder.append
Looks for string concatenation in the parameter of an invocation of the append method of StringBuilder or StringBuffer. Since NetBeans 6.9
String constructor
Use of java.lang.String constructor is usually useless. Since NetBeans 6.9
String.equals("")[ Disabled by default ]
Use of String.equals("") can be replaced with with String.length() == 0 (for JDK5 and lower) or String.isEmpty() (for JDK6 and higher) Since NetBeans 6.9
String.intern() called on constant[ Disabled by default ]
Invocations of String.intern() on compile-time constants are superfluous. Since NetBeans 6.9
StringBuilder without initial capacity[ Disabled by default ]
Looks for instantiations of StringBuilder or StringBuffer with missing initial capacity. Since NetBeans 6.9
Unnecessary temporary during conversion from String
Finds occurrences of new Integer("111").intValue() and similar constructions, where the boxed instance is created just to parse the String parameter. Boxing types have parseXXX methods, which perform the conversion without creating the temporary instance. Since NetBeans 8.0
Unnecessary temporary during conversion to String
Finds places like new Integer(11).toString() where a temporary boxed instance is created to just produce a String representation of a primitive. The boxed types have toString() static method just for that purpose. Since NetBeans 8.0
Usage of .size() == 0
Use .isEmpty() or !.isEmpty() instead of .size() == 0 or .size() != 0 where possible. Since NetBeans 6.9
Useless use of StringBuffer
Use StringBuilder instead of StringBuffer where possible. Since NetBeans 6.9
Zero element array passed to Collection.toArray[ Disabled by default ]
Passing zero element array to Collection.toArray may affect performance Since NetBeans 7.2

Probable Bugs

'finally' block suppresses exceptions
Reports usage of return statements in finally block. Such return discards the exception being thrown and causes the whole method to complete normally, which is usually not the desired outcome. Break and continue statements, which break out of the finally block are also reported. Since NetBeans 7.4
'throw' inside 'finally' block
Throwing an exception inside finally block will hide the original exception thrown from the associated try or catch blocks from enclosing exception handlers. Note that the exception can be still inspected using Throwable.getSuppressedException(), although it cannot be directly caught by a catch block. Since NetBeans 7.4
.equals on Array
.equals on array Since NetBeans 6.9
.equals on Incompatible Types
.equals on incompatible types In NetBeans 6.8 or earlier
.equals(null)
Finds invocations of the Object.equals method with literal parameter 'null'. Since NetBeans 6.9
@CheckReturnValue
Verifies that a result of method marked with @CheckReturnValue is really checked. Since NetBeans 7.2
Annotations without runtime Retention
Warns about reflective access to annotations with CLASS or SOURCE retentions Since NetBeans 6.9
Assert with side effects
Identifies assert statements whose condition reportedly causes some side effects. The hint checks assignments to local variables and fields made from within the condition expression. If the expression calls a method, the hint checks whether the method assigns to some fields. Only the directly called methods are checked. For performance reasons, although the called method may resolve to some overrides in subclasses at runtime, only the base class method body is inspected. Calls to interface type methods are ingored completely. Inspection of all possible overrides of a method would greatly hurt performance. Since NetBeans 8.0
Boxed value identity comparison
If two boxed values are compared using == or !=, identity of the boxed object's identity is compared instead of the boxed value. The inspection suggests a fix, which performs a null-safe comparison using java.util.Objects.equals().<p/>The fix is only available for source level >= 7, since a conditional expression would require multiple evaluation of one of the operands, which may not be possible because of potential expression's side effects. Since NetBeans 8.0
Cloneable class does not implement clone().[ Disabled by default ]
<html>Cloneable class should override clone(). If it does not, the clone operation uses the default java.lang.Object.clone(), which is usually not suitable. Lack of overridden clone indicate a possible error.</html> Since NetBeans 7.4
Comparator.compare() does not use its parameter {0}
The Comparator is expected to compare the arguments to its compare method. If one of the parameters is not used for comparison, it indicates that the other argument might be compared to self or some other error in the implementation. Since NetBeans 8.0
Confusing indentation
Warns about indentation that suggests possible missing surrounding block Since NetBeans 7.4
Confusing primitive array passed to varargs method
A primitive array passed to variable-argument method will not be unwrapped and its items will not be seen as items of the variable-length argument in the called method. Instead, the array will be passed as a single item. Since NetBeans 8.0
Created Throwable not thrown
The hint detects creation of a Throwable, which is then discarded. Throwable creation is rather expensive, and not using a created Throwable may indicate an unfinished error handling code. The Throwable is considered used, if it is thrown, passed to a method as a parameter, returned as a method's result or assigned to a field. Possible assignments through local variables are also inspected to determine whether the value will be finally used. Since NetBeans 8.0
Dead Branch
Dead Branch Since NetBeans 7.1
Incompatible cast/instanceof
Incompatible cast surrounded with incompatible instanceof Since NetBeans 6.9
Incorrect column index in ResultSet
Reports Iincorrect column indices passed to various methods of java.sql.ResultSet Since NetBeans 6.9
Infinite recursion
Detects methods which must recurse infinitely and could only terminate by throwing an exception. Only definitively recursions are reported, not possibilities. The recursion only inspected across the single method (so recursion like a -> b -> a is not reported). Recursion through several instances of the class is also not reported. The hint can be disabled for the case the recursing method could be overriden in subclasses, since subclass implementations could avoid the recursion. However if some subclass does not override and fix the method, recursion may still happen. By default the inspection warns even for the overridable case. Since NetBeans 8.0
Malformed XPath expression
The hint check syntax of the XPath expression passed to JAXP XPath evaluator. The calls checked are:
  • JAXP XPath compile and evaluate calls,
  • Xalan-J XPath creation and XPathAPI usage,
  • Apache Common's JXPath calls
Since NetBeans 8.0
Malformed format string
Reports format strings passed to String.format, printf-style methods. Checks that the number of arguments correspond to the number of % specifiers, and the arguments have the correct type. Since NetBeans 8.0
Malformed regular expression
Warns about malformed regular expressions Since NetBeans 6.9
Math.random() casted to int
Math.random produces a double in range 0..1. If the value is immediately cast to int, it is always rounded down to 0, which is probably not intended. The fix will move the cast so the enclosing arithmetic expression is casted and possibly rounded. Since NetBeans 8.0
Null Pointer Dereference
Checks various problems related to dereferencing nulls Since NetBeans 7.3
Possibly missing switch "case" statement
The hint detects a typo made in a switch statement a label without a case statement.<p/>While it may be a intended label for the following statement, it could be also an intended case branch with the keyword forgotten. Since NetBeans 8.0
Result of new Object ignored
Result of new Object ignored. Since NetBeans 6.9
String.replaceAll(".", )
Finds occurrences of calls to String.replaceAll(".", $target), which would replace all characters of the source string with $target. Since NetBeans 6.9
StringBuffer constructor called with `char argument
StringBuffer and StringBuilder constructors accept int as a parameter. If a char is passed, it is silently promoted to int, and the call creates a StringBuffer instance with a defined initial capacity, rather than a StringBuffer that initially contains a single (the passed one) character.<p/>The offered fix will add an append that actually adds the character. Since NetBeans 8.0
Suspicious Collections.toArray() call
Detects such calls, whose array type parameter does not match the Collection's type parameter. The collection's type parameter should be assignable to the array type. For raw Collections, the hint checks that the array type is actually assignable to the casted-to array type.<p/>The hint offers to change the newly created array type, or to change the toArray parameter to new Type[],but the fix is not available if the collection expression may have some side effects. Since NetBeans 8.0
Suspicious Names Combination[ Disabled by default ]
Suspicious Names Combination Since NetBeans 8.0
Suspicious invocation of System.arraycopy
Finds invocations of System.arraycopy with negative offsets, length or used on non-array objects. Since NetBeans 6.9
Suspicious method call
Warns about suspicious calls to Collection.remove/contains and Map.containsKey/containsValue/remove Since NetBeans 6.9
Synchronizing on this in anonymous class
<html>Synchronizing on this in anonymous or local class is probably a result of refactoring and possibly a mistake Since NetBeans 6.9
Throwable method result is ignored
If a Throwable is returned from a method call as a return value (as an oppposite to be thrown), it is usually somehow recorded (assigned), further processed (passed to another method call), or thrown. Ignoring such Throwable or using in some simple comparison indicates either a defect in error handling, or that the method should return a different value to save time for Throwable's stacktrace creation. Since NetBeans 8.0
Unbalanced read/write with arrays
Unbalanced read/write with arrays Since NetBeans 7.1
Unbalanced read/write with collections
Unbalanced read/write with collections Since NetBeans 7.1
Unused Assignment
Unused Assignment Since NetBeans 7.1
clone() does not call super.clone()
Cloned instances should be allocated using super.clone() so fields are initialized properly. Since NetBeans 7.4
clone() does not throw CloneNotSupportedException
If clone() is not declared to throw CloneNotSupportedException subclasses cannot prohibit cloning using standard Cloneable contract. Since NetBeans 7.4
clone() in a non-Cloneable class[ Disabled by default ]
The contract for Object.clone() requires, that a class must implement Cloneable marker interface. If not, the clone() method will raise CloneNotSupportedException. Declaring Cloneable interface is often overlooked. Since NetBeans 7.4
hashCode() used on array instance
hashCode for array instances is inherited from java.lang.Object, and it is based on the array's reference rather than on array's contents.

In order to obtain a more reasonable hashCode, which reflects contained objects or values, use Arrays.hashCodeor Arrays.deepHashCode() Since NetBeans 8.0

toString() used on array instance
toString() implementation for arrays does not convert array contents to String, rather it will print array's type and hash code (defined as identity hash code). To get string representation of contents of the array, the array could be for example wrapped into Arrays.asList(), as Collections produce content representation in their toString(). Since NetBeans 8.0

Standard Javac Warnings

Deprecated[ Disabled by default ]
Warn when code uses deprecated API. Since NetBeans 6.9
Division By Zero[ Disabled by default ]
Division By Zero Since NetBeans 6.9
Empty Statement After If[ Disabled by default ]
Empty Statement After If Since NetBeans 6.9
Fallthrough[ Disabled by default ]
Warn when a case can fall through to the next case. Since NetBeans 6.9
Finally [ Disabled by default ]
Warn when a finally block interrupts flow of a try/catch block. Since NetBeans 6.9
Overrides[ Disabled by default ]
Warn when an overriding method is not annotated with @Overrides Since NetBeans 6.9
Raw Types[ Disabled by default ]
Raw Types Since NetBeans 6.9
Serialization[ Disabled by default ]
Warn when a class which implements java.io.Serializable does not declare a serialVersionUID. Since NetBeans 6.9
Unchecked[ Disabled by default ]
Warn when unchecked conversions may cause ClassCastExceptions at runtime. Since NetBeans 6.9
Unnecessary Cast[ Disabled by default ]
Warn when an object is cast unnecessarily to the same type or a supertype. Since NetBeans 6.9

Suggestions

Assign Return Value To New Variable
Assign Return Value To New Variable In NetBeans 6.8 or earlier
Assign Unused Constructor Parameter to Field
Assign Unused Constructor Parameter to Field In NetBeans 6.8 or earlier
Combine nested if statements
Combines two nested if statements, like if (cond1) if (cond2) statement;, into one if statement, like if (cond1 && cond2) statement;. Since NetBeans 7.4
Convert Anonymous to Member
Convert Anonymous to Member In NetBeans 6.8 or earlier
Convert Lambda Body to Use a Block
Converts lambda bodies to use blocks rather than expressions Since NetBeans 7.4
Convert Lambda Expression to Anonymous Innerclass
Converts lambda expressions to anonymous inner classes Since NetBeans 7.4
Convert Lambda Expression to Member Reference
Converts lambda expressions to member references Since NetBeans 8.0
Convert Lambda to Use Explicit Parameter Types
Converts lambdas to use explicit parameter types Since NetBeans 7.4
Convert Member Reference to Lambda Expression
Converts member references to lambda expressions Since NetBeans 7.4
Convert integer constant to different base
Convert integer constant to different base Since NetBeans 7.0
Create Subclass
Create Subclass Since NetBeans 7.2
Create Test Class
Create a test class for the selected source class. Since NetBeans 7.4
Declaration for instanceof
Declaration for instanceof In NetBeans 6.8 or earlier
Expand Enhanced For Loop
Expand Enhanced For Loop Since NetBeans 7.1
Fill Missing Cases to Switch
Adds missing cases to switch statement. The default clause template should be one Java statement, occurrences of $expression will be replaced with the expression over which the switch statement works. Since NetBeans 7.2
Flip .equals
Allows to flip .equals parameter and call site Since NetBeans 6.9
Flip operands of the binary operator
Flip operands of the binary operator Since NetBeans 7.4
Generate All Test Methods
Generate all test methods for the selected source class. Since NetBeans 7.4
Implement Abstract Methods
Implement Abstract Methods. Since NetBeans 7.3
Invert If
Will invert an if statement; negate the condition and switch the statements from the then and else sections. Since NetBeans 7.3
Join consecutive ifs into if-else
Converts cases like if - else { if } info if - else if Since NetBeans 7.4
Join if conditions using ||
Converts cases like if (cond1) statement; else if (cond2) statement; into if (cond1 || cond2) statement; Since NetBeans 7.4
Move initialization to constructor
Moves a fields initialization expression to the constructors. Since NetBeans 7.3
Split Declaration
Splits declaration with initializer to a declaration and assignment Since NetBeans 7.2
Split if condition
Splits if whose condition is || into two ifs Since NetBeans 7.4
Split if statement condition
Splits an if statement with a complex condition, like if (cond1 || cond2) statement;, into two if statements, like if (cond1) statement; else if (cond2) statement;. Since NetBeans 7.4

Testing

Inconvertible parameters of Assert.assertEquals
Inconvertible parameters of Assert.assertEquals Since NetBeans 7.4
Incorrect order of parameters of Assert.assertEquals
Incorrect order of parameters of Assert.assertEquals Since NetBeans 7.4
assertEquals for array parameters
Warns about assertEquals whose parameters are arrays Since NetBeans 7.4

Threading

.notify invoked outside a synchronized context
.notify invoked outside a synchronized context Since NetBeans 6.9
.wait invoked outside a synchronized context
.wait invoked outside a synchronized context Since NetBeans 6.9
Double-checked locking
Searches for examples of double checked locking - e.g. when a variable is tested before as well as inside a synchronized block. In NetBeans 6.8 or earlier
Empty synchronized block
Empty synchronized block are usually useless Since NetBeans 6.9
Field Can Be Final
Finds fields that can be made final, which can simplify synchronization and clarity Since NetBeans 7.4
Invoking Condition.notify()
Invoking notify or notifyAll on java.util.concurrent.locks.Condition should probably be replaced with invoking signal or signalAll. Since NetBeans 6.9
Invoking Condition.wait()
Invoking wait on java.util.concurrent.locks.Condition is probably unintended. Since NetBeans 6.9
Invoking Thread.run()
Invoking run on java.lang.Thread should be probably replaced with invocation of method start() Since NetBeans 6.9
Invoking Thread.stop()/suspend()/resume()
Methods stop(), suspend() and resume() of java.lang.Thread are dangerous and should not be used. Since NetBeans 6.9
Invoking Thread.yield()
Invocation of method yield() on java.lang.Thread is usually used to masquerade synchronization problems and should be avoided. Since NetBeans 6.9
Lock not unlocked in finally
Finds occurrences of Lock.lock()-Lock.unlock() not properly wrapped in try-finally. Since NetBeans 6.9
Nested synchronized blocks
Nesting synchronized blocks is either useless (if they use the same lock object) or dangerous. Since NetBeans 6.9
Starting Thread in constructor
Starting a new Thread in constructor is dangerous and should be prevented. Since NetBeans 6.9
Synchronization on non-final field
Synchronization on non-final field In NetBeans 6.8 or earlier
Synchronizing on Lock
Synchronizing on java.util.concurrent.locks.Lock is usually unintended and should be replaced with Lock.lock()-Lock.unlock() Since NetBeans 6.9
Thread.sleep in loop
Invoking Thread.sleep in loop can cause performance problems Since NetBeans 6.9
Thread.sleep in synchronized context
Invoking Thread.sleep in synchronized context can cause performance problems Since NetBeans 6.9
Volatile array field
Finds declarations of volatile array fields. Since NetBeans 6.9

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo