Skip to main content

Don't Get Me Wrong

Posted by editor on July 27, 2006 at 6:46 AM PDT


A thin line between == and equals()

Most Java developers have learned the difference between == and .equals(), that the former means that two objects share the same memory address, while the latter is whatever you choose to make it, and usually means that some or all of the fields of two objects are equal. And with this knowledge fully grasped, you go off confident in the ability to determine identity, the ability to distinguish objects from one another.

Not so fast, dude.

Peter Becker brings up some suprising issues with common-sense ideas in today's Feature Article. At risk of giving away the big suprise of the article, You Are What You Is: Defining Object Identity, consider the Set collection, which allows at most one instance of an object to exist in the set. The test for this is performed with equals(). Now throw mutability into the mix. What happens when you add two objects to a set, then use set methods on one to make it, in effect, equal() to the other. I'll give you a hint: it's not pretty.

Read on for what this means for real-life Java programming and what you should consider doing about it.


In Java Today,

Version 1.3.5 of the Hudson build-monitoring system has been released. You could consult the changelog, or just check out Kohsuke Kawaguchi's blog Hudson 1.35 posted. "One of many improvements that came out of this is to speed up CVS changelog computation. When you are doing a continuous build, every build usually contains only a small number of changes. In Hudson 1.35, Hudson first runs "cvs update", then use its output to determine what files are changed. Hudson then uses this to significantly reduce the amount of traffic for the "cvs log" command, which is used to compute the changelog."

ONJava blogger Paul Browne has met up with a group of local Java developers to figure out What Dublin Java Developers think you should be learning... You can read the entire virtual Java meetup, or just scan Paul's summary of the top to-do's, which include web services and SOA's (with some reservations), and a fresh look at EJB3 and NetBeans.

With the rise of Ajax comes the need to dispel the myths of this hot property and pointedly deal with the issues that arise during its use. In Ease the integration of Ajax and Java EE, Patrick Gan examines the potential impacts throughout the full development life cycle of introducing Ajax technology into Java EE Web applications. In several cases, he notes the strengths of Direct Web Remoting (DWR) as a Ajax framework that does a particularly good job of dealing with Ajax problems.


In today's Forums,
ljnelson digs into authentication challenges in
JAAS and Glassfish: progress:
"What's been so tantalizing about Glassfish is that it's almost there. The packaged application client ships with a Configuration, and clearly something somewhere calls the equivalent of LoginContext.login(), but it isn't that call exactly, because the Subject is never actually created. Instead, the buck seems to stop at the LoginModule. Anyhow, I'd be curious to know from any Glassfish committers why, as long as you accomplish authentication via LoginModules, you don't allow an application client to accomplish authentication via the next rung up the ladder--the LoginContext. Or, I'd be curious to know what wrong path I've headed down that's led me to this conclusion, and would love to hear that actually, this is entirely possible."

Fabrizio Giudici joins the crowd discussing a new photographic application in
Re: [JAI] Photoshop In Java:
"I'm working on a thing that, using similar words, is a 100% Java mini version of Lightroom, I mean, at the moment there's the cataloging, browsing tools etc. (look at bluemarine.tidalwave.it). There's no editing part at all. Sounds like it's pretty complementary to your work. I've planned to add the editing part, but before start working on it I'm searching for existing opensource applications and developers that would like to work together in some way. I've also published a image i/o plugin for reading camera-raw files - the next step is working on an opensource 100% Java version of the camera raw plugin by Adobe. Being able to base it on existing filtering code would be great."


Rémi Forax explains his role in a change to SwingWorker's process signature in today's Weblogs. "Why the signature of the SwingWorker's process method changed ? Perhaps not only to bother developers that already play with JDK betas."

Calvin Austin discusses
What PHP needs to learn from Java, detailing
"Why PHP finds it hard to dislodge Java from the Enterprise"

On the topic of Pluralization, Tom White writes:
"tool builders can now easily add pluralization to their applications using Inflector, a new Java library hosted on java.net."


In today's java.net
News Headlines
:

Registered users can submit news items for the href="http://today.java.net/today/news/">java.net News Page using our
news submission
form
. All submissions go through an editorial review before being
posted to the site. You can also subscribe to the href="http://today.java.net/pub/q/news_rss?x-ver=1.0">java.net News RSS
feed.


Current and upcoming Java
Events
:

Registered users can submit event listings for the href="http://www.java.net/events">java.net Events Page using our href="http://today.java.net/cs/user/create/e">events submission form.
All submissions go through an editorial review before being posted to the
site.


Archives and Subscriptions: This blog is delivered weekdays as
the Java
Today RSS feed
. Also, once this page is no longer featured as the
front page of java.net it will be
archived along with other past issues in the href="http://today.java.net/today/archive/">java.net Archive.

A thin line between == and equals()