Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javac equality operators in java 7 and java 8

Tags:

java

I have to write a little paper about "javac tools" in Java 8 for my class.

Here is something i dont understand. Oracle says, that in the 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."

"Whats 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 don´t really understand that. I thought it worked just fine in Java 7. Does anybody have an idea what i missed? What wasn´t "enforced correctly" in Java 7?

If anybody has an answer, can you tell me where you found it, if you didnt find out by coincidence ;).

like image 914
javaBeginner Avatar asked Apr 29 '26 17:04

javaBeginner


1 Answers

Here is a link to a bug report that reports one particular case where javac 7 would compile a == test which was not valid according to the JLS. Even though the bug is marked as fixed in 2010, discussions indicate that it was still manifesting in 2013.

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

like image 125
Andrzej Doyle Avatar answered May 01 '26 06:05

Andrzej Doyle