This week's book giveaways are in the AI and JavaScript forums.
We're giving away four copies each of GANs in Action and WebAssembly in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • 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
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • 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 ]
 
Yeah. What he said. Totally. Wait. What? Sorry, I was looking at this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!