Details
-
Task
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
None
-
None
-
None
Description
(It is recommended you read this with good humor, like Think Geek)
While building Netbeans, a number of warnings show up. We should fix that.
For the sake of organization, we should probably open a new task for each module. This will be the root/umbrella task. The main project heads should take a look at this task and update it with official stuff.
We should probably slay warnings in this order:
- Warnings that don't require changes to other modules (like API changes). Examples would be changing raw types to non-raw types or something that would cause another module to not build after the warning has be properly dealt with.
- Warnings that Do require changes to other modules (see previous entry for examples)
- Those evil warnings that don't leave any links behind. Here are some examples:
warning: [options] bootstrap class path not set in conjunction with -source 1.7 /Volumes/Data/Code/<snip>/incubator-netbeans/nbbuild/build/public-package-jars/org-netbeans-api-annotations-common.jar(org/netbeans/api/annotations/common/NonNull.class): warning: Cannot find annotation method 'when()' in type 'Nonnull': class file for javax.annotation.Nonnull not found warning: unknown enum constant When.ALWAYS reason: class file for javax.annotation.meta.When not found /Volumes/Data/Code/<snip>/incubator-netbeans/nbbuild/build/public-package-jars/org-netbeans-api-annotations-common.jar(org/netbeans/api/annotations/common/NullAllowed.class): warning: Cannot find annotation method 'when()' in type 'Nonnull' warning: unknown enum constant When.MAYBE /Volumes/Data/Code/<snip>/incubator-netbeans/nbbuild/build/public-package-jars/org-netbeans-api-annotations-common.jar(org/netbeans/api/annotations/common/CheckForNull.class): warning: Cannot find annotation method 'when()' in type 'Nonnull' warning: unknown enum constant When.MAYBE warning: Supported source version 'RELEASE_6' from annotation processor 'org.netbeans.modules.openide.util.NbBundleProcessor' less than -source '1.7' warning: No processor claimed any of these annotations: org.netbeans.api.annotations.common.NullAllowed,org.netbeans.api.annotations.common.CheckForNull,org.netbeans.api.annotations.common.NonNull
The following guide-lines should be followed while slaying warnings:
- You shall make every effort to resolve the warning without suppressing it. This may involve one or more of the following (non-inclusive):
- Adding a new variable so assignments are not done to method parameters
- Adding a variable followed with an "assert var != null" to let the IDE know that it can't be null
- In the second pass, breaking APIs so raw types and such are not used if possible
- You shall suppress the warning on the smallest scope possible. Why? Warnings exist for a reason. They are there to tell you that you did something wrong, unless that was your intention and you know what you are doing. That is what @SuppressWarnings is for. If (heaven forbid) you suppress all warnings in a class file, you may be (figuratively) slain, so DON'T!
- The following (in my opinion) is a good way to suppress a warning on a line:
@SuppressWarning("unchecked") Object shush = bar = (Foo<Bar>)foo;
- You may want to add dummy return values to some void methods to enable suppression via the above method.
- If you do suppress a warning, and it is not obvious why it was suppressed, document it! Leave a comment that says why it was suppressed. The following is an example:
//the following is intentional //the method is expected to return an constant array @SuppressWarnings("OverridableMethodCallInConstructor") List<Foo> shush = ImmutableList.copyOf(getSupportedTypes());
I think that is all for now...