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 Class Already  Been Loaded 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 "Class Already  Been Loaded" Watch "Class Already  Been Loaded" New topic
Author

Class Already Been Loaded

Alec Lee
Ranch Hand

Joined: Jan 28, 2004
Posts: 569
Can a Java program identify if a class has been loaded by some other threads? Say, my program want to know if the StringBuilder class has been used before by some other threads.

If you want to ask why I need to do so. It is some how related to security. I want to know if some known malicous code has been executed in the JVM running my code.
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

You could ask the system ClassLoader if it loaded a certain class. But if the intruder used another classloader then you still no know nothing so I don't think that is the solution.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Alec Lee
Ranch Hand

Joined: Jan 28, 2004
Posts: 569
How do we ask the System Class loader if it has loaded a certain class or not?
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

java system class loader
Alec Lee
Ranch Hand

Joined: Jan 28, 2004
Posts: 569
Sorry, but which method(s) should we use? Just can't see any single method for testing this.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19651
    
  18

That's because this information isn't publicly available. And why would you need it? Simply try loading it; if it already has been loaded it will not load it again.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Class Already Been Loaded
 
Similar Threads
threading issue
Bytecode Manipulation of JRE Classes
Can I "hot-swap" a .class file in a running application?
Singleton pattern and thread issue
threading issue