classloader

Reason and tracing of class loading during verification, method execution and JIT compilation

拥有回忆 提交于 2019-12-04 14:21:53
问题 I'm trying to understand which events lead to class loads on a very detailed basis and during my testing encountered one behaviour I do not understand in this very basic sample: public class ClinitTest { public static Integer num; public static Long NUMTEST; static { NUMTEST = new Long(15);; num = (int) (NUMTEST * 5); System.out.println(num); } public static void main(String[] args) { System.out.println( "The number is " + num); } } When running java.lang.Long gets loaded while executing the

Is Java Classloader Delegation model mandatory?

风格不统一 提交于 2019-12-04 14:05:21
If i have a custom classloader which, instead of delegating to its parent first, tries a search and load of the class itself will it be a violation of some stated/unstated rule? The Tomcat webapp classloader follows this model, so I imagine it works to at least some extent :) From the Tomcat classloader documentation : As mentioned above, the web application class loader diverges from the default Java 2 delegation model (in accordance with the recommendations in the Servlet Specification, version 2.4, section 9.7.2 Web Application Classloader). When a request to load a class from the web

Memory leak when using JDK compiler at runtime

瘦欲@ 提交于 2019-12-04 12:03:01
问题 I am trying to add a javaeditor to my program to extend the program at run time. It all works fine, except when using the program extensively (I simulated 1000-10000 compiler executions). The memory usage rises and rises, it looks like there is a memory leak. In my program, the class gets loaded, the constructor gets executed and the class gets unloaded (no remaining instance and the classLoader becomes invalid as I set the pointer to null). I analyzed the process with JConsole, the classes

Groovy with Grape and AntBuilder classloader problem

有些话、适合烂在心里 提交于 2019-12-04 11:44:16
问题 I wanted to use groovy for a little ftp script and found this post http://www.hhhhq.org/blog/2009/05/01/ftp-using-groovy-and-ant/ Since there were several dependencies I wanted to use Grape. All dependencies are resolved and present in the cache. But I can't get Ant to find the optional tasks in the other libs. It always says Caught: : Problem: failed to create task or type ftp Cause: the class org.apache.tools.ant.taskdefs.optional.net.FTP was not found. This looks like one of Ant's optional

Java's classloader versus jars-within-jars

核能气质少年 提交于 2019-12-04 11:20:58
问题 We have an executable JAR file that sometimes contains other JAR files. (The whole thing rests on four other downloaded JARs, riding on the back of a giant deployed turtle in space.) At runtime, we dynamically load that nested JAR file doing the following: // wearyingly verbose error handling elided URL nestedURL = the_main_system_classloader.getResource("path/to/nested.jar"); File temp = File.createTempFile (....); // copy out nestedURL contents into temp, byte for byte URL tempURL = temp

Is it possible to “reset” a class loader?

六月ゝ 毕业季﹏ 提交于 2019-12-04 11:17:14
问题 I have to dynamically load a class with the same name from some JAR, but different implementation, multiple times. I'm creating an evaluator backend and I have to dynamically load classes and test them. The tests are JUnit classes that instantiate the classes which should be tested, this is a simple example: package evaluator.tests; import static org.junit.Assert.*; import org.junit.*; import evaluator.tested.*; public class KTest { private K tested; @Before public void setup() { tested = new

Using ClassPathScanningCandidateComponentProvider with multiple jar files?

你说的曾经没有我的故事 提交于 2019-12-04 10:50:57
问题 I'm looking at using ClassPathScanningCandidateComponentProvider for finding sub-classes of a specific Class in my JVM. I'm doing pretty much exactly what is described here: Scanning Java annotations at runtime However, when I call the code from ant, via a JMX bean I hit a serious issue. I call: ClassPathScanningCandidateComponentProvider.findCandidateComponents with the search package: "com.mycompany" However, there are multiple jar files in my classpath that contain classes that start with

weird behaviour of custom system classloader and MessageDigest

允我心安 提交于 2019-12-04 10:26:49
I have an application which uses a custom system classloader, set by the Djava.system.class.loader=class parameter. The Application uses RMI. Everything works fine out of eclipse, but if i export a runnable jar, this error happens: Caused by: java.lang.SecurityException: SHA MessageDigest not available at sun.rmi.server.Util.computeMethodHash(Unknown Source) at sun.rmi.server.UnicastServerRef$HashToMethod_Maps.computeValue(Unknown Source) at sun.rmi.server.UnicastServerRef$HashToMethod_Maps.computeValue(Unknown Source) at sun.rmi.server.WeakClassHashMap.get(Unknown Source) at sun.rmi.server

Is JDK ClassLoader.getResourceAsStream broken? (unclosed resources)

走远了吗. 提交于 2019-12-04 10:00:20
I will try to prove that ClassLoader.getResourceAsStream() is opening two InputStreams , closing none of it and returning only one to client. Is my logic correct? JDK sources are picked from jdk1.8.0_25 I've get into unclosed resources problem using Spring ClassPathResource in interval ( original question ), that is using ClassLoader.getResourceAsStream to get InputStream to a properties file. After investigation, I found that classLoader.getResourceAsStream is getting an URL by URL url = getResource(name); and then it is opening that stream, but URL url = getResource(name) already opens that

PermGen space issue with Glassfish/Hibernate

左心房为你撑大大i 提交于 2019-12-04 09:37:47
问题 I'm running a GWT+Hibernate app on Glassfish 3.1. After a few hours, I run out of Permgen space. This is without any webapp reloads. I'm running with –XX:MaxPermSize=256m –XmX1024m . I took the advice from this page, and found that I'm leaking tons of classes- all of my Hibernate models and all of my GWT RequestFactory proxies. The guide referenced above says to "inspect the chains, locate the accidental reference, and fix the code". Easier said than done. The classloader always points back