百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
J

jOOR

> 编程语言
开源

jOOR - Java 中的流畅反射 jOOR 是一个非常简单的流畅 API,可通过更直观的方式访问 Java 类结构。JDK 的反射

2.8K stars0 点赞0 次浏览
访问官网GitHub

工具介绍

jOOR - Java 中的流畅反射 jOOR 是一个非常简单的流畅 API,可通过更直观的方式访问 Java 类结构。JDK 的反射

Overview

jOOR stands for jOOR Object Oriented Reflection. It is a simple wrapper for the java.lang.reflect package.

jOOR's name is inspired by jOOQ, a fluent API for SQL building and execution.

Dependencies

None!

Download

For use with Java 9+

<dependency>
  <groupId>org.jooq</groupId>
  <artifactId>joor</artifactId>
  <version>0.9.15</version>
</dependency>

For use with Java 8+

<dependency>
  <groupId>org.jooq</groupId>
  <artifactId>joor-java-8</artifactId>
  <version>0.9.15</version>
</dependency>

For use with Java 6+

<dependency>
  <groupId>org.jooq</groupId>
  <artifactId>joor-java-6</artifactId>
  <version>0.9.15</version>
</dependency>

Simple example

// All examples assume the following static import:
import static org.joor.Reflect.*;

String world = onClass("java.lang.String") // Like Class.forName()
                .create("Hello World")     // Call most specific matching constructor
                .call("substring", 6)      // Call most specific matching substring() method
                .call("toString")          // Call toString()
                .get();                    // Get the wrapped object, in this case a String

Proxy abstraction

jOOR also gives access to the java.lang.reflect.Proxy API in a simple way:

public interface StringProxy {
  String substring(int beginIndex);
}

String substring = onClass("java.lang.String")
                    .create("Hello World")
                    .as(StringProxy.class) // Create a proxy for the wrapped object
                    .substring(6);         // Call a proxy method

Runtime compilation of Java code

jOOR has an optional dependency on the java.compiler module and simplifies access to javax.tools.JavaCompiler through the following API:

Supplier<String> supplier = Reflect.compile(
    "com.example.HelloWorld",
    "package com.example;\n" +
    "class HelloWorld implements java.util.function.Supplier<String> {\n" +
    "    public String get() {\n" +
    "        return \"Hello World!\";\n" +
    "    }\n" +
    "}\n").create().get();

// Prints "Hello World!"
System.out.println(supplier.get());

Comparison with standard java.lang.reflect

jOOR code:

Employee[] employees = on(department).call("getEmployees").get();

for (Employee employee : employees) {
  Street street = on(employee).call("getAddress").call("getStreet").get();
  System.out.println(street);
}

The same example with normal reflection in Java:

…

`

Similar projects

Everyday Java reflection with a fluent interface:

  • http://docs.codehaus.org/display/FEST/Reflection+Module
  • http://projetos.vidageek.net/mirror/mirror/

Reflection modelled as XPath (quite interesting!)

  • http://commons.apache.org/jxpath/users-guide.html

GitHub Issues· 0 开放

在 GitHub 查看全部

暂无开放 Issues,或尚未同步最近议题。

核心特点

  • •http://docs.codehaus.org/display/FEST/Reflection+Module
  • •http://projetos.vidageek.net/mirror/mirror/
  • •http://commons.apache.org/jxpath/users-guide.html

> 标签

Java

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言