Top
Interstage Studio User's Guide
FUJITSU Software

6.2.5 Detecting and Correcting Problems

If there are errors, warnings, or other problems in Java files, JSP files or other source files, markers are set at those locations. Thus, problems can be checked from the icons displayed in the editor rulers and the highlighted displays in the source. A list of problems is also displayed in the Problems view. The problem content is displayed as marker information. Correct these locations as required.

Errors, warnings, and other problems are detected by various functions. The following functions detect problems:

6.2.5.1 Java Compiler

The Java compiler not only checks for coding errors that violate Java specifications, but can also check for coding that may cause problems despite conforming to Java specifications.

The following categories can be checked:

More detailed check items belong to the above categories, and the check level can be customized. Customized settings can be entered from [Java] > [Compiler] on the preferences page, or from other preferences page under the preferences page. To customize settings for a specific project, use [Java Compiler] under the project properties.

6.2.5.2 Validation

The validators shown below are provided to validate files and applications. The validators can check in file units and project units.

Validator

Contents to be checked

HTML Syntax Validator

Checks the basic syntax of HTML files.

JavaScript Syntax Validator

Checks the JavaScript syntax described in HTML/JSP files.

JPA Validator

Checks the validity of an application as a JPA application.

JSP Syntax Validator

Converts a JSP file to Java code then checks for compile errors in that Java code, thereby checking the syntax of the JSP file.

JSP Content Validator

Checks the EL, directives, and so on of the JSP.

XML Validator

Checks that an XML file is in the correct format and checks its validity.

The validators run at the following times:

Validation Settings

The validation operation can be customized using [Validation] on the Preferences page. To customize settings for a specific project, use [Validation] under the project properties.
Refer to the following concerning customization:

6.2.5.3 Interstage Java EE Validator

The validity of an application as a Java EE application can be validated in archive file units, as shown below.

Point

When an enterprise application project is checked, the modules it contains are also checked. If the workspace is used to create an enterprise application and also its constituent modules, and if the validity is checked at build time, avoid duplication by selecting only one or the other.

Interstage Java EE Validator Settings

The Interstage Java EE Validator operation can be customized using [Interstage Java EE Validator] on the preferences page. To customize settings for a specific project, use [Interstage Java EE Validator] under the project properties.
Perform customization with reference to the following:

6.2.5.4 FindBugs

FindBugs can be used to identify code which may contain bugs as shown below.

Point

It is also possible to change the settings collectively to execute as builders by selecting multiple project and [Find Bugs] > [Turn on "Run FindBugs automatically"] from the context menu.

The detected problem will be displayed in the Problems View in the following format.

  <Warning priority> <Bug category> <Bug pattern> : <Message>

In addition, as listed below, views and perspectives for the purpose of displaying problems detected by FindBugs are also provided.

Check Contents

In FindBugs, the checks shown below are performed.

Bug Category

Abbreviation

Overview

Performance

P

It is not necessarily a mistake, but it is possible that execution efficiency will worsen. For example, the following points are detected.

  • Inefficient use of URL class

  • Inefficient use of String class

  • Inefficient use of valueOf method

  • Inefficient use of boxing/ unboxing

  • Field or method declaration that is not in use

Correctness

C

Obvious coding errors that resulted in unintended code by the developers. For example, the following points are detected.

  • Misuse of equals method

  • Obvious infinite loops

  • Naming issues in fields, methods and so on

  • Null pointers

Internationalization

I

Flaws exist in code that deals with Internationalization or locale. For example, the following points are detected.

  • A method that keeps the Locale in the argument is not used

Multithreaded correctness

M

Flaws exist in code that deals with Threads, locks and volatiles.

Bad practice

B

Code that deviates from recommended or fundamental coding patterns. For example, the following points are detected.

  • Exception handling

  • Incorrect comparison of character strings

  • Misuse of finalizer

  • Use of equals method

  • Confusing names of fields, methods and so on

  • Serialization problems

Malicious code vulnerability

V

Code that is vulnerable to attacks from untrusted code. For example, the following points are detected.

  • Possibility of internal expressions spilling

  • Related to private or final (and so on) modifiers

Dodgy

D

Code that is easily misinterpreted, improper, or invites errors. For example, the following points are detected.

  • Related to settings of values to variables

  • Related to cast

The bug category units above can be customized to check or not check.

FindBugs Settings

The FindBugs operation can be customized using [FindBugs] on the preferences page. To customize settings for a specific project, use [FindBugs] under the project properties.
Perform customization with reference to the following:

For setup items that are specific to a project, refer to the following:

Point

It is also possible to change the settings collectively to execute as builders by selecting multiple project and [Find Bugs] > [Turn on "Run FindBugs automatically"] from the context menu.

FindBugs Filter File Format

With FindBugs it is possible to control whether or not checked content is treated as a problem using the filter file. For example, if with FindBugs detects a problem but a code check proves that it is not actually a problem, the exclude filter file can be set so that in future it will not detect that as a problem.

The tags used by Filter File are explained below.

Tag

Attribute

Description

FindBugsFilter

-

Top level element of filter file.

Match

-

Element used to identify class.

class

Specifies class name.

classregex

Specifies class name as a regular expression.

BugCode

-

Element used to specify bug pattern abbreviations. The bug pattern abbreviation is the alphabet combination displayed third in the problem message.

name

Separate each bug pattern abbreviation with a comma.

Priority

-

Element used to specify priority.

value

Specify one of the following values.
1: High
2: Normal
3: Low

Method

-

Element used to specify method. The params attribute and returns attribute are not mandatory, but if specifying, both must be specified.

name

Specifies method name.

params

Separate each full qualified argument type name with a comma.

returns

Separate each full qualified return value type name with a comma.

Or

-

Element that acts as an OR logical operator.

The following is an actual exclude filter file.

<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter>
     <!-- Do not detect a problem related to ClassNotToBeAnalyzed class -->
     <Match class="com.foobar.ClassNotToBeAnalyzed" />

     <!-- Do not detect the following problems related to ClassWithSomeBugsMatched class
       DE : Exception is overlooked or ignored.
       UrF: A field that will not be referenced exists.
      -->
     <Match class="com.foobar.ClassWithSomeBugsMatched">
       <BugCode name="DE,UrF" />
     </Match>

     <!-- Do not detect SQL problems in any class -->
     <Match classregex=".*" >
       <BugCode name="SQL" />
     </Match>

     <!-- Do not detect field double-check problems for nonOverloadedMethod, frob or blat method of AnotherClass class -->
     <Match class="com.foobar.AnotherClass">
       <Or>
         <Method name="nonOverloadedMethod" />
         <Method name="frob" params="int,java.lang.String" returns="void" />
         <Method name="blat" params="" returns="boolean" />
       </Or>
       <BugCode name="DC" />
     </Match>

    <!-- Do not detect priority 2 (normal) problems in check item "substitution of meaningless local variables" for the someMethod of the MyClass class-->
    <Match class="com.foobar.MyClass">
      <Method name="someMethod"/>
      <BugCode name="DLS "/>
      <Priority value="2"/>
    </Match>

</FindBugsFilter>