xref: /titanic_44/usr/src/tools/scripts/jstyle.1 (revision 4eaa471005973e11a6110b69fe990530b3b95a38)
ident "%Z%%M% %I% %E% SMI"
Copyright 2005 Sun Microsystems, Inc. All rights reserved.
Use is subject to license terms.

CDDL HEADER START

The contents of this file are subject to the terms of the
Common Development and Distribution License (the "License").
You may not use this file except in compliance with the License.

You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
or http://www.opensolaris.org/os/licensing.
See the License for the specific language governing permissions
and limitations under the License.

When distributing Covered Code, include this CDDL HEADER in each
file and include the License file at usr/src/OPENSOLARIS.LICENSE.
If applicable, add the following below this CDDL HEADER, with the
fields enclosed by brackets "[]" replaced with your own identifying
information: Portions Copyright [yyyy] [name of copyright owner]

CDDL HEADER END

jstyle 1 "22 November 2005"
NAME
jstyle - check for some common stylistic errors in Java source files
SYNOPSIS
jstyle [-chptvC] [file...]

DESCRIPTION
"OS-Net build tools" "jstyle" "" "jstyle"

jstyle inspects Java source files (*.java) for common stylistic errors. It is similar to cstyle (1) in that it attempts to check for the style documented in /shared/ON/general_docs/cstyle.ms.pdf, although by necessity is modified to work with Java-specific constructs. Note that there is much in that document that cannot be checked for; just because your code is jstyle (1) clean does not mean that you've followed Sun's Java style. Caveat emptor.

OPTIONS

The following options are supported:

4 -c Check continuation line indentation inside of functions. Sun's C style states that all statements must be indented to an appropriate tab stop, and any continuation lines after them must be indented exactly four spaces from the start line. This option enables a series of checks designed to find contination line problems within functions only.

4 -h Performs heuristic checks that are sometimes wrong. Not generally used.

4 -p Performs some of the more picky checks. You should generally use this.

4 -t Insists on indentation with tabs. Because of the depth of nested blocks that Java requires, and the commonality of long identifiers, tab indentation in Java code is not always useful, assuming that tabs are fixed at eight columns and that maximum line length is fixed at eighty columns, so this option is not on by default. If you choose to consider tabs to be four columns wide (not acceptable for ON), or are writing simple enough code that the nesting is not very deep, this option might be useful. Otherwise, avoid it.

4 -v Verbose output; includes the text of the line of error.

4 -C Ignore errors in header comments (i.e., block comments starting in the first column). Not generally used.

NOTES

The jstyle rule for the OS/Net consolidation is that all new files must be -p clean. For existing files, the following invocations are run against both the old and new files:

4 "jstyle file"

4 "jstyle -p file"

If the old file gave no errors for one of the invocations, the new file must also give no errors. This way, files cannot become unclean.

BUGS

jstyle (1) cannot disambiguate Java generic type parameters or arguments that span multiple lines from relational operators. For example:

4 private class Foo<A extends Bar,

B extends Bar> { ...

is flagged as two lines with missing spaces around relational operators.