Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Wish List: Java Object Replacement

DZone's Guide to

Wish List: Java Object Replacement

· Java Zone
Free Resource

Learn how to troubleshoot and diagnose some of the most common performance issues in Java today. Brought to you in partnership with AppDynamics.

I wish I could replace an object with another of the same type and the myriad references existing to the first one would automatically be redirected.

Obj o1 = new Obj("Red");
map.put("Ball", o1);
list.add(o1);
ball = o1;
Obj o2 = new Obj("Blue");
o1.replace(o2);

 

map.get("Ball") should return the blue ball.
list should contain blue ball.
ball == o2 should evaluate to true.

We can work around the situation by extra code in Obj using composition and method call redirection. Wouldn’t live be simpler if the support is native?

The security part could be controlled by providing a markable interface or annotation.

Real life examples? Substituting a player. Corporate mergers. Two pools joining to make a bigger pool.

From http://www.aloshbennett.in/weblog/2010/java/wish-list-java-object-replacement/

Understand the needs and benefits around implementing the right monitoring solution for a growing containerized market. Brought to you in partnership with AppDynamics.

Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}