OpenSolaris_b135/tools/scripts/jstyle.1

.\" 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
.\"
.TH jstyle 1 "22 November 2005"
.SH NAME
.I jstyle
\- check for some common stylistic errors in Java source files
.SH SYNOPSIS
\fBjstyle [-chptvC] [file...]\fP
.LP
.SH DESCRIPTION
.IX "OS-Net build tools" "jstyle" "" "\fBjstyle\fP"
.LP
.B jstyle
inspects Java source files (*.java) for common stylistic errors.  It
is similar to
.BR cstyle (1)
in that it attempts to check for the style
documented in \fI/shared/ON/general_docs/cstyle.ms.pdf\fP, although by
necessity is modified to work with Java-specific constructs.  Note that
there is much in that document that
.I cannot
be checked for; just because your code is
.BR jstyle (1)
clean does not
mean that you've followed Sun's Java style.  \fICaveat emptor\fP.
.LP
.SH OPTIONS
.LP
The following options are supported:
.TP 4
.B \-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 \fIexactly\fP four
spaces from the start line.  This option enables a series of checks
designed to find contination line problems within functions only.
.LP
.TP 4
.B \-h
Performs heuristic checks that are sometimes wrong.  Not generally used.
.LP
.TP 4
.B \-p
Performs some of the more picky checks.  You should generally use this.
.LP
.LP
.TP 4
.B \-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.
.LP
.TP 4
.B \-v
Verbose output; includes the text of the line of error.
.LP
.TP 4
.B \-C
Ignore errors in header comments (i.e., block comments starting in the
first column).  Not generally used.
.LP
.LP
.SH NOTES
.LP
The jstyle rule for the OS/Net consolidation is that all new files must
be
.B -p
clean.  For existing files, the following invocations are
run against both the old and new files:
.LP
.TP 4
.B "jstyle file"
.LP
.TP 4
.B "jstyle -p file"
.LP
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.
.LP
.SH BUGS
.LP
.BR jstyle (1)
cannot disambiguate Java generic type parameters or
arguments that span multiple lines from relational operators.  For example:
.RS 4
.HP 4
private class Foo<A extends Bar,
.br
B extends Bar> { ...
.RE
.LP
is flagged as two lines with missing spaces around relational operators.