Toolkit returns references to proprietary Sun APIs?
I just upgraded our project to JDK 1.6, and on compilation, I have a test class that implements java.awt.Toolkit and implements the methods to do nothing special (other than capture the call to the beep command).
(This is an old test that should probably be rewritten in several ways (either mock it or wrap that functionality in a simple inter开发者_开发百科face. However, regardless of the badness of the test) the compiler now spits out a bunch of warnings like this:
[19:50:10]: [javac] MemoryManagerTest.java:14: warning: java.awt.dnd.peer.DragSourceContextPeer is Sun proprietary API and may be removed in a future release [19:50:10]: [javac] import java.awt.dnd.peer.DragSourceContextPeer
First it is interesting that something with a package called java.awt.dnd.peer would be a sun proprietary API (although obviously the implementation is), but is this message bogus, or is it really true? And if it is true, what does that say about the whole Toolkit class which is tied to those interfaces?
You could have checked the API documentation and found, that none of the classes in java.awt.dnd.peer are listed, and hence implementation specific for the Sun VM. Even if the Toolkit class itself is part of the public API, the implementation of the class is of course also VM specific and may use other proprietary Sun-internal classes.
精彩评论