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

📄 hacking.texinfo

📁 linux下建立JAVA虚拟机的源码KAFFE
💻 TEXINFO
📖 第 1 页 / 共 5 页
字号:
@itemBecause the output of different compilers differs, we havestandardized 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 @bullet@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* Branches::                    * Writing ChangeLogs::          @end menu@node Branches, Writing ChangeLogs, Hacking Code, Hacking Code@comment node-name, next, previous, up@section Working with branchesSometimes it is necessary to create branch of the source for doing newwork that is disruptive to the other hackers, or that needs newlanguage or libraries not yet (easily) available.After discussing the need for a branch on the main mailinglist withthe other hackers explaining the need of a branch and suggestion ofthe particular branch rules (what will be done on the branch, who willwork on it, will there be different commit guidelines then for themainline trunk and when is the branch estimated to be finished andmerged back into the trunk) every GNU Classpath hacker with commitaccess should feel free to create a branch. There are however a coupleof rules that every branch should follow:@itemize @bullet@item All branches ought to be documented in the developer wiki at@uref{http://developer.classpath.org/mediation/ClasspathBranches}, sowe can know which are live, who owns them, and when they die.@item Some rules can be changed on a branch.  In particular the branchmaintainer can change the review requirements, and the requirement ofkeeping things building, testing, etc, can also be lifted.  (Theseshould be documented along with the branch name and owner if theydiffer from the trunk.)@item Requirements for patch email to classpath-patches and for paperwork@strong{cannot} be lifted. See @ref{Requirements}.@item A branch should not be seen as ``private'' or``may be completely broken''. It should be as much as possiblesomething that you work on with a team (and if there is no team - yet- then there is nothing as bad as having a completely broken build toget others to help out). There can of course be occasional breakage, butit should be planned and explained. And you can certainly have a rulelike ``please ask me before committing to this branch''.@item Merges from the trunk to a branch are at the discretion of thebranch maintainer.@item A merge from a branch to the trunk is treated like any other patch.In particular, it has to go through review, it must satisfy all thetrunk requirements (build, regression test, documentation).@item There may be additional timing requirements on merging a branch tothe trunk depending on the release schedule, etc.  For instance we maynot want to do a branch merge just before a release.@end itemizeIf any of these rules are unclear please discuss on the list first.@menu* Writing ChangeLogs::          @end menu@node Writing ChangeLogs,  , Branches, 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 @bullet@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't

⌨️ 快捷键说明

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