groovyclassloader

GroovyClassLoading Mechanism

淺唱寂寞╮ 提交于 2019-12-24 06:56:39
问题 I'm really newbie to groovy scripting but following some tutorial I tried to dynamically load some groovy class within my java code using parseClass() method of GroovyClassLoader . I wrote some snippet and it worked fine for me. The problem is that I don't clearly understand what groovy engine is doing beyond my view and how those scripts are compiled? Does a new class gets creted and loaded into jvm? Or does my application uses some cached sources? Here is the class I'm trying to parse:

GroovyClassLoading Mechanism

夙愿已清 提交于 2019-12-24 06:56:31
问题 I'm really newbie to groovy scripting but following some tutorial I tried to dynamically load some groovy class within my java code using parseClass() method of GroovyClassLoader . I wrote some snippet and it worked fine for me. The problem is that I don't clearly understand what groovy engine is doing beyond my view and how those scripts are compiled? Does a new class gets creted and loaded into jvm? Or does my application uses some cached sources? Here is the class I'm trying to parse:

GroovyClassLoader call to parseClass is successful, even when code does not compile

自闭症网瘾萝莉.ら 提交于 2019-12-23 09:43:24
问题 I'm trying to dynamically load a Groovy script as a class but the class object is created even when the script's code does not compile. For example, a simplified version of my Groovy code to load the Groovy script is as follows: GroovyCodeSource src = new GroovyCodeSource( "blah blah blah", "Foo.groovy", GroovyShell.DEFAULT_CODE_BASE ) new GroovyClassLoader().parseClass(src, true) Clearly, the code blah blah blah isn't a legitimate Groovy script. And yet, a class object is successfully

How compile Groovy source but not from filesystem

旧时模样 提交于 2019-12-23 02:39:16
问题 I compile single groovy source module "in fly" using GroovyClassLoader.parseClass(src) and all is ok. But problem is when this source module imports other classes, these are not compiled yet. Traditional compiling when I start compilation of one source but other are required and ready on source path, are compiled too. How can I use GroovyClassLoader with target to compile all other required sources NOT FROM FILESYSYSTEM. My sources are for example in database, remote http via URI etc. 回答1:

Grails 1.4.0.M1 (with STS 2.7.0.M2) NoClassDefFoundError for GantBuilder

佐手、 提交于 2019-12-11 12:37:57
问题 I have just upgraded to... Grails 1.4.0.M1 Groovy 1.8.0 STS Version: 2.7.0.M2 Build Id: 201106101000 - 64bit Cocoa version for Mac I have OS X 10.5.8. with JVM 1.5.0 When I run a grails command eg 'create-app' or 'upgrade' on an existing project I get the following NoClassDefFoundError for the GantBuilder. (see below for full trace) A proposed solution for a similar problem from this forum is that gant_groovy1.8-1.9.5.jar is missing. I've added this to the project directly and also to a

Beanshell will not allow me to add jars to the “default” JRE classloader?

前提是你 提交于 2019-12-10 19:43:11
问题 I have a question about Beanshell that I can't find an answer to anywhere. I am only able to run Beanshell scripts in 1 of 2 ways: Where Classpath is defined before invoking Beanshell and Beanshell uses the JRE default classloader. Where no classpath is defined at all before starting Beanshell and then I use addClassPath() and importCommands() to dynamically build the classpath within Beanshell's classloader. This method does not seem to inherit a jars that were part of the default JRE

Replace classpath of a running Groovy Script (Jenkins Pipeline script)

耗尽温柔 提交于 2019-12-08 08:43:28
问题 In Jenkins Pipeline we have a CpsGroovyScript executed by CPSGroovyShell with a custom classpath which is appended with path to Global Library location. In order to be able to test my changes before making them available for all the Pipelines on my Jenkins instance I want to override classpath by unloading the classes and modifying the script's classpath from itself in runtime. My idea is to prepend current classpath with a new location so that changed classes found first. this.class

GroovyShell in Java8 : memory leak / duplicated classes [src code + load test provided]

佐手、 提交于 2019-12-03 14:41:10
问题 We have a memory leak caused by GroovyShell/ Groovy scripts (see GroovyEvaluator code at the end). Main problems are (copy-paste from MAT analyser): The class "java.beans.ThreadGroupContext", loaded by "<system class loader>", occupies 807,406,960 (33.38%) bytes. and: 16 instances of "org.codehaus.groovy.reflection.ClassInfo$ClassInfoSet$Segment", loaded by "sun.misc.Launcher$AppClassLoader @ 0x7004e9c80" occupy 1,510,256,544 (62.44%) bytes We're using Groovy 2.3.11 and Java8 (1.8.0_25 to be

GroovyShell in Java8 : memory leak / duplicated classes [src code + load test provided]

北城以北 提交于 2019-12-03 03:45:40
We have a memory leak caused by GroovyShell/ Groovy scripts (see GroovyEvaluator code at the end). Main problems are (copy-paste from MAT analyser): The class "java.beans.ThreadGroupContext", loaded by "<system class loader>", occupies 807,406,960 (33.38%) bytes. and: 16 instances of "org.codehaus.groovy.reflection.ClassInfo$ClassInfoSet$Segment", loaded by "sun.misc.Launcher$AppClassLoader @ 0x7004e9c80" occupy 1,510,256,544 (62.44%) bytes We're using Groovy 2.3.11 and Java8 (1.8.0_25 to be exact) . Upgrading to Groovy 2.4.6 doesn't solve the problem. Just improves memory usage a little bit ,

Loading classes not present in the classpath

五迷三道 提交于 2019-11-29 22:58:39
问题 Let's say I've compiled a Groovy script using Groovyc, which has generated one or more .class files in the file system. From a Java application, how do I add those classes to the classpath dynamically in order to load them and call their methods? The goal is to pre-compile Groovy scripts and store them into the database, so evaluation can be performed from compiled versions of the scripts. 回答1: You can create an instance of URLClassLoader to load new classes from a directory: URL dirUrl = new