classloader

accessing to classes of app from dex file by classloader

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-12 07:38:35
问题 I have a app that recieve a dex file from server then save it on sdcard and load it for doing some functions.I am loading a my app's class from my dex file as following dex file public class Main { public void onCreate() { System.out.print("------------onCreate------------"); try { final ClassLoader classloader = ClassLoader.getSystemClassLoader(); final Class<Object> classToLoad = (Class<Object>) classloader.loadClass("com.example.myapp.M"); final Object myInstance = classToLoad.newInstance(

Brainstorming: Weird JPA problem, possibly classpath or jar versioning problem?

吃可爱长大的小学妹 提交于 2019-12-12 07:07:28
问题 I'm seeing a weird error message and am looking for some ideas as to what the problem could be. I'm sort of new to using the JPA. I have an application where I'm using Spring's Entity Manager Factory (LocalContainerEntityManagerFactoryBean), EclipseLink as my ORM provider, connected to a MySQL DB and built with Maven. I'm not sure if any of this matters..... When I deploy this application to Glassfish, the application works as expected. The problem is, I've created a set of stand alone unit

How to cache objects on Tomcat across several WARs without putting the class-containing JAR into /lib/ext?

こ雲淡風輕ζ 提交于 2019-12-12 05:57:11
问题 How can I cache server-wide (with cache scope spanning multiple WARs on this server) instances of classes from a JAR which is contained binary-identical in several WARs on a web container (server, e. g. Tomcat)? <EDIT> I want to cache application data across WARs because the data is common to them. (It's a portal project, where it can be useful to share common data across different "views" implemented as different portlets deployed as different WARs, and using a Java object cache is much

How to check if a class in an OSGi bundle has been correctly unloaded?

牧云@^-^@ 提交于 2019-12-12 05:52:19
问题 I have an application which I suspect to leak some class references. To expose that buggy behaviour, we wrote a test : BundleUnloadIT In that test, I use Assertions.assertThat(weakReference.isEnqueued()) .as("weak reference should have been enqueued, but is not").isTrue(); To test if my reference is correctly gc'ed. But whatever I try to do, the reference is never enqueued. So I suspect some reference to that class is leaking somewhere. So ... am I using the right method to test my class is

Singleton returning new instance when accessed from test method

空扰寡人 提交于 2019-12-12 04:18:55
问题 I am using Junit 4.12 with PowerMock 1.6 with Mockito. I have also used PowerMockRule library as described here. I am trying to execute initialization code for all of my test cases exactly once as described in this SO Thread. Its executing the initialization code exactly one time however, if I do ServiceInitializer.INSTANCE inside test method it returns me new object. I am not able to understand this behavior. Does anyone have any idea why this is happening? If I execute my code without

On the fly class loading with jars

空扰寡人 提交于 2019-12-12 04:06:19
问题 I've got a ClassLoader extending class with following method @Override public Class<?> findClass(String className) throws ClassNotFoundException { try { /** * Get a bytecode from file */ byte b[] = fetchClassFromFS(pathtobin + File.separator + className.replaceAll("\\.", escapeSeparator(File.separator)) + ".class"); return defineClass(className, b, 0, b.length); } catch (FileNotFoundException ex) { return super.findClass(className); } catch (IOException ex) { return super.findClass(className)

Java How to load classes out of a jar in the classpath with the System ClassLoader (no URLClassLoader)?

回眸只為那壹抹淺笑 提交于 2019-12-12 03:15:45
问题 So, I need to load some class at runtime with the System ClassLoader out of a jar in the classpath, but every time I try, I get a ClassNotFoundException. With the System ClassLoader, am I able to do just: x.y.classineed (x and y being packages) or would I have to do something like: pathtox.x.y.classineed, assuming it's even possible to do this? 回答1: The JAR must not be in your CLASSPATH. This works fine: I have the JDOM JAR in my CLASSPATH. package cruft; /** * ClassLoaderDemo * @author

Liberty profile: birt and jsf integration

风流意气都作罢 提交于 2019-12-12 02:59:19
问题 I'm building a web application running on Liberty profile 8.5, with JSF 2.0 feature enabled (jsf-2.0 in server.xml) and BIRT integration in the web app. The web application includes all BIRT needed libs in WEB-INF/lib folder, but the only way to make it working (specially for chart report) is to set the classloader to 'parentlast' in the server.xml: <webApplication contextRoot="MyApp" id="MyApp" location="MyApp.war" name="MyApp"> <classloader delegation="parentLast"/> </webApplication> In

Can parameterized generic class instance have different methods depending on type argument?

廉价感情. 提交于 2019-12-12 02:57:19
问题 While answering following question: How do I create a Builder that can build more than one kind of Java object? I thought that it's impossible to achieve the following in Java: public class Builder<T> { // ... } Builder<User> userBuilder = new Builder<User>(); // here userBuilder only has method 'name' userBuilder.name("John"); Builder<Country> countryBuilder = new Builder<Country>(); // here countryBuilder only has method 'code' countryBuilder.code("UA"); But, in the comments, user John

java.rmi.UnmarshalException: error unmarshalling return; nested exception is:java.lang.ClassNotFoundException:

社会主义新天地 提交于 2019-12-12 02:47:09
问题 I have the following situation: Using RMI, i noticed that under a specific situation, the RMI client did not have the class whose instance was sent via RMI. So, I sent the class in the shape of Byte [] and then loaded it with a class loader i defined. The code in the client side is something like: pp = plugins.getPanelClasses(); //RMI method panelClassLoader pcl = new panelClassLoader(); //simple class loader defined by me String name = pcl.defineClass(pp); Then, i ask in the client side by