views:

49

answers:

1

I am using the AWTUtilities class in my application to create custom window shapes. As far as I know, there is no other way to do it. It is a requirement.

The javadoc generation gives me this error: warning: com.sun.awt.AWTUtilities is Sun proprietary API and may be removed in a future release

What exactly does this mean? I can use it, but it may stop working with any release? Why put it in, then? More importantly, and the real question here, if Sun takes it out, will they likely replace it with another way to do the same thing? Is that what the warning is for?

I suppose I could just check for the presence of the AWTUtilities class before calling the code. But that's just obnoxious if I don't need to do it.

Does anyone have any experience with similar classes? Were they eventually accepted into the API and the warning removed or replaced with another method of doing the same thing? Do I need to be concerned about this?

FYI, I have read this:

http://stackoverflow.com/questions/1416869/how-to-distribute-awtutilities

+1  A: 

The Oracle documentation states:

Note: the com.sun.awt.AWTUtilities class is not part of an officially supported API and appears as an implementation detail. The API is only meant for limited use outside of the core platform. It may change drastically between update releases, and it may even be removed or be moved in some other packages or classes. The class should be used via Java Reflection. Supported and public API will appear in the next major JDK release.

JDK 7 has been a long time coming so it could be awhile. Whether you should use it is a risk management question that only your company can answer. If we are talking about an internal application where the deployed JRE can be guaranteed then you are not going to have a problem because you can guarantee a compatible JRE. If we are talking about deploying to external customers then you need to have a support plan if this provisional API ever changes.

A stable way to do this would be to create a Shell in SWT as per this snippet and then use the SWT_AWT bridge to get a Frame to use in your application:

java.awt.Frame frame = SWT_AWT.new_Frame(shell);

If you are just deploying to a single platform (like Windows) then tossing a single SWT jar plus the native library. If you are targeting multiple platforms then this becomes a pain.

So those are the two choice: deal with the AWTUtilities risk or use the SWT_AWT bridge.

rancidfishbreath
We cannot use SWT_AWT because we are creating custom shells. So we'll have to deal with the risk. Good to know that I don't have to worry about this class being removed until Java 7.
Erick Robertson