classloader

How to set the orders of jars in Weblogic EAR?

拟墨画扇 提交于 2019-12-06 21:44:35
I have an EAR file that contains two different jars that share some classes with an identical package+class name. This results in importance of classloading inside the EAR file itself. How can I tell Weblogic to load one jar from APP-INF/lib before loading a different one in the same APP-INF/lib? I need to define a specific order to that if there is a conflict, it will take from JAR a and not JAR b. I'm using Webogic 11g (10.3). Thanks. The top-level element in weblogic-application.xml has an optional classloader-structure element that you probably want to look into. For instance you can do

Patch or override an implementation of a core Java 10 class

烈酒焚心 提交于 2019-12-06 18:19:55
问题 There is a bug in JFX which often manifests when calculating screen co-ordinates https://bugs.openjdk.java.net/browse/JDK-8194727 and https://bugs.openjdk.java.net/browse/JDK-8190400 I've tracked the problem down to the implementation of GeneralTransform3D, which is part of the javajfx runtime. I've submitted a bug report to Oracle, but until it is accepted, fixed, and makes it to a release, I need a way of fixing my application. In java 8 i was able to create a jar containing a fixed version

Custom Class Loader In Java [closed]

半世苍凉 提交于 2019-12-06 16:29:18
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . Is it possible to make my own Custom Class Loader In java. If Yes Then Please Guide me. Instead of class obfuscation I want to change in class file so that it cant be reversed by any tool 回答1: You can use some obfuscation tools, like ProGuard. A self written ClassLoader, must be placed in a standard .class file,

Encrypted class files with decryption handled by a native library

与世无争的帅哥 提交于 2019-12-06 14:58:43
问题 The article "Cracking Java byte-code encryption" (javaworld.com/javaworld/javaqa/2003-05/01-qa-0509-jcrypt.html) explains why class file encryption using a custom class loader is pointless, because at some point you always need to call defineClass(), which passes the class file to the JVM as an unencrypted byte array. However I've seen solutions where a slightly different approach is used; the class is decrypted by a native library and handed over to the JVM as a java.lang.Class instance

How to send a Class over the wire

天涯浪子 提交于 2019-12-06 14:21:42
I have the following problem: I want to send a type (java.lang.Class) over the wire and 'define' the class on the other side. I tried like that: ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(MyClass.class); and on the receiving end: ByteArrayInputStream bis = new ByteArrayInputStream(request.getBytes()); ObjectInputStream ois = new ObjectInputStream(bis); Class c = (Class) ois.readObject(); // ClassNotFoundException so obviously I need to send the raw bytecode of the class and do a ClassLoader.defineClass(bytes, .

Dynamic class loading to target multiple Android versions

天大地大妈咪最大 提交于 2019-12-06 14:13:37
问题 I would like to make a single Android app for multiple Android versions (possibly every one of them) My problem is that I want to check what is the version of Android the app is currently running on, and dynamically load a class which is version dependent. This part should be ok. I just wonder how I can achieve that without compilation errors in my Eclipse project. I mean, the project is configured for a particular target (1.5, 2.1 ...), so if a class in my project is not compatible wich the

How to access a resource / configuration / text file in an external Jar from Java?

旧城冷巷雨未停 提交于 2019-12-06 13:39:10
问题 I am running a program in com.me.X.jar . In an external com.me.Y.jar , I have a configuration file located at ' config/conf.txt ' in the root of the Jar. How can I access this configuration file programmatically from within Java? com.me.Y.jar is not currently loaded in memory and is composed of just non-code resources. 回答1: jar files are just zip files. So google for an example how to read a zip file. Or have a look at the API ZipInputStream 回答2: The easiest option for reading embedded

Custom ClassLoader not garbage collected

谁说胖子不能爱 提交于 2019-12-06 13:28:00
问题 In an attempt to solve this problem, I built a (very) small project that is reproducing part of it. It is a NetBeans project using Glassfish v2.1.1 and OpenJpa-1.2.2. Globally, the goal is to be able to reload dynamically some business code (called 'tasks') without the need to (re)make a full deployment (eg via asadmin). In the project there are two of them: PersonTask and AddressTask which are simply accessing some data and printing them out. In order to do that, I've implemented a custom

ClassLoader&Class使用

末鹿安然 提交于 2019-12-06 12:27:20
ClassLoader 一个经常出现又让很多人望而却步的词,本文将试图以最浅显易懂的方式来讲解 ClassLoader ,希望能对不了解该机制的朋友起到一点点作用。 要深入了解 ClassLoader ,首先就要知道 ClassLoader 是用来干什么的,顾名思义,它就是 用来加载 Class 文件到 JVM ,以供程序使用的。我们知道, java 程序可以动态加载类定义,而这个 动态加载的机制就是通过 ClassLoader 来实现 的,所以可想而知 ClassLoader 的重要性如何。 看到这里,可能有的朋友会想到一个问题,那就是既然 ClassLoader 是用来加载类到 JVM 中的,那么 ClassLoader 又是如何被加载呢?难道它不是 java 的类? 没有错,在这里确实有一个 ClassLoader 不是用 java 语言所编写 的,而是 JVM 实现的一部分,这个 ClassLoader 就是 bootstrap classloader (启动类加载器) ,这个 ClassLoader 在 JVM 运行的时候加载 java 核心的 API 以满足 java 程序最基本的需求,其中就包括用户定义的 ClassLoader ,这里所谓的用户定义是指通过 java 程序实现的 ClassLoader ,一个是 ExtClassLoader ,这个

Do security providers cause ClassLoader leaks in Java?

China☆狼群 提交于 2019-12-06 11:40:41
In my Java EE (Glassfish 3.1.1) application I register a security provider: public static final class XoauthProvider extends Provider { public XoauthProvider() { super("Google Xoauth Provider", 1.0, "Provides the Xoauth experimental SASL Mechanism"); put("SaslClientFactory.XOAUTH", "blah.server.utils.XoauthSaslClientFactory"); } } ... XoauthProvider xoauthProvider = new XoauthProvider(); Security.addProvider(xoauthProvider); I have been receiving following exceptions after redeploys: java.lang.IllegalStateException: WEB9031: WebappClassLoader unable to load resource [blah.server.utils