GitHub

MVFLEX Expression Language (MVEL) is a hybrid dynamic/statically typed, embeddable Expression Language and runtime for the Java Platform.

Overview

MVEL3 is a complete rewrite of MVEL. Instead of interpreting expressions at runtime (as MVEL2 does), MVEL3 transpiles MVEL expressions into Java source code, compiles them in-memory via javac, and executes the resulting bytecode.

Alpha Notice: This is an alpha release. APIs may change in future releases.

Security Notice: MVEL expressions are functionally equivalent to Java code and can perform any operation the JVM allows, including file system access and network calls. Only compile and execute expressions from trusted sources. See SECURITY.md for details.

MVEL3 and MVEL2

This is the MVEL version 3.x codebase, developed in the main branch.

MVEL2 is maintained separately in the mvel2 branch. If you contribute to MVEL2, please submit PRs to the mvel2 branch.

How to Build

Prerequisites: JDK 17+, Maven 3.8.7+

MVEL3 requires a javaparser-mvel fork with MVEL-specific AST nodes. Build it first:

git clone https://github.com/mvel/javaparser-mvel.git
cd javaparser-mvel
mvn clean install

Then build MVEL3:

git clone https://github.com/mvel/mvel.git
cd mvel
mvn clean install

Usage

MVEL3 provides a fluent builder API with three context types: Map, List, and POJO.

Map Context

Variables are passed via Map<String, Object> and extracted by name.

"Map > types = new HashMap<>(); types.put("x", Type.type(int.class)); types.put("y", Type.type(int.class)); Evaluator , Void, Integer> evaluator = MVEL.

Read the original on github.com ↗