aspose file tools*
The moose likes Performance and the fly likes secret clone discovered in performance test of Integer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "secret clone discovered in performance test of Integer" Watch "secret clone discovered in performance test of Integer" New topic
Author

secret clone discovered in performance test of Integer

John Davis
Ranch Hand

Joined: Nov 02, 2000
Posts: 189
In testing the performance of Integer objects in various settings, I discovered what may be a "secret" clone of the Integer object when used as a method parameter. My test passed a reference to an Integer object as a method parameter and then expected to print the new value for the Integer object which was computed by the called method. According to my documentation, this should have worked because the Integer reference variable was passed by value to the called method.
Is the Integer object being cloned unbeknowst to me when I use a reference to it as a parameter to a called method?
Michael Hildner
Ranch Hand

Joined: Oct 13, 2000
Posts: 297
Could you post this code?
(And Sheriff, I don't care about the book, I'm actually interested )
John Davis
Ranch Hand

Joined: Nov 02, 2000
Posts: 189
Michael
I was getting ready to post you this code when I
realized that the whole thing is just a mistake on my
part.
Since Integer is immutable a side effect could
never be expected. Sorry, my problem.
I needed a side effect, so I created my own wrapper
class MyInteger which has an increment method etc.
Then, when I pass MyInteger as a parameter to a
method, and the method runs the increment method, the
calling program gets to see this side effect.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: secret clone discovered in performance test of Integer