Showing posts with label FindBugs. Show all posts
Showing posts with label FindBugs. Show all posts

Sunday, July 26, 2015

Implicit super constructor Object() is undefined for default constructor

Suppose if your JRE is not defined properly, you might get this error. 

Just follow the below steps to solve this error. 

In Eclipse:

1.Right click on your project (Package Explorer mode)  and select Build Path -> Configure Build Path
2.Go to Libraries tab 
3.Click Add Library.
4.Select JRE System Library 
5.Click Next
6.Select your JRE
7.Click Finish.

Once finish, make a clean and build. 

Friday, May 8, 2015

Avoid null with valueOf() method

In java the valueOf() and toString() would play the most role for displaying object output. However we should know, which is the best one to use?

We can avoid null, if we will use valueOf() method instead of toString() method.

See the below example for more understanding,

JavaHit javaObject = null;

// will not throw Null Poniter Exception
System.out.println(String.valueOf(javaObject));


// will throw Null Poniter Exception
System.out.println(javaObject.toString())

Friday, June 13, 2014

ORA-01008: not all variables bound

Problem:

    While executing the callable statement or prepared statement, you may get this error.

Solution:

    Just check how many " ? " parameters you are using with your procedure call or prepared statement call.

Friday, May 9, 2014

Null pointer deference in find bugs

I have faced null pointer deference, when I checked the code standard with tool. It shows NULL pointer deference in severity 1.

Normally it will come when you are not handling null values. For example,

if ( URL != null) {System.out.println( "URL is NOT NULL + URL );}

ok fine. You are checking URL is not null. But in case , URL come as null, what will happen? Null pointer Exception error will thrown.

So this error called Null Pointer Dereference error. ok, How to handle this. See below for solution.

if ( URL != null) {System.out.println( "URL is NOT NULL + URL );}
        else {
        System.out.println( "URL is NULL " );
         throw new IllegalArgumentException();
}

Thats all.

Thursday, May 8, 2014

Appears to call the same method on the same object redundantly in FindBugs

Issue Here below:

try {
----------
----------
}
catch (final SQLException e) {
LOG.error("Error Message Test: " + e.getMessage());
            throw new YourException(e.getMessage(), e);
}


Solution for that:

try {
--------------
--------------
 } catch (final SQLException e) {
        String errorMessage = e.getMessage();
            LOG.error("Error Message Test: " + errorMessage);
            throw new YourException(errorMessage, e);