Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-ant-dev] Fw: [platform-ui-dev] Code warnings that should be fixed

I have cleaned up the platform debug, platform ant, and jdt debug code as
per this
"code cleanup" posting from the platform ui list

Darins

> Olivier from the jdt core team has pointed out some problems we have in
the
> ui and jdt components that should be addressed. I am going to deal with
> those in the platform ui portions of the code but those of you covering
> platform text, external tools and jdt should look at your code for these
> issues. Both of them can be found by using the Java Compiler preference
> page to set the priorities higher on these problems.
>
> 1) Unused local variables. The VM will allocate space for an Object that
is
> never used and the garbage collector will have to clean it up.
>
> 2) Static members accessed through a non static reference.
>
> This is the following:
>
> Say your plugin has a default instance and a static method myStatic(). It
> is the difference between calling
>
> MyPlugin.myStatic()
>
> and
>
> myPlugin.getDefault().myStatic().
>
> The second (incorrect) scenario has a series of issues
> 1) The compiler cannot remove what preceeds the static message send,
which
> could potentially have a side-effect - especially if you are creating new
> instances to get at the API.
> 2) This style reduces the readability and the maintability of the code..
> This code is still a valid piece of code even with JDK 1.4.1. It is
simply
> a style that should be avoided (see point 10.2 of the Java conventions).
> 3) In the case of constants used in switch statements this is invalid
code
> in JDK1.2.2, (although it is fixed since 1.3).
>
> Tod
>
>
>
> _______________________________________________
> platform-ui-dev mailing list
> platform-ui-dev@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/platform-ui-dev



Back to the top