📄 hacking.texinfo
字号:
contains those features. GNU Classpath has been free of anyproprietary dependencies for a long time now and we like to keep itthat way. But finishing, polishing up, documenting, testing anddebugging current functionality is of higher priority then adding newfunctionality.@node Needed Tools and Libraries, Programming Standards, Project Goals, Top@comment node-name, next, previous, up@chapter Needed Tools and LibrariesIf you want to hack on Classpath, you should at least download andinstall the following tools. And try to familiarize yourself withthem. Although in most cases having these tools installed will be allyou really need to know about them. Also note that when working on(snapshot) releases only GCC 3.3+ (plus a free VM from the list aboveand the libraries listed below) is needed. The other tools are onlyneeded when working directly on the CVS version.@itemize @bullet@itemGCC 3.3+@itemCVS 1.11+@itemautomake 1.7+@itemautoconf 2.59+@itemlibtool 1.4.2+@itemGNU m4 1.4@itemtexinfo 4.2+@end itemizeAll of these tools are available from@uref{ftp://gnudist.gnu.org/pub/gnu/,gnudist.gnu.org} via anonymousftp, except CVS which is available from@uref{http://www.cvshome.org/,www.cvshome.org}. They are fullydocumented with texinfo manuals. Texinfo can be browsed with theEmacs editor, or with the text editor of your choice, or transformedinto nicely printable Postscript.Here is a brief description of the purpose of those tools.@table @b@item GCCThe GNU Compiler Collection. This contains a C compiler (gcc) forcompiling the native C code and a compiler for the java programminglanguage (gcj). You will need at least gcj version 3.3 or higher. Ifthat version is not available for your platform you can try the@uref{http://www.jikes.org/, jikes compiler}. We try to keep all codecompilable with both gcj and jikes at all times.@item CVS A version control system that maintains a centralized Internetrepository of all code in the Classpath system.@item automake This tool automatically creates Makefile.in files from Makefile.amfiles. The Makefile.in is turned into a Makefile by autoconf. Whyuse this? Because it automatically generates every makefile targetyou would ever want (clean, install, dist, etc) in full compliancewith the GNU coding standards. It also simplifies Makefile creationin a number of ways that cannot be described here. Read the docs formore info.@item autoconf Automatically configures a package for the platform on which it isbeing built and generates the Makefile for that platform.@item libtool Handles all of the zillions of hairy platform specific options neededto build shared libraries.@item m4The free GNU replacement for the standard Unix macro processor.Proprietary m4 programs are broken and so GNU m4 is required forautoconf to work though knowing a lot about GNU m4 is not required towork with autoconf.@item perlLarry Wall's scripting language. It is used internally by automake.@item texinfoManuals and documentation (like this guide) are written in texinfo.Texinfo is the official documentation format of the GNU project.Texinfo uses a single source file to produce output in a number of formats,both online and printed (dvi, info, html, xml, etc.). This means thatinstead of writing different documents for online information and anotherfor a printed manual, you need write only one document. And when the workis revised, you need revise only that one document.@end tableFor compiling the native AWT libraries you need to have the followinglibraries installed:@table @b@item GTK+ 2.2.x@uref{http://www.gtk.org/,GTK+} is a multi-platform toolkit forcreating graphical user interfaces. It is used as the basis of theGNU desktop project GNOME.@item gdk-pixbuf@uref{http://www.gnome.org/start/,gdk-pixbuf} is a GNOME library forrepresenting images.@end tableGNU Classpath comes with a couple of libraries included in the sourcethat are not part of GNU Classpath proper, but that have been includedto provide certain needed functionality. All these external librariesshould be clearly marked as such. In general we try to use as much aspossible the clean upstream versions of these sources. That waymerging in new versions will be easiest. You should always try to getbug fixes to these files accepted upstream first. Currently weinclude the following 'external' libraries. Most of these sources areincluded in the @file{external} directory. That directory alsocontains a @file{README} file explaining how to import newer versions.@table @b@item GNU jaxpCan be found in @file{external/jaxp}. Provides javax.xml, org.w3c andorg.xml packages. Upstream is@uref{http://www.gnu.org/software/classpathx/,GNU ClasspathX}.@item fdlibmCan be found in @file{native/fdlibm}. Provides native implementationsof some of the Float and Double operations. Upstream is@uref{http://gcc.gnu.org/java/,libgcj}, they sync again with the'real' upstream @uref{http://www.netlib.org/fdlibm/readme}. See alsojava.lang.StrictMath.@end table@node Programming Standards, Hacking Code, Needed Tools and Libraries, Top@comment node-name, next, previous, up@chapter Programming StandardsFor C source code, follow the@uref{http://www.gnu.org/prep/standards/,GNU Coding Standards}.The standards also specify various things like the install directorystructure. These should be followed if possible.For Java source code, please follow the@uref{http://www.gnu.org/prep/standards/,GNU CodingStandards}, as much as possible. There are a number of exceptions tothe GNU Coding Standards that we make for GNU Classpath as documentedin this guide. We will hopefully be providing developers with a codeformatting tool that closely matches those rules soon.For API documentation comments, please follow@uref{http://java.sun.com/products/jdk/javadoc/writingdoccomments.html,Howto Write Doc Comments for Javadoc}. We would like to have a set ofguidelines more tailored to GNU Classpath as part of this document.@menu* Source Code Style Guide:: @end menu@node Source Code Style Guide, , Programming Standards, Programming Standards@comment node-name, next, previous, up@section Java source coding styleHere is a list of some specific rules used when hacking on GNUClasspath java source code. We try to follow the standard@uref{http://www.gnu.org/prep/standards/,GNU Coding Standards}for that. There are lots of tools that can automatically generate it(although most tools assume C source, not java source code) and itseems as good a standard as any. There are a couple of exceptions andspecific rules when hacking on GNU Classpath java source code however.The following lists how code is formatted (and some other codeconventions):@itemize @bullet@itemJava source files in GNU Classpath are encoded using UTF-8. However,ordinarily it is considered best practice to use the ASCII subset ofUTF-8 and write non-ASCII characters using \u escapes.@itemIf possible, generate specific imports (expand) over java.io.* typeimports. Order by gnu, java, javax, org. There must be one blank linebetween each group. The imports themselves are ordered alphabetically bypackage name. Classes and interfaces occur before sub-packages. Theclasses/interfaces are then also sorted alphabetical. Note that uppercasecharacters occur before lowercase characters.@exampleimport gnu.java.awt.EmbeddedWindow;import java.io.IOException;import java.io.InputStream;import javax.swing.JFrame;@end example@itemBlank line after package statement, last import statement, classes,interfaces, methods.@itemOpening/closing brace for class and method is at the same level ofindent as the declaration. All other braces are indented and contentbetween braces indented again.@itemSince method definitions don't start in column zero anyway (since theyare always inside a class definition), the rational for easy greppingfor ``^method_def'' is mostly gone already. Since it is customary foralmost everybody who writes java source code to put modifiers, returnvalue and method name on the same line, we do too.@c fixme Another rational for always indenting the method definition is that itmakes it a bit easier to distinguish methods in inner and anonymousclasses from code in their enclosing context. NEED EXAMPLE.@itemImplements and extends on separate lines, throws too. Indent extends,implements, throws. Apply deep indentation for method arguments.@c fixme Needs example.@itemDon't add a space between a method or constructor call/definition andthe open-bracket. This is because often the return value is an object onwhich you want to apply another method or from which you want to accessa field. Don't write:@example getToolkit ().createWindow (this);@end exampleBut write:@example getToolkit().createWindow(this);@end example@itemThe GNU Coding Standard it gives examples for almost every construct(if, switch, do, while, etc.). One missing is the try-catch constructwhich should be formatted as:@example try @{ // @} catch (...) @{ // @}@end example@itemWrap lines at 80 characters after assignments and before operators.Wrap always before extends, implements, throws, and labels.@itemDon't put multiple class definitions in the same file, except forinner classes. File names (plus .java) and class names should be thesame.@itemDon't catch a @code{NullPointerException} as an alternative to simplychecking for @code{null}. It is clearer and usually more efficientto simply write an explicit check.For instance, don't write:@exampletry @{ return foo.doit(); @}catch (NullPointerException _) @{ return 7; @}@end exampleIf your intent above is to check whether @samp{foo} is @code{null},instead write:@exampleif (foo == null) return 7;else return foo.doit();@end example@itemDon't use redundant modifiers or other redundant constructs. Here issome sample code that shows various redundant items in comments:@example/*import java.lang.Integer;*//*abstract*/ interface I @{ /*public abstract*/ void m(); /*public static final*/ int i = 1; /*public static*/ class Inner @{@}@}final class C /*extends Object*/ @{ /*final*/ void m() @{@}@}@end exampleNote that Jikes will generate warnings for redundant modifiers if youuse @code{+Predundant-modifiers} on the command line.@itemModifiers should be listed in the standard order recommended by theJLS. Jikes will warn for this when given @code{+Pmodifier-order}.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -