runtime-compilation

Compile java class in runtime with dependencies to nested jar

守給你的承諾、 提交于 2021-02-08 06:55:45
问题 In a spring-boot app I'm doing the following in runtime: Generating a java class Compiling it Accessing some static fields of the compiled class using reflection. I've based my code on this post and got a problem compiling my generated class in runtime. When running in the IDE compilation works just fine but when runing from a spring-boot jar compilation fails saying symbols are missing or some package does not exist. The class I'm compiling has dependencies to other classes that reside in a

Provide an Explicit Assembly Name for a Dynamically Compiled ASP.NET Website's App_Code Folder?

瘦欲@ 提交于 2020-01-04 05:04:25
问题 In a dynamically compiled ASP.NET Website project, can the assembly for the App_Code folder be explicitly named? For example, under regular circumstances when I run an ASP.NET website the assembly name generated into the Temporary ASP.NET Files\ folder is partially randomized like App_Code.neizakfo.dll where neizakfo is the portion that can differ. Can I explicitly provide a name for the assembly like App_Code_Web1.dll ? Clarification By business requirements, the website cannot be

C++ Make a Program Write Over Itself

ぐ巨炮叔叔 提交于 2019-12-24 12:57:35
问题 I posted a question on a similar topic a couple days ago (and one a couple years ago), but I decided to go ahead and get started. I am trying to inject C++ code into C++ code (in a somewhat portable manner using no os specific features and trying to be compiler/toolchain independent manner). I basically want to do this in an attempt to do runtime C++ scripts. I wrote a small test program (its really just kinda thrown together and hacky): Main.cpp: #include <stdlib.h> #include <iostream>

Compiling C# code from txt file to interface with running wpf application

三世轮回 提交于 2019-12-24 09:39:52
问题 I have been searching online for a neat way to compile code at runtime and manipulate the running application's objects (properties etc.). I have come across Snippy, CodeDom and CSharpCodeProvider but I didn't completely understood how I can use those solutions in my application to do what I want. Bottom line is, I want to have a small portion of the code in an external file so I can swap out different code during run time (e.g. Formulas to manipulate Data and etc.) Could somebody explain to

Online c# interpreter security issues

我只是一个虾纸丫 提交于 2019-12-18 13:26:30
问题 I am toying around with the idea of building an online C# interpreter, a bit like Codepad. Now there are obvious security issues: Infinite loops System.Diagnostics.Process.Start Pretty much the whole System.IO namespace My knowledge of C# isn't exactly insignificant, but I'm sure there are a lot that know much more about it, plus the stuff I didn't think about. What would you be careful about? A few precisions, I plan on running this on a small Linux VPS using Mono. 回答1: Use Mono's Compiler

Defining a class while a Java application is running

≯℡__Kan透↙ 提交于 2019-12-17 23:37:30
问题 In Java, is it possible to create a class definition on the fly while an application is running, and then create an object of that class? For example, a running application would read in a text file that contains a list of class members to include in the new class. The application would then define a class definition based on the list of members, and then insantiate it. 回答1: Yes its possible to do so in theory your class file is byte code which is at the end a byte array! you can then use the

Revisiting the conflict of lombok with java runtime compilation

不问归期 提交于 2019-12-11 17:36:24
问题 I am working in IntelliJ Idea, with JDK and JRE 8. The project makes use of lombok, and I would like to have code generation and runtime compiling. My aim is to produce a code that does the same task as some complicated runtime generated lambda function, to speed up the evaluation. The project makes heavy use of lombok. And I have the same issue as the one discussed here, so I know that one way around this problem is to add particular dependencies. My question is: did there appear any other,

Lambda compilation throws “variable '' of type '' referenced from scope '', but it is not defined”

断了今生、忘了曾经 提交于 2019-12-11 01:17:41
问题 When I attempt to compile the lambda shown below, it throws: variable 'model' of type 'System.Collections.Generic.IEnumerable`1[WheelEndCatalogKendo.Models.SapBasicData]' referenced from scope '', but it is not defined public static GridBoundColumnBuilder<TModel> BuildColumnString<TModel>(this GridBoundColumnBuilder<TModel> column, WebViewPage<IEnumerable<TModel>> webViewPage, int width) where TModel : class { var modelParameter = Expression.Parameter(typeof(IEnumerable<TModel>), "model");

Where would you use C# Runtime Compilation?

大憨熊 提交于 2019-12-05 15:24:04
问题 I happened upon a brief discussion recently on another site about C# runtime compilation recently while searching for something else and thought the idea was interesting. Have you ever used this? I'm trying to determine how/when one might use this and what problem it solves. I'd be very interested in hearing how you've used it or in what context it makes sense. Thanks much. 回答1: Typically, I see this used in cases where you are currently using Reflection and need to optimize for performance.

Runtime code generation and compilation

 ̄綄美尐妖づ 提交于 2019-12-04 14:50:53
Say I have this code that uses some input (e.g. a URL path) to determine which method to run, via reflection: // init map.put("/users/*", "viewUser"); map.put("/users", "userIndex"); // later String methodName = map.get(path); Method m = Handler.class.getMethod(methodName, ...); m.invoke(handler, ...); This uses reflection so the performance can be improved. It could be done like this: // init map.put("/users/*", new Runnable() { public void run() { handler.viewUser(); } }); map.put("/users", new Runnable() { public void run() { handler.userIndex(); } }); // later Runnable action = map.get