classloader

disable bytecode verification in java web start application

梦想与她 提交于 2019-12-31 05:05:07
问题 I have a java web start application and i need to disable bytecode verification from within the jnlp file. This can be done easily by setting JAVAWS_VM_ARGS=" -noverify " or by setting -Xverify:none but the documentation here says that web start does not support adding these arguments in jnlp file . I tried this : <j2se version="1.6+" java-vm-args="-noverify -showversion -verbose" > under resources tag but it skips -noverify and takes the other two. Any help is appreciated. 回答1: ... but the

When does Class#getClassLoader return null?

怎甘沉沦 提交于 2019-12-31 04:43:11
问题 Say I have some Java code: public class Widget { ...whatever } And some code that classloads the Widget : ClassLoader widgetLoader = Widget.class.getClassLoader(); Can widgetLoader ever be null ? Why/why not? If so, under what circumstances? 回答1: According to this method javadoc: Returns the class loader for the class. Some implementations may use null to represent the bootstrap class loader. This method will return null in such implementations if this class was loaded by the bootstrap class

InvokeExact on the object, whose type is dynamically loaded by classloader

安稳与你 提交于 2019-12-31 01:46:09
问题 I have spend whole day on this problem. My problem is how to make an MethodHandle.invokeExact invocation on an instance, whose class type is dynamically loaded at program runtime. To make problem more clear, i show my sample code below: Class<?> expClass = new MyClassLoader().load(....) //expClass is AddSample.class which is subclass of BaseTemplate BaseTemplate obj = expClass.getConstructor(...) .newInstance(...); MethodHandle myMH = MethodHandles.lookup().findVirtual(expClass, methodName,..

Find the ClassLoader loading a specific class

≯℡__Kan透↙ 提交于 2019-12-31 00:43:12
问题 Is there a way to determine which ClassLoader loads a specific class? Or more specifically from where a specific class is loaded? I've a situation where an old db driver class is loaded. I'd like to find the file where the old driver is loaded from. My initial approach is to set a debug point on the ClassLoader.loadClass(..) method and stop the vm once the class is getting loaded to see which classloader is loading it. Unfortunately the loadClass method is called so often that its difficult

Overriding default accessor method across different classloaders breaks polymorphism

≯℡__Kan透↙ 提交于 2019-12-30 18:31:21
问题 I come across to a strange behavior while trying to override a method with default accessor (ex: void run() ). According to Java spec, a class can use or override default members of base class if classes belongs to the same package. Everything works correctly while all classes loaded from the same classloader. But if I try to load a subclass from separate classloader then polymorphism don't work. Here is sample: App.java: import java.net.*; import java.lang.reflect.Method; public class App {

Adding MarvinFramework to a WebApp on Tomcat7

情到浓时终转凉″ 提交于 2019-12-30 11:14:13
问题 I have a Jersey WebApp running on Tomcat and want to integrate the MarvinFramework for ImageProcessing. Basically I want to reduce noise, grayscale and scale an Image for further processing. The Marvin Framework relies on custom Plugins for their specific prupose, and those Plugins I want to use. But since the Framwork has its own ClassLoader , that loads the plugins JAR dynamically at runtime from an absolute location inside the project, I am confused where to put the files or how to

PHPUnit loads all classes at once. Causes PHP Fatal error: Cannot redeclare class

泄露秘密 提交于 2019-12-30 07:01:36
问题 I've done my due diligence, but I don't think any of the questions so far have touched on this problem. I have a situation where my PHP code generates class definitions based on config properties. The class definitions are basically data holders and can have either: public properties or protected properties with a public interface that supplies getter/setters. In certain config cases, the generated CLASS NAMES WILL BE THE SAME but their FILE NAMES WILL BE DIFFERENT. In a real environment, the

Creating a ClassLoader to load a JAR file from a byte array

混江龙づ霸主 提交于 2019-12-29 03:40:28
问题 I'm looking to write a custom class loader that will load a JAR file from across a custom network. In the end, all I have to work with is a byte array of the JAR file. I cannot dump the byte array onto the file system and use a URLClassLoader . My first plan was to create a JarFile object from a stream or byte array, but it only supports a File object. I've already written up something that uses a JarInputStream : public class RemoteClassLoader extends ClassLoader { private final byte[]

Are static fields in Activity classes guaranteed to outlive a create/destroy cycle?

半腔热情 提交于 2019-12-29 03:04:31
问题 I frequently run into the problem that I have to preserve state between several invocations of an activity (i.e. going through several onCreate()/onDelete() cycles). Unfortunately, Android's support for doing that is really poor. As an easy way to preserve state, I thought that since the class is only loaded once by the class loader, that it would be safe to store temporary data that's shared between several instances of an activity in a static Bundle field. However, occasionally, when

Java Classloader - how to reference different versions of a jar

大憨熊 提交于 2019-12-28 04:01:28
问题 This is a common problem. I'm using 2 libraries A.jar and B.jar and these depend on different versions of the same jar. Let's say that at runtime I need THIS.x.x.x.jar MY.jar -> A.jar -> THIS.1.0.0.jar -> B.jar -> C.jar -> THIS.5.0.0.jar I can compile the specific jar (A.jar/B.jar) against its dependency but at runtime I've to load only 1 version. Which one? Loading only 1 dependency (the latest version) means that my code will probably throw runtime exceptions if the libraries are not