Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ClassLoaders in java

Posted on 2014-03-25
6
Medium Priority
?
982 Views
Last Modified: 2014-04-03
Two objects loaded by different class loaders are never equal even if they carry the same values.
This means a class is uniquely identified in the context of the associated classloader. This applies to singletons too, where each classloader will have its own singleton.

I was reading as above. I have not understood what it means.
please advise
Any links resources ideas highly appreciated. Thanks in advance
0
Comment
Question by:gudii9
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 12

Expert Comment

by:Sharon Seth
ID: 39955749
I do not think two classloaders(on the same JVM) can load the same object , it wld create conflicts when trying to access the class. But the same object on different JVMs is possible.
0
 
LVL 35

Expert Comment

by:girionis
ID: 39958275
It means that a class can be loaded by two different classloaders, and in the context of the JVM these classes are considered *not* the same, even if, in fact, they are byte-for-byte the same class. So if you have a class A which is loaded by both classloader X and classloader Y then, as far as the JVM is concerned, you have *two different* classes. This is what the phrase
a class is uniquely identified in the context of the associated classloader
means.
0
 
LVL 7

Author Comment

by:gudii9
ID: 39973090
how is classloader is different or related to JVM. In which practical scenario this situation happens? I never come across this scenario earlier. please advise
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 35

Expert Comment

by:girionis
ID: 39974295
All classloaders are loaded by the JVM. When the JVM starts it loads the bootstrap classloader, and this in turn loads all other classes, including the rest of the classloaders that will load their own classes and so on.
0
 
LVL 12

Assisted Solution

by:Sharon Seth
Sharon Seth earned 400 total points
ID: 39974725
I still do not believe there will be a practical scenario where a class will be loades by two classloaders . Class loading is hierarchial , in the sense that a classloader first checks if a class is already loaded by another lower level class loader , before actually loading it .
0
 
LVL 35

Accepted Solution

by:
girionis earned 1600 total points
ID: 39974767
A class is identified (among other things) in the context of the classloader as well. So two different classloader could load the same class twice. Here is a nice article on different ways you can get two different objects from two different classloaders.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

598 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question