Questions tagged [dynamic-class-loaders]

The Java Classloader is a part of the Java Runtime Environment that dynamically loads Java classes into the Java Virtual Machine.

Dynamic Class Loading allows the loading of java code that is not known about before a program starts. Many classes rely on other classes and resources such as icons which make loading a single class unfeasible. For this reason the ClassLoader (java.lang.ClassLoader) is used to manage all the inner dependencies of a collection of classes. The Java model loads classes as needed and need not know the name of all classes in a collection before any one of its classes can be loaded and run.

188 questions
31
votes
2 answers

how to build an APK and separate libraries that the app loads dynamically

The short summary is: How do I build an APK and separate libraries (by which I mean sets of classes (and ideally, resources too) in some form, such as JAR, AAR or DEX files), but not include those libraries in the APK; instead, the app loads them at…
25
votes
8 answers

Java Class Loaders

Can anyone point me a good resource or explain me about the concept behind Class Loaders? I found the following resource on class loaders http://www.onjava.com/lpt/a/5586 but still no help. The following questions may look silly but trying to answer…
BlueGene
  • 1,071
  • 1
  • 20
  • 30
25
votes
3 answers

Sharing dynamically loaded classes with JShell instance

Please view the edits below I'm trying to create a JShell instance that gives me access to, and lets me interact with objects in the JVM it was created in. This works fine with classes that have been available at compile time but fails for classes…
Joba
  • 777
  • 7
  • 24
24
votes
5 answers

Dynamic class loading in Python 2.6: RuntimeWarning: Parent module 'plugins' not found while handling absolute import

I am working on a plugin system where plugin modules are loaded like this: def load_plugins(): plugins=glob.glob("plugins/*.py") instances=[] for p in plugins: try: name=p.split("/")[-1] name=name.split(".py")[0] …
pehrs
  • 1,481
  • 2
  • 15
  • 21
18
votes
3 answers

Custom Class Loading in Dalvik with Gradle (Android New Build System)

As per the introduction of Custom Class Loading in Dalvik by Fred Chung on the Android Developers Blog: The Dalvik VM provides facilities for developers to perform custom class loading. Instead of loading Dalvik executable (“dex”) files from …
rfgamaral
  • 16,546
  • 57
  • 163
  • 275
16
votes
8 answers

How can I modify a java.lang class on the fly?

I'm looking for a way to add fields to an Thread on the fly by rewriting the byte code and reloading the class, not sure if it is at all possible. Any pointers welcome. I found some info on modifying and loading a class, and I know JRebel can…
14
votes
3 answers

Dynamic loading a class in java with a different package name

Is it possible to load a class in Java and 'fake' the package name/canonical name of a class? I tried doing this, the obvious way, but I get a "class name doesn't match" message in a ClassDefNotFoundException. The reason I'm doing this is I'm…
C. Ross
  • 31,137
  • 42
  • 147
  • 238
11
votes
1 answer

How class loading is done by using -Xbootclasspath/p:path?

I've seen -Xbootclasspath/p:path being used for loading class dynamically can you please elaborate and explain by providing example.
NEO
  • 161
  • 1
  • 3
  • 10
10
votes
3 answers

How to remove this use of dynamic class loading or replace this class loading?

othersMap.put("maskedPan", Class.forName("Some Class")); Remove this use of dynamic class loading. Rule Changelog Classes should not be loaded dynamically Dynamically loaded classes could contain malicious code executed by a static class…
Bhaskar Saikia
  • 172
  • 1
  • 2
  • 15
8
votes
2 answers

Custom class loading/overriding Android-native classes

Main goal is to override Android system class (Activity, View etc) with my own implementation. http://android-developers.blogspot.com/2011/07/custom-class-loading-in-dalvik.html ClassLoader for custom class loading is implemented, loading non-system…
user1083195
8
votes
1 answer

OneJar and dynamic class loading

We're currently investigating the use of OneJar in our application (for a number reasons), but our application makes use of a number of custom URLClassloaders to load application extensions. When bundled as a "OneJar" Jar, we get ClassNotFound…
MadProgrammer
  • 343,457
  • 22
  • 230
  • 366
7
votes
1 answer

Custom ClassLoader, how to use?

I am trying to use a custom class loader to load all the dependencies needed for the application. I've implemented the customerClassLoader following the site: https://www.javacodegeeks.com/2013/03/java-handmade-classloader-isolation.html However, I…
Minisha
  • 2,117
  • 2
  • 25
  • 56
6
votes
1 answer

Using Java Compiler API to compile multiple java files

Hi I have requirement to create ,compile and load java classes run time. Using FTL i am creating java source files , and able to compile the source if there is no dynamic dependency. To elaborate with an instance, I have two java source file, one…
Satheesh Cheveri
  • 3,621
  • 3
  • 27
  • 46
6
votes
1 answer

how does system bundle has access to system packages?

I'm exploring how OSGI is implemented for the last couple of weeks. I know that each bundle uses its own class loader to load its classes. As part of my investigation, I understood that parent of every bundle's class loader is null i.e boot class…
6
votes
0 answers

Different behaviors between Unsafe defineAnonymousClass and ClassLoader

I used classloader and Unsafe::definedAnonymous() to load generated bytecode byte[]. The usage of Class returned by classLoader.loadClass() succeeds while it fails with c.getMethod() in which c=Unsafe.defineAnonymousClass() API. So is the generated…
1
2 3
12 13