简体   繁体   English

使用非Sun JRE / JDK的动机是什么?

[英]What is the motivation for using a non-Sun JRE/JDK?

This question got me thinking, assuming a Sun JDK is available, why would I use anything else? 这个问题让我思考,假设Sun JDK可用,我为什么要使用其他东西? Is there a good technical reason for using a different compiler? 使用不同的编译器有一个很好的技术原因吗?

Well, I'm sure people don't realize it, but Eclipse has its own compiler. 好吧,我确信人们没有意识到这一点,但Eclipse有自己的编译器。 So, when you are using Eclipse, you are using a nun-Sun(Oracle) JDK. 因此,当您使用Eclipse时,您使用的是nun-Sun(Oracle)JDK。

There are many advantages to using this too. 使用它也有很多好处。 First off, Eclipse actually has a few compilers built in. The one the provides the most benefit, IMO, is the one that provide the red underlines as you type. 首先,Eclipse实际上内置了一些编译器。提供最大好处的IMO是在键入时提供红色下划线的那个。

Another thing that the Eclipse compiler does is 'compiles' uncompilabe code. Eclipse编译器所做的另一件事是“编译”uncompilabe代码。 So, if you run a piece of code, and never hit the code that couldn't compile, the code will run without error. 因此,如果您运行一段代码,并且从未点击无法编译的代码,代码将运行而不会出错。 Otherwise you get a NotYetCompiledException . 否则,您将收到NotYetCompiledException (Or something like that) (或类似的东西)

A lot of people are answering a different question than what you asked. 很多人回答的问题不同于你提出的问题。 The JDK used to compile the code is different from the JVM used to run it. 用于编译代码的JDK与用于运行代码的JVM不同。

Because most optimization occurs JIT, the quality of generated code from your compiler is not very important. 因为大多数优化都发生在JIT中,所以编译器生成的代码质量不是很重要。 This leaves the reason to use a particular JDK as: 这留下了使用特定JDK的原因:

  1. Compile performance. 编译性能。 At one time IBM Jikes was a very fast compiler. IBM Jikes曾经是一个非常快速的编译器。
  2. Error reporting. 错误报告。 Compilers built into IDE's usually have superior error reporting. IDE内置的编译器通常具有出色的错误报告功能。
  3. Standards compliance. 符合标准。 For example, at one time IBM provided an extra overloaded method in StringBuilder. 例如,IBM曾一度在StringBuilder中提供了额外的重载方法。 If that overload was selected at compile time then your code would fail at runtime on a Sun JVM. 如果在编译时选择了该重载,那么您的代码将在运行时在Sun JVM上失败。

If you're a WebLogic user, JRockit makes a lot of sense. 如果您是WebLogic用户,JRockit很有意义。 It's a terrific JVM. 这是一个了不起的JVM。 I'm not sure that it runs on all operating systems, though. 不过,我不确定它是否可以在所有操作系统上运行。

Wait a second, if you use JRockIt or whatever other JRE you are going to lose portability, no matter what commercials tell you: it is never 100% portable neither 100% standard. 等一下,如果您使用JRockIt或其他任何JRE,您将失去便携性,无论商业广告告诉您:它永远不是100%便携式,也不是100%标准。

In fact many consider making you switch the JRE part of the Embrace, extend and extinguish strategy, sometimes is the "only recomended way" to solve an issue. 事实上,许多人考虑让你切换拥抱的JRE部分,扩展和消除策略,有时是解决问题的“唯一推荐方式”。

http://en.wikipedia.org/wiki/Embrace,_extend_and_extinguish http://en.wikipedia.org/wiki/Embrace,_extend_and_extinguish

Promise, I suffered this years ago and paid for it :( 承诺,我多年前遭受了并为此付出了代价:(

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM