[英]Why remove dependency from java.awt?
In Selenium's Point class Javadocs , it states that it is: 在Selenium的Point类Javadocs中 ,它声明为:
A copy of java.awt.Point, to remove dependency on awt.
java.awt.Point的副本,用于删除对awt的依赖。
What is gained by this? 这有什么收获?
Well, if you wanted to import the entire selenium class, you'd do something like this: 好吧,如果您想导入整个硒类,则可以执行以下操作:
import org.openqa.selenium.*;
If you wanted to use point, then you'd also have to do: 如果要使用点,则还必须执行以下操作:
import java.awt.point;
even if you weren't going to use any other part of the java.awt
package. 即使您不打算使用
java.awt
包的任何其他部分。
So, by doing this, you never have to include java.awt
unless explicitly using it- hence, no dependency on java.awt
. 因此,通过执行此操作,除非明确使用它,否则不必包含
java.awt
,因此不依赖于java.awt
。
This was probably done because AWT is known to run differently on different platforms, which defeats one of the key philosophies of Java- WORA (Write Once Run Anywhere). 之所以这样做是因为已知AWT在不同平台上的运行方式不同,这违背了Java-WORA(一次写入,可在任何地方运行)的主要思想之一。 You don't want something that's supposed to be platform independent like Selenium to depend on something heavyweight like AWT.
您不希望像Selenium这样的本应独立于平台的东西依赖于像AWT这样的重量级东西。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.