Questions tagged [classloader]

A class loader is an object that is responsible for loading classes in Java.

A class loader is an object that is responsible for loading classes in Java.

Given the binary name of a class, a class loader should attempt to locate or generate data that constitutes a definition for the class. A typical strategy is to transform the name into a file name and then read a "class file" of that name from a file system. A class loader may also chose to delegate to another class loader. It may do this before or after doing a normal lookup.

Every Class object contains a reference to the class loader that defined it. This class loader is used by the runtime for linking to other classes referenced by this class. Together with the name of the class the defining class loader uniquely identifies a class. It's therefore possible to have several classes in with the same name in Java as long as they have a different defining class loader.

4126 questions
2
votes
1 answer

Android multi dex project setup

I am creating a multi-dex project setup by following this post: http://android-developers.blogspot.fr/2011/07/custom-class-loading-in-dalvik.html Everything goes on successfully, and next, I'd like to separate the secondary dex into a library…
Zennichimaro
  • 5,236
  • 6
  • 54
  • 78
2
votes
2 answers

How to change eclipse plugin's default parent-first classloader policy to child-first classloader policy?

I want to change the behavior of eclipse's parent-first classloader policy to child-first classloader policy. The scenario would be : Plugin A has class C in dependent external jar. When the classloader of the jar looks for "META-INF" folder - it…
deepthinker121
  • 95
  • 1
  • 2
  • 9
2
votes
3 answers

How to access class fields of a class that I only know it by its string name?

For instance, I have a class called "My_Class_X123.java" like this : public class My_Class_X123 // This file was generated by a java program { static String ABC[]={"1","2",...}; int XYZ=0; } When I wrote my program I didn't know there would…
Frank
  • 30,590
  • 58
  • 161
  • 244
2
votes
3 answers

Class A cannot be cast to Class A after dynamic loading

Let's say I have: object GLOBAL_OBJECT{ var str = "" } class A(_str: String){ GLOBAL_OBJECT.str = _str } and I would like to create 2 copies of GLOBAL_OBJECT (for tests), so I am using different classloader to create obj2: val obj1 = new…
IProblemFactory
  • 9,551
  • 8
  • 50
  • 66
2
votes
5 answers

Classloader vulnerability reproducing procedure in struts 1.1

In Struts1, I heard that there is a classloader vulnerability issue which is cause by CVE-2014-0114. But I am unable to reproduce this respect to my project. Can anyone help me how to reproduce this issue. I googled but not get any procedure of…
SkyWalker
  • 28,384
  • 14
  • 74
  • 132
2
votes
1 answer

Load classes in WEB-INF/classes via a Tomcat Context LifecycleListener

I have a requirement to load a given class via a . I'm trying read class annotations like @WebService that are mentioned in classes. But, I'm getting ClassNotFoundException since the classloader of org.apache.catalina.LifecycleListener which is the…
2
votes
4 answers

How much time a java class resides in memory

I am thinking about how much a class resides in memory in case it is not being accessed by other objects in memory? for example suppose I have some class like this: public class OrderNumber { private static long counter = 0; public static long…
Muhammad Hewedy
  • 29,102
  • 44
  • 127
  • 219
2
votes
2 answers

ClassLoader error with Reflecions 0.9.9-RC1 in Weblogic11g

I have a problem deploying an EAR application on Weblogic 10.3.5 using Reflections 0.9.9-RC1 jar. With default classloader (weblogic.utils.classloaders.ChangeAwareClassLoader@396e8d0 finder: weblogic.utils.classloaders.CodeGenClassFinder@5bcfadd) I…
JSP749
  • 127
  • 1
  • 3
  • 12
2
votes
2 answers

Java: When DLLs are loaded by a ClassLoader where are they stored in memory?

My understanding is that the .dlls are loaded into java.library.path by a ClassLoader but where are they stored in memory after System.loadLibrary() and System.load() is called from a non-static procedure?
amadib
  • 868
  • 14
  • 33
2
votes
1 answer

In Java, how can I run a static method whenever my class gets loaded or unloaded?

I have a class that uses static methods to wrap remote API calls. Generally speaking, I don't want my API server to "listen" for these calls all the time, but instead only listen when the class is being used by a program. So I need a way to tell the…
user3470440
  • 221
  • 1
  • 2
  • 6
2
votes
0 answers

How to load JavaAgent and run method from it?

I'm new in JavaAgent concept, so maybe this issue isn't complicated. But I hope some discussion and knowledge arrangement will be helpful (not only for me). So - what I want to do? I would like to load external jar library when I start my…
oundru87
  • 43
  • 1
  • 8
2
votes
0 answers

How can I create memory sandbox for objects using ClassLoaders in Scala?

I am trying to create a dynamically-loaded set of Scala classes (and objects), held in a 'sandbox' by a ClassLoader (all memory, resources, threads, etc. held within the sandbox). When refreshed, I want all memory/static objects held in the class…
Greg
  • 10,696
  • 22
  • 68
  • 98
2
votes
2 answers

tomcat 5.5 web.xml change WEB-INF/lib directory

I have a jruby rails app that has some jar dependencies in rails lib/java. I prefer this to just putting them straight in lib as it separates my java libs from ruby libs. Works locally using jruby. Problem is, on deploy, tomcat is looking for a…
brad
  • 31,987
  • 28
  • 102
  • 155
2
votes
1 answer

Lock contention on WebappClassLoader in Grails application under load

I am profiling a Grails web application with JProfiler and JConsole and am observing a phenomenon I am unable to fully understand. The setup I am profiling is as follows: A Grails web application built with maven as WAR and deployed to Tomcat. A…
lost
  • 1,449
  • 1
  • 13
  • 17
2
votes
3 answers

Why does ClassLoader.loadClass ALWAYS throw ClassNotFoundException in android?

Take a look at: Context contxt = createPackageContext("com.exam.provider", CONTEXT_IGNORE_SECURITY); // I know, the package must be (and IS) already installed ;-) ClassLoader loader = contxt.getClassLoader(); …
Joseph_Marzbani
  • 1,796
  • 4
  • 22
  • 36