Questions tagged [runtime-compilation]

Use this tag for questions related to Runtime Compilation, i.e. the compilation of a program during Runtime.

is used in its general meaning, and is usually accompanied by Java, C based languages, Scala, ASP.NET, etc. .

123 questions
22
votes
8 answers

Compile and run dynamic code, without generating EXE?

I was wondering if it was possible to compile, and run stored code, without generating an exe or any type of other files, basically run the file from memory. Basically, the Main application, will have some stored code (code that will potentially be…
caesay
  • 16,932
  • 15
  • 95
  • 160
22
votes
6 answers

Is there any way to compile additional code at runtime in C or C++?

Here is what I want to do: Run a program and initialize some data structures. Then compile additional code that can access/modify the existing data structures. Repeat step 2 as needed. I want to be able to do this with both C and C++ using gcc…
Matt
  • 21,026
  • 18
  • 63
  • 115
18
votes
6 answers

On-the-fly, in-memory java code compilation for Java 5 and Java 6

How can I compile java code from an arbitrary string (in memory) in Java 5 and Java 6, load it and run a specific method on it (predefined)? Before you flame this, I looked over existing implementations: Most rely on Java 6 Compiler API. Those that…
17
votes
11 answers

Defining a class while a Java application is running

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…
Lehane
  • 47,588
  • 14
  • 53
  • 53
11
votes
1 answer

Roslyn, how can I instantiate a class in a script during runtime and invoke methods of that class?

I understand how I can execute entire scripts using Roslyn in C# but what I now want to accomplish is to compile a class inside the script, instantiate it, parse it to an interface and then invoke methods that the compiled and instantiated class…
Matt
  • 7,004
  • 11
  • 71
  • 117
11
votes
5 answers

Compile Groovy class at runtime in Java

I am successfully able to compile Groovy in Java at runtime and store it in a database and pull it out. I can't compile a Groovy class if it has inner classes or an inner enum. Has anyone successfully compiled Groovy code like this and included…
ColinMc
  • 1,238
  • 3
  • 16
  • 33
11
votes
1 answer

Maximum amount of errors in CSharpCodeProvider.CompileAssemblyFromFile

I use CSharpCodeProvider to compile instant plugins for my app. Right now it is possible to try to compile a file, that looks good, but generates many errors, for example a C# code glued with a binary file. There are many characters, that are…
Piotr Zierhoffer
  • 5,005
  • 1
  • 38
  • 59
11
votes
7 answers

Where would you use C# Runtime Compilation?

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…
itsmatt
  • 31,265
  • 10
  • 100
  • 164
10
votes
2 answers

scala as scripting language

Possible Duplicate: “eval” in Scala I know scala is a compiled language, but I do also know that I can dynamically load classes into the jvm, and I can call the scala compiler at runtime, last but not least I do also have an awesome repl, so…
Arne
  • 7,921
  • 9
  • 48
  • 66
7
votes
4 answers

Online c# interpreter security issues

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…
Alex Turpin
  • 46,743
  • 23
  • 113
  • 145
5
votes
1 answer

Using Roslyn to parse a lambda expression of a runtime generated type

I'm trying to use Roslyn as a way to parse lambda expressions provided at runtime by users using the general format: // The first line is normally static and re-used across callers to save perf Script baseScript = CSharpScript.Create(string.Empty,…
Jeff Wight
  • 833
  • 5
  • 11
5
votes
4 answers

Runtime code generation and compilation

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 =…
Bart van Heukelom
  • 43,244
  • 59
  • 186
  • 301
4
votes
2 answers

How can I speed up compilation of Common Lisp `IF` statements?

I have a system that generates decision trees and converts them into nested Common Lisp if statements with predicates that check if a variable value is >= or <= a given integer e.g. (LAMBDA (V1 V2) (IF (>= V1 2) (IF (<= V1 3) (IF…
4
votes
3 answers

Determine return type of a Java expression in a String at runtime

At runtime, in my Java program, given a String, I 'd like to know the return type. For example: 1 + 1 returns int 1L + 1L returns long 1L + 1 returns long 1 + 1.5 returns double 1 + 2 - 3 * 4 / 5 returns int 1 / 0 returns int 1 + Math.nextInt()…
Geoffrey De Smet
  • 26,223
  • 11
  • 73
  • 120
4
votes
1 answer

RuntimeHelpers.PrepareMethod not working when called with Func created in Generic class

I'm currently working on an extension on the Moq framework to be also to mock the implementation of non virtual methods. I currently already have this working by obtaining the Method Handle of the original Method and swapping this with the pointer…
Devedse
  • 1,801
  • 1
  • 19
  • 33
1
2 3
8 9