This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes 2 classloaders 1 JVM Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "2 classloaders 1 JVM" Watch "2 classloaders 1 JVM" New topic
Author

2 classloaders 1 JVM

Nimish Kanojia
Greenhorn

Joined: Mar 09, 2004
Posts: 6
Hi
Call between one object in 1 classloader and another object in another classloader within a single JVM - is it pass by value or pass by reference?
Bye
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
This is not covered in the SCJP Exam - I'm moving this to Java in General (Intermediate).
Corey


SCJP Tipline, etc.
Jean-Francois Briere
Ranch Hand

Joined: Mar 03, 2004
Posts: 101
I'm not sure I understand your question about the two class loaders.
However, there is something you should know about pass by value -vs- pass by reference in JAVA.
This is a very very very simple rule:
In JAVA, everything is passed by balue.
There is no exception to that rule, none.
Cheers
JFB
David Weitzman
Ranch Hand

Joined: Jul 27, 2001
Posts: 1365
The use of multiple classloader hierarchies has no effect on the behavior of the language, only on the ability of the bytecode verifier to resolve references between classes.
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Originally posted by Jean-Francois Briere:

This is a very very very simple rule:
In JAVA, everything is passed by balue.
There is no exception to that rule, none.

That's evidentally false.
Nearly everything is passed by reference, except primitiv types (int, boolean, byte, char, float, ...).
Arrays of primitiv types are passed by reference too.


http://home.arcor.de/hirnstrom/bewerbung
Jean-Francois Briere
Ranch Hand

Joined: Mar 03, 2004
Posts: 101

Originally posted by Stefan Wagner:
That's evidentally false.
Nearly everything is passed by reference, except primitiv types (int, boolean, byte, char, float, ...).
Arrays of primitiv types are passed by reference too.

Stefan,
This an honest mistake from your part.
But it IS a mistake.
A mistake that many programmers are doing though, so don't beat yourself :-)
I repeat, very loud and clear:
In JAVA, everything is passed by value.
It's as simple as that.
And there is absolutely NO exception whatsoever.
You should read the following from JavaRanch Campfire.
Cheers
JFB
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

I repeat with enthusiasm:

Java is pass by value.

A very good article!
Please excuse my former posting.
(editing for this PS
It's a wonder how certain I used parameters till today - but now I may explain WHY it workes
[ March 16, 2004: Message edited by: Stefan Wagner ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: 2 classloaders 1 JVM
 
Similar Threads
What is ClassLoader
Patching Java applications without restarting application
Some basic questions
Where does static variables live?
Basic Questions