classloader

Make JVM use My Own Class Loader

心不动则不痛 提交于 2019-12-09 16:48:30
问题 I wrote my own class loader. I need all my classes to be loaded using my class loader. I have passed the VM the following: -Djava.system.class.loader=MyClassLoader Only the first referenced class in my package is being loaded using my class loader. Other classes in my package are being loaded using AppClassLoader . Here is what MyClassLoader looks like: import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.util.Enumeration; public class MyClassLoader extends

Difference between loadClass(String name) and loadClass(String name, boolean resolve)

…衆ロ難τιáo~ 提交于 2019-12-09 16:47:12
问题 What is the difference between loadClass(String name) and loadClass(String name, boolean resolve) ? The only difference I know is loadClass(String name, boolean resolve) calls findLoadedClass(String) if the resolve parameter is true? So when is true or false passed to resolve parameter ? I'm confused a lot between this two functions. Thanks. 回答1: The resolve parameter controls whether the class that's loaded is linked or not. During linking, static constants are initialized and have their

Loading Encrypted JarFile Via URLCassloader

。_饼干妹妹 提交于 2019-12-09 13:59:38
问题 I've been writing a little system to dynamically load AES encrypted jar files. My code: public static void main(String args[]) throws Exception { String jar = "http://site.com/api/rsc/test.jar"; List<URL> urls = new ArrayList<URL>(); urls.add(getURL(jar)); URL jarurl = urls.get(0); ObjectInputStream ois = new ObjectInputStream((new URL("http://site.com/api/rsc/key_1.txt").openStream())); Object o = ois.readObject(); DESKeySpec ks = new DESKeySpec((byte[])o); SecretKeyFactory skf =

Looking for basic example of using Apache Felix in dynamic loading of Jar file and instancing a class at runtime in Java

亡梦爱人 提交于 2019-12-09 13:09:41
问题 I tried implementing my own class loader based on some examples. However, I think it is not working as expected ( unable to reload Jar file etc. I see few references of recommending using OSGI or Apache Felix for handling Jar file loading. Is there any examples of loading Jar, instancing a class from the Jar? More details on what I am trying to accomplish..I have a Java command line application that essentially continuously runs. I want it to be able to reference JAR files dynamically at

How to launch jar with 'exec app_process' on android ICS

大城市里の小女人 提交于 2019-12-09 07:07:47
问题 I have 3 devices. 1.base on cm9(android 4.0.4). 2.htcg14(android 4.0.3) 3.moto me525 base on miui(android 2.2) they are all rooted. I exec the code below in the terminal on device 1 and 3,the process works fine. But device 2,it doesn't work. su export CLASSPATH=/sdcard/foo.jar exec app_process /system/bin xx.xx.Test '$@' log W/dalvikvm(12364): Exception Ljava/lang/NullPointerException; thrown while initializing Ljava/lang/System; W/dalvikvm(12364): Exception Ljava/lang

ClassLoader Leak - Are they worth solving?

拜拜、爱过 提交于 2019-12-09 05:24:56
问题 ClassLoader leaks usually result in java.lang.OutOfMemoryError: PermGen . In the instance of working on application servers you may see this as a result of many redeploys of a common application. The explanation and possible resolutions to this problem can be seen on these two links. (among others) http://dev.eclipse.org/blogs/memoryanalyzer/2008/05/17/the-unknown-generation-perm/ http://blogs.oracle.com/fkieviet/entry/classloader_leaks_the_dreaded_java Now for the most part they are easy to

Order of Tomcat Classloaders: common, shared, and server

青春壹個敷衍的年華 提交于 2019-12-09 05:09:15
问题 The Tomcat Class Loader HOW-TO documentation describes 4 different class loaders: Bootstrap System Common Webapp In the default catalina.properties file, however, there are properties defined for a shared and server class loader as well. In the default version of the file both of these properties are empty and the comments say: If left as blank, the "common" loader will be used as Catalina's "shared"/"server" loader. I have not been able to find any additional documentation about these class

Custom Java classloader not being used to load dependencies?

六月ゝ 毕业季﹏ 提交于 2019-12-09 04:37:28
问题 I've been trying to set up a custom classloader that intercepts classes to print out which classes are being loaded into the application. The classloader looks like this public class MyClassLoader extends ClassLoader { @Override public Class<?> loadClass(String name) throws ClassNotFoundException { System.out.println("Loading: " + name); return super.loadClass(name); } } It just spits out the name of all the classes it loads. However, when i try to run some code, import org.python.util

How to block access to some classes, when executing groovy scripts from java?

早过忘川 提交于 2019-12-08 20:51:37
问题 I'm pretty new to groovy, and scripting in java generally, and I really hope there is a simple solution for my problem. In our application, the users can execute groovy scripts which they write themselves, and we need to control what those scripts can and can not do. I read a lot of stuff about sandboxing groovy, but either I am looking at wrong places or I am overlooking the obvious. To make it simple, I have a small example which demonstrates the problem. This is my class loader which

PathMatchingResourcePatternResolver (spring) Usage

余生颓废 提交于 2019-12-08 15:58:33
问题 I'm using : PathMatchingResourcePatternResolver rr = new ...; rr.getResources("classpath*:**/*.class") to get all the classes from the classpath that is made of directories and jars. The call returns only classes from the directories; JAR files are ignored. The following call returns classes from JARs : rr.getResources("classpath*:org/**/*.class") Is that possible to get all the classes without knowing the base package name ? 回答1: It is mentioned in the documentation that when using