• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

2 classloaders 1 JVM

 
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
 
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
 
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
 
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.
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • 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
Scala Postgres Database Linux
  • 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 ]
 
And then the entire population worshiped me like unto a god. Well, me and this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic