Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

2 classloaders 1 JVM

 
Nimish Kanojia
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is not covered in the SCJP Exam - I'm moving this to Java in General (Intermediate).
Corey
 
Jean-Francois Briere
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jean-Francois Briere
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic