Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
M

manifold

> 后端框架
Open source

Manifold is a Java compiler plugin, its features include Metaprogramming, Properties, Extension Methods, Operator Overloading, Templates, a Preprocessor, and mo

2.8K stars0 likes1 views
WebsiteGitHub

About

Manifold is a Java compiler plugin, its features include Metaprogramming, Properties, Extension Methods, Operator Overloading, Templates, a Preprocessor, and mo



Manifold

Manifold extends Java at compile time through the Java compiler plugin API.

It adds language features and type-safe access to external data, APIs, and DSLs directly to Java, without leaving the Java compiler and without additional build steps.

Compile-time metaprogramming type-safely integrates any kind of schema, metadata, or DSL directly into Java. These include:

  • SQL (New!)
  • JSON & JSON Schema, YAML, XML
  • GraphQL

Language enhancements improve developer productivity. Such as:

  • Parts (true composition) (New!)
  • Extension methods
  • Properties
  • Optional parameters
  • Operator overloading
  • Tuple expressions
  • A preprocessor

Add only the features you want to an existing Java project and keep using ordinary Java, Java libraries, and the JVM.

Works with JDK LTS releases 8 - 25 + latest, plus comprehensive IDE support in IntelliJ IDEA and Android Studio.


What can you do with Manifold?

Parts (true composition)

Parts is a compositional model that resolves a long-standing dilemma in statically typed object-oriented programming: independent runtime components and internal polymorphism remain unreconciled in general-purpose languages.

Independent components Internal polymorphism
Implementation inheritance — ✓
Trait/mixin composition (flattening) — ✓
Object composition (forwarding) ✓ —
Parts ✓ ✓

Parts provides both properties in arbitrary compositions without sacrificing component independence, limiting polymorphism, or compromising performance.

…

Hero.takeAction() calls attack() on itself (a self-call). Because Hero is a linked part of the Wizard composite, the self-call dispatches to Wizard.attack(), so the output is:

Cast spell!

With ordinary object composition, Hero's own attack() would be called and Swing club! would result instead.

This internal polymorphism across a runtime-injected part is the defining capability of Parts, and it comes at vtable speed: dispatch is O(1), performance equivalent to a conventional virtual call. See the Parts README for a deeper dive, or the formal paper for the underlying model and supporting analysis.


Compile-time meta-programming

Use the framework to gain direct, type-safe access to any type of resource, such as SQL, JSON, GraphQL, XML, YAML, CSV, and even other languages such as JavaScript

SQL: Use native SQL of any complexity directly and type-safely from Java.

java
Language english =
  "[.sql/]select * from Language where name = 'English'".fetchOne();
Film film = Film.builder("My Movie", english)
  .withDescription("Nice movie")
  .withReleaseYear(2023)
  .build();
MyDatabase.commit();

JSON: Use .json schema files directly and type-safely, no code gen steps! Find usages of .json properties in your Java code.

java
// From User.json
User user = User.builder("myid", "mypassword", "Scott")
  .withGender(male)
  .withDob(LocalDate.of(1987, 6, 15))
  .build();
User.request("http://api.example.com/users").postOne(user);

GraphQL: Use types defined in .graphql files directly, no code gen steps! Make GraphQL changes and immediately use them with code completion.

java
var query = MovieQuery.builder(Action).build();
var result = query.request("http://com.example/graphql").post();
var actionMovies = result.getMovies();
for (var movie : actionMovies) {
  out.println(
    "Title: " + movie.getTitle() + "\n" +
    "Genre: " + movie.getGenre() + "\n" +
    "Year: " + movie.getReleaseDate().getYear() + "\n");
}

Extension methods

Add your own methods to existing Java classes, even String, List, and File. Eliminate boilerplate code.  ▶ Check it out!

java
String greeting = "hello";
greeting.myMethod(); // Add your own methods to String!

Or, intercept existing methods.

java
// Intercepts Search.find() to insert a caching layer
result = search.find(); // returns cached results

Properties

Eliminate boilerplate getter/setter code, improve your overall dev experience with properties.

java
public interface Book {
  @var String title; // no more boilerplate code!
}
// refer to it directly by name
book.title = "Daisy";     // calls setter
String name = book.title; // calls getter 
book.title += " chain";   // calls getter & setter

Additionally, the feature automatically infers properties, both from your existing source files and from compiled classes your project uses. Reduce property use from this:

java
Actor person = result.getMovie().getLeadingRole().getActor();
Likes likes = person.getLikes();
likes.setCount(likes.getCount() + 1);

to this:

java
result.movie.leadingRole.actor.likes.count++;

Optional parameters & named arguments

Use optional parameters and named arguments with any Java project to add clarity and flexibility to call sites and as a refreshing alternative to method overloads and builders.

java
String valueOf(char[] data, 
               int offset = 0, 
               int count = data.length - offset) {...}

valueOf(array) // use defaults for offset and count
valueOf(array, 2) // use default for count
valueOf(array, count:20) // use default for offset by naming count

Binary compatible with methods, constructors, and records.


Operator Overloading

Implement operator methods on any type to directly support arithmetic, relational, index, and unit operators.

java
// BigDecimal expressions
if (bigDec1 > bigDec2) {
  BigDecimal result = bigDec1 + bigDec2;
  ...
}
// Implement operators for any type
MyType value = myType1 + myType2;

Tuple expressions

Tuple expressions provide concise syntax to group named data items in a lightweight structure.

java
var t = (name: "Bob", age: "35");
System.out.println("Name: " + t.name + " Age: " + t.age);

var t = (person.name, person.age);
System.out.println("Name: " + t.name + " Age: " + t.age);

You can also use tuples with new auto type inference to enable multiple return values from a method.


Unit Expressions

Unit or binding operations are unique to the Manifold framework. They provide a powerfully concise syntax and can be applied to a wide range of applications.

Use units with the science framework to type-safely incorporate SI units and precise measurements into your applications.

java
import static manifold.science.util.UnitConstants.*; // kg, m, s, ft, etc
...
Length distance = 100 mph * 3 hr;
Force f = 5.2 kg m/s/s; // same as 5.2 N
Mass infant = 9 lb + 8.71 oz;
Time time = 1min + 3.7sec;

Preprocessor

Use familiar directives such as #define and #if to conditionally compile your Java projects. The preprocessor offers a simple and convenient way to support multiple build targets with a single codebase.  ▶ Check it out!

java
#if JAVA_8_OR_LATER
  @Override
  public void setTime(LocalDateTime time) {...}
#else
  @Override
  public void setTime(Calendar time) {...}
#endif

Structural Typing

Unify disparate APIs. Bridge software components you do not control. Use structural typing to access objects (and maps) using type-safe interfaces.  ▶ Check it out!

java
Map<String, Object> map = new HashMap<>();
MyThingInterface thing = (MyThingInterface) map; // O_o
thing.setFoo(new Foo());
Foo foo = thing.getFoo();
out.println(thing.getClass()); // prints "java.util.HashMap"

Type-safe Reflection

Access private features with @Jailbreak to avoid the drudgery and vulnerability of Java reflection.  ▶ Check it out!

java
@Jailbreak Foo foo = new Foo();
/

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Javaandroid-studiodelegationduck-typingextension-methods

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category后端框架
PricingOpen source

> Related tools

N
Node.js
基于 V8 的 JavaScript 运行时
D
Django
Python 高级 Web 框架
S
Spring Boot
Java 生态主流微服务框架