⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hacking.texinfo

📁 gcc的组建
💻 TEXINFO
📖 第 1 页 / 共 5 页
字号:
standardized on explicitly specifying @code{serialVersionUID} in@code{Serializable} classes in Classpath.  This field should bedeclared as @code{private static final}.  Note that a class may be@code{Serializable} without being explicitly marked as such, due toinheritance.  For instance, all subclasses of @code{Throwable} need tohave @code{serialVersionUID} declared.@c fixme index@c fixme link to the discussion@itemDon't declare unchecked exceptions in the @code{throws} clause of amethod.  However, if throwing an unchecked exception is part of themethod's API, you should mention it in the Javadoc.@itemWhen overriding @code{Object.equals}, remember that @code{instanceof}filters out @code{null}, so an explicit check is not needed.@itemWhen catching an exception and rethrowing a new exception you should``chain'' the Throwables.  Don't just add the String representation ofthe caught exception.@example  try    @{      // Some code that can throw    @}  catch (IOException ioe)    @{      throw (SQLException) new SQLException("Database corrupt").setCause(ioe);    @}@end example@itemAvoid the use of reserved words for identifiers.  This is obvious with thosesuch as @code{if} and @code{while} which have always been part of the Javaprogramming language, but you should be careful about accidentally usingwords which have been added in later versions.  Notable examples are@code{assert} (added in 1.4) and @code{enum} (added in 1.5).  Jikes will warnof the use of the word @code{enum}, but, as it doesn't yet support the 1.5version of the language, it will still allow this usage through.  Acompiler which supports 1.5 (e.g. the Eclipse compiler, ecj) will simplyfail to compile the offending source code.@c fixme Describe Anonymous classes (example).@c fixme Descibe Naming conventions when different from GNU Coding Standards.@c fixme Describee API doc javadoc tags used.@end itemizeSome things are the same as in the normal GNU Coding Standards:@itemize@itemUnnecessary braces can be removed, one line after an if, for, while asexamples.@itemSpace around operators (assignment, logical, relational, bitwise,mathematical, shift).@itemBlank line before single-line comments, multi-line comments, javadoccomments.@itemIf more than 2 blank lines, trim to 2.@itemDon't keep commented out code.  Just remove it or add a real commentdescribing what it used to do and why it is changed to the currentimplementation.@end itemize@node Hacking Code, Programming Goals, Programming Standards, Top@comment node-name, next, previous, up@chapter Working on the code, Working with othersThere are a lot of people helping out with GNU Classpath.  Here are acouple of practical guidelines to make working together on the codesmoother.The main thing is to always discuss what you are up to on themailinglist.  Making sure that everybody knows who is working on whatis the most important thing to make sure we cooperate mosteffectively.We maintain a@uref{http://www.gnu.org/software/classpath/tasks.html,Task List}which contains items that you might want to work on.Before starting to work on something please make sure you read thiscomplete guide.  And discuss it on list to make sure your work doesnot duplicate or interferes with work someone else is already doing.Always make sure that you submit things that are your own work.  Andthat you have paperwork on file (as stated in the requirementssection) with the FSF authorizing the use of your additions.Technically the GNU Classpath project is hosted on@uref{http://savannah.gnu.org/,Savannah} a central point fordevelopment, distribution and maintenance of GNU Software.  Here youwill find the@uref{https://savannah.gnu.org/projects/classpath/,project page}, bugreports, pending patches, links to mailing lists, news items and CVS.You can find instructions on getting a CVS checkout for classpath at@uref{https://savannah.gnu.org/cvs/?group=classpath}.You don't have to get CVS commit write access to contribute, but it issometimes more convenient to be able to add your changes directly tothe project CVS. Please contact the GNU Classpath savannah admins toarrange CVS access if you would like to have it.Make sure to be subscribed to the commit-classpath mailinglist whileyou are actively hacking on Classpath.  You have to send patches (cvsdiff -uN) to this list before committing.We really want to have a pretty open check-in policy.  But this meansthat you should be extra careful if you check something in.  If at allin doubt or if you think that something might need extra explainingsince it is not completely obvious please make a little announcementabout the change on the mailinglist.  And if you do commit somethingwithout discussing it first and another GNU Classpath hackers asks forextra explanation or suggests to revert a certain commit then pleasereply to the request by explaining why something should be so or ifyou agree to revert it.  (Just reverting immediately is OK withoutdiscussion, but then please don't mix it with other changes and pleasesay so on list.)Patches that are already approved for libgcj or also OK for Classpath.(But you still have to send a patch/diff to the list.)  All otherpatches require you to think whether or not they are really OK andnon-controversial, or if you would like some feedback first on thembefore committing.  We might get real commit rules in the future, fornow use your own judgment, but be a bit conservative.Always contact the GNU Classpath maintainer before adding anythingnon-trivial that you didn't write yourself and that does not come fromlibgcj or from another known GNU Classpath or libgcj hacker.  If youhave been assigned to commit changes on behalf of another project ora company always make sure they come from people who have signed thepapers for the FSF and/or fall under the arrangement your company madewith the FSF for contributions.  Mention in the ChangeLog who actuallywrote the patch.Commits for completely unrelated changes they should be committedseparately (especially when doing a formatting change and a logicalchange, do them in two separate commits). But do try to do a commit ofas much things/files that are done at the same time which canlogically be seen as part of the same change/cleanup etc.When the change fixes an important bug or adds nice new functionalityplease write a short entry for inclusion in the @file{NEWS} file.  If itchanges the VM interface you must mention that in both the @file{NEWS} fileand the VM Integration Guide.All the ``rules'' are really meant to make sure that GNU Classpathwill be maintainable in the long run and to give all the projects thatare now using GNU Classpath an accurate view of the changes we make tothe code and to see what changed when.  If you think the requirementsare ``unworkable'' please try it first for a couple of weeks.  If youstill feel the same after having some more experience with the projectplease feel free to bring up suggestions for improvements on the list.But don't just ignore the rules!  Other hackers depend on them beingfollowed to be the most productive they can be (given the aboveconstraints).@menu* Writing ChangeLogs::          @end menu@node Writing ChangeLogs,  , Hacking Code, Hacking Code@comment node-name, next, previous, up@section Documenting what changed when with ChangeLog entriesTo keep track of who did what when we keep an explicit ChangeLog entrytogether with the code.  This mirrors the CVS commit messages and ingeneral the ChangeLog entry is the same as the CVS commit message.This provides an easy way for people getting a (snapshot) release orwithout access to the CVS server to see what happened when.  We do notgenerate the ChangeLog file automatically from the CVS server sincethat is not reliable.A good ChangeLog entry guideline can be found in the Guile Manual at@uref{http://www.gnu.org/software/guile/changelogs/guile-changelogs_3.html}.Here are some example to explain what should or shouldn't be in aChangeLog entry (and the corresponding commit message):@itemize@itemThe first line of a ChangeLog entry should be:@example[date] <two spaces> [full name] <two spaces> [email-contact]@end exampleThe second line should be blank. All other lines should be indentedwith one tab.@itemJust state what was changed.  Why something is done as it is done inthe current code should be either stated in the code itself or beadded to one of the documentation files (like this Hacking Guide).So don't write:@example        * java/awt/font/OpenType.java: Remove 'public static final'        from OpenType tags, reverting the change of 2003-08-11.  See        Classpath discussion list of 2003-08-11.@end exampleJust state:@example        * java/awt/font/OpenType.java: Remove 'public static final' from        all member fields.@end exampleIn this case the reason for the change was added to this guide.@itemJust as with the normal code style guide, don't make lines longer then80 characters.@itemJust as with comments in the code. The ChangeLog entry should be afull sentence, starting with a captital and ending with a period.@itemBe precise in what changed, not the effect of the change (which shouldbe clear from the code/patch).  So don't write:@example * java/io/ObjectOutputStream.java : Allow putFields be called more  than once.@end exampleBut explain what changed and in which methods it was changed:@example * java/io/ObjectOutputStream.java (putFields): Don't call markFieldsWritten(). Only create new PutField when currentPutField is null. (writeFields): Call markFieldsWritten().@end example@end itemizeThe above are all just guidelines.  We all appreciate the fact that writingChangeLog entries, using a coding style that is not ``your own'' and theCVS, patch and diff tools do take some time to getting used to.  So don'tfeel like you have to do it perfect right away or that contributionsaren't welcome if they aren't ``perfect''.  We all learn by doing andinteracting with each other.@node Programming Goals, API Compatibility, Hacking Code, Top@comment node-name, next, previous, up@chapter Programming GoalsWhen you write code for Classpath, write with three things in mind, andin the following order: portability, robustness, and efficiency.If efficiency breaks portability or robustness, then don't do it theefficient way.  If robustness breaks portability, then bye-bye robustcode.  Of course, as a programmer you would probably like to find sneakyways to get around the issue so that your code can be all three ... thefollowing chapters will give some hints on how to do this.@menu* Portability::                 Writing Portable Software                * Utility Classes::             Reusing Software* Robustness::                  Writing Robust Software               * Java Efficiency::             Writing Efficient Java            * Native Efficiency::           Writing Efficient JNI          * Security::                    Writing Secure Software@end menu@node Portability, Utility Classes, Programming Goals, Programming Goals@comment node-name, next, previous, up@section PortabilityThe portability goal for Classpath is the following:@enumerate@itemnative functions for each platform that work across all VMs on thatplatform@itema single classfile set that work across all VMs on all platforms thatsupport the native functions.@end enumerateFor almost all of Classpath, this is a very feasible goal, using acombination of JNI and native interfaces.  This is what you should shootfor.  For those few places that require knowledge of the Virtual Machinebeyond that provided by the Java standards, the VM Interface was designed.Read the Virtual Machine Integration Guide for more information.Right now the only supported platform is Linux.  This will change as thatversion stabilizes and we begin the effort to port to many otherplatforms.  Jikes RVM runs Classpath on AIX, and generally the JikesRVM team fixes Classpath to work on that platform. @node Utility Classes, Robustness, Portability, Programming Goals@comment  node-name,  next,  previous,  up@section Utility ClassesAt the moment, we are not very good at reuse of the JNI code.  Therehave been some attempts, called @dfn{libclasspath}, tocreate generally useful utility classes.  The utility classes are inthe directory @file{native/jni/classpath} and they are mostly declaredin @file{native/jni/classpath/jcl.h}.  These utility classes are

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -