Javac equality operators in java 7 and java 8

I need to write a small article about "javac tools" in Java 8 for my class.

Here's what I don't understand. Oracle says in new Java 8: "The type rules for equality operators in the Java Language Specification (JLS) section 15.21 are now correctly enforced by the javac command."

"What's New in Java 8": http://www.oracle.com/technetwork/java/javase/8-whats-new-2157071.html

Java Language Specification: http://docs.oracle.com/javase/specs/jls/se8/jls8-diffs.pdf

I do not understand this. I thought this works fine in Java 7. Does anyone have an idea what I missed? What was not "done right" in Java 7?

If anyone has an answer, can you tell me where you found it if you didn't find out by coincidence;).

+3


source to share


2 answers


Here is a link to a bug report that reports one specific case where javac 7 compiled a test ==

that was invalid according to the JLS. Although the bug is flagged as fixed in 2010, discussions indicate that it is still showing up in 2013.



In short, I would consider this Java 8 "feature" to really be a bug fix. They didn't actually change the language itself (as defined by the JLS) or added additional standard library functionality. They just fixed a bug that ideally would never have been there in the first place.

+4


source


Given the time, this is most likely a reference to JDK-8013357 :

This code shouldn't compile:



class Main {
  public boolean func(Object obj) {
    return obj == 0;
  }
}

      

But javac (since JDK 7 accepts it).

0


source







All Articles