diff --git a/distribution/proxy-native/pom.xml b/distribution/proxy-native/pom.xml
index 205f28680dc754..c906ed14667fc9 100644
--- a/distribution/proxy-native/pom.xml
+++ b/distribution/proxy-native/pom.xml
@@ -36,12 +36,6 @@
org.apache.shardingsphere
shardingsphere-proxy-bootstrap
${project.version}
-
-
- org.apache.shardingsphere
- shardingsphere-cluster-mode-repository-etcd
-
-
@@ -103,7 +97,6 @@
org.apache.shardingsphere.proxy.Bootstrap
- --report-unsupported-elements-at-runtime
-J-Xmx7g
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/graalvm-native-image/_index.cn.md b/docs/document/content/user-manual/shardingsphere-jdbc/graalvm-native-image/_index.cn.md
index 1a512938346627..1bba59c8487c58 100644
--- a/docs/document/content/user-manual/shardingsphere-jdbc/graalvm-native-image/_index.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/graalvm-native-image/_index.cn.md
@@ -10,18 +10,18 @@ ShardingSphere JDBC 已在 GraalVM Native Image 下完成可用性验证。
构建包含 `org.apache.shardingsphere:shardingsphere-jdbc-core:${shardingsphere.version}` 的 Maven 依赖的 GraalVM Native
Image,你需要借助于 GraalVM Native Build Tools。GraalVM Native Build Tools 提供了 Maven Plugin 和 Gradle Plugin 来简化 GraalVM
-CE 的 `native-image` 工具的长篇大论的 shell 命令。
+CE 的 `native-image` 命令行工具的长篇大论的 shell 命令。
ShardingSphere JDBC 要求在如下或更高版本的 `GraalVM CE` 完成构建 GraalVM Native Image。使用者可通过 SDKMAN! 快速切换 JDK。这同理
适用于 `Oracle GraalVM`, `Liberica Native Image Kit` 和 `Mandrel` 等 `GraalVM CE` 的下游发行版。
- GraalVM CE 23.0.2 For JDK 17.0.9,对应于 SDKMAN! 的 `17.0.9-graalce`
-- GraalVM CE 23.0.2 For JDK 21.0.1,对应于 SDKMAN! 的 `21.0.1-graalce`
+- GraalVM CE 23.1.1 For JDK 21.0.1,对应于 SDKMAN! 的 `21.0.1-graalce`
### Maven 生态
-使用者需要配置额外的 BuildArgs ,以阻止 GroovyShell 的相关类在构建 GraalVM Native Image 时报错。并主动使用 GraalVM Reachability
-Metadata 中央仓库。如下配置可供参考,以配置项目额外的 Maven Profile,以 GraalVM Native Build Tools 的文档为准。
+使用者需要主动使用 GraalVM Reachability Metadata 中央仓库。
+如下配置可供参考,以配置项目额外的 Maven Profiles,以 GraalVM Native Build Tools 的文档为准。
```xml
@@ -41,9 +41,6 @@ Metadata 中央仓库。如下配置可供参考,以配置项目额外的 Mave
0.9.28
true
-
- --report-unsupported-elements-at-runtime
-
true
@@ -72,8 +69,8 @@ Metadata 中央仓库。如下配置可供参考,以配置项目额外的 Mave
### Gradle 生态
-使用者需要配置额外的 BuildArgs ,以阻止 GroovyShell 的相关类在构建 GraalVM Native Image 时报错。并主动使用 GraalVM Reachability
-Metadata 中央仓库。如下配置可供参考,以配置项目额外的 Gradle Task,以 GraalVM Native Build Tools 的文档为准。
+使用者需要主动使用 GraalVM Reachability Metadata 中央仓库。
+如下配置可供参考,以配置项目额外的 Gradle Tasks,以 GraalVM Native Build Tools 的文档为准。
```groovy
plugins {
@@ -85,26 +82,17 @@ dependencies {
}
graalvmNative {
- binaries {
- main {
- buildArgs.add('--report-unsupported-elements-at-runtime')
- }
- test {
- buildArgs.add('--report-unsupported-elements-at-runtime')
- }
- }
metadataRepository {
enabled = true
}
}
```
-### 对于 SBT 等不被 GraalVM Native Build Tools 支持的构建工具
+### 对于 sbt 等不被 GraalVM Native Build Tools 支持的构建工具
此类需求需要在 https://github.com/graalvm/native-build-tools 打开额外的 issue 并提供对应构建工具的 Plugin 实现。
-
-### 使用限制
+## 使用限制
1. 如下的算法类由于涉及到 https://github.com/oracle/graal/issues/5522 , 暂未可在 GraalVM Native Image 下使用。
- `org.apache.shardingsphere.sharding.algorithm.sharding.inline.InlineShardingAlgorithm`
diff --git a/docs/document/content/user-manual/shardingsphere-jdbc/graalvm-native-image/_index.en.md b/docs/document/content/user-manual/shardingsphere-jdbc/graalvm-native-image/_index.en.md
index 7702642b5b5b82..f93b27e09f6936 100644
--- a/docs/document/content/user-manual/shardingsphere-jdbc/graalvm-native-image/_index.en.md
+++ b/docs/document/content/user-manual/shardingsphere-jdbc/graalvm-native-image/_index.en.md
@@ -10,21 +10,20 @@ ShardingSphere JDBC has been validated for availability under GraalVM Native Ima
Build GraalVM Native containing Maven dependencies of `org.apache.shardingsphere:shardingsphere-jdbc-core:${shardingsphere.version}`
Image, you need to resort to GraalVM Native Build Tools. GraalVM Native Build Tools provides Maven Plugin and Gradle Plugin
-to simplify long list of shell commands for GraalVM CE's `native-image` tool.
+to simplify long list of shell commands for GraalVM CE's `native-image` command line tool.
ShardingSphere JDBC requires GraalVM Native Image to be built with GraalVM CE as follows or higher. Users can quickly switch
JDK through `SDKMAN!`. Same reason applicable to downstream distributions of `GraalVM CE` such as `Oracle GraalVM`, `Liberica Native Image Kit`
and `Mandrel`.
- GraalVM CE 23.0.2 For JDK 17.0.9, corresponding to `17.0.9-graalce` of SDKMAN!
-- GraalVM CE 23.0.2 For JDK 21.0.1, corresponding to `21.0.1-graalce` of SDKMAN!
+- GraalVM CE 23.1.1 For JDK 21.0.1, corresponding to `21.0.1-graalce` of SDKMAN!
### Maven Ecology
-Users need to configure additional `BuildArgs` to prevent GroovyShell related classes from reporting errors when building
-GraalVM Native Image. and proactively use GraalVM Reachability Metadata central repository. The following configuration
-is for reference to configure additional Maven Profiles for the project, and the documentation of GraalVM Native Build
-Tools shall prevail.
+Users need to actively use the GraalVM Reachability Metadata central repository.
+The following configuration is for reference to configure additional Maven Profiles for the project,
+and the documentation of GraalVM Native Build Tools shall prevail.
```xml
@@ -44,9 +43,6 @@ Tools shall prevail.
0.9.28
true
-
- --report-unsupported-elements-at-runtime
-
true
@@ -75,10 +71,9 @@ Tools shall prevail.
### Gradle Ecosystem
-Users need to configure additional `BuildArgs` to prevent GroovyShell related classes from reporting errors when building
-GraalVM Native Image. and proactively use GraalVM Reachability Metadata central repository. The following configuration
-is for reference to configure additional Gradle Task for the project, and the documentation of GraalVM Native Build
-Tools shall prevail.
+Users need to actively use the GraalVM Reachability Metadata central repository.
+The following configuration is for reference to configure additional Gradle Tasks for the project,
+and the documentation of GraalVM Native Build Tools shall prevail.
```groovy
plugins {
@@ -90,27 +85,18 @@ dependencies {
}
graalvmNative {
- binaries {
- main {
- buildArgs.add('--report-unsupported-elements-at-runtime')
- }
- test {
- buildArgs.add('--report-unsupported-elements-at-runtime')
- }
- }
metadataRepository {
enabled = true
}
}
```
-### For build tools such as SBT that are not supported by GraalVM Native Build Tools
-
-Such requirements require opening additional issues at https://github.com/graalvm/native-build-tools and providing the Plugin
-implementation of the corresponding build tool.
+### For build tools such as sbt that are not supported by GraalVM Native Build Tools
+Such requirements require opening additional issues at https://github.com/graalvm/native-build-tools
+and providing the Plugin implementation of the corresponding build tool.
-### Usage restrictions
+## Usage restrictions
1. The following algorithm classes are not available under GraalVM Native Image due to the involvement of https://github.com/oracle/graal/issues/5522.
- `org.apache.shardingsphere.sharding.algorithm.sharding.inline.InlineShardingAlgorithm`
diff --git a/docs/document/content/user-manual/shardingsphere-proxy/startup/graalvm-native-image.cn.md b/docs/document/content/user-manual/shardingsphere-proxy/startup/graalvm-native-image.cn.md
index a8b17547ee45c5..0c4adf765c751a 100644
--- a/docs/document/content/user-manual/shardingsphere-proxy/startup/graalvm-native-image.cn.md
+++ b/docs/document/content/user-manual/shardingsphere-proxy/startup/graalvm-native-image.cn.md
@@ -25,17 +25,9 @@ services:
- "3307:3307"
```
-- 当前阶段,GraalVM Native Image 形态的 ShardingSphere Proxy 不支持使用 `InlineExpressionParser` SPI 的默认实现的 `行表达式`,
- 这首先导致 `数据分片` 功能的`actualDataNodes` 属性只能使用其他 `InlineExpressionParser` SPI 的实现来配置, 例如使用
- `InlineExpressionParser` SPI 实现为 `LITERAL` 的 `行表达式`, 即 `ds_0.t_order_0, ds_0.t_order_1`
- 或 `ds_0.t_user_0, ds_15.t_user_1023`。
-
- 本节假定处于 Linux(amd64,aarch64), MacOS(amd64)或 Windows(amd64)环境。
如果你位于 MacOS(aarch64/M1) 环境,你需要关注尚未关闭的 https://github.com/oracle/graal/issues/2666 。
-- `org.apache.shardingsphere:shardingsphere-cluster-mode-repository-etcd` 受
- https://github.com/micronaut-projects/micronaut-gcp/issues/532 影响,不可使用。
-
## 前提条件
1. 根据 https://www.graalvm.org/downloads/ 要求安装和配置 JDK 17 对应的 `GraalVM Community Edition`
diff --git a/docs/document/content/user-manual/shardingsphere-proxy/startup/graalvm-native-image.en.md b/docs/document/content/user-manual/shardingsphere-proxy/startup/graalvm-native-image.en.md
index 416af5d97473a8..04117da1d546bc 100644
--- a/docs/document/content/user-manual/shardingsphere-proxy/startup/graalvm-native-image.en.md
+++ b/docs/document/content/user-manual/shardingsphere-proxy/startup/graalvm-native-image.en.md
@@ -27,20 +27,10 @@ services:
- "3307:3307"
````
-- At this stage, ShardingSphere Proxy in the form of GraalVM Native Image does not support `row expressions` using the
- default implementation of the `InlineExpressionParser` SPI.
- This first results in the `actualDataNodes` property of the `data sharding` feature that can only be configured using
- other implementations of the `InlineExpressionParser` SPI, for example using `LITERAL` implemented
- `InlineExpressionParser` SPI for `row expression`, i.e. `ds_0.t_order_0, ds_0.t_order_1`
- or `ds_0.t_user_0, ds_15.t_user_1023`.
-
- This section assumes a Linux (amd64, aarch64), MacOS (amd64) or Windows (amd64) environment.
If you are on MacOS (aarch64/M1) environment, you need to follow https://github.com/oracle/graal/issues/2666 which is
not closed yet.
-- `org.apache.shardingsphere:shardingsphere-cluster-mode-repository-etcd` is affected by
- https://github.com/micronaut-projects/micronaut-gcp/issues/532 and cannot be used.
-
## Premise
1. Install and configure `GraalVM Community Edition` or a downstream distribution of `GraalVM Community Edition` for
diff --git a/infra/expr/core/src/main/java/org/apache/shardingsphere/infra/expr/core/InlineExpressionParserFactory.java b/infra/expr/core/src/main/java/org/apache/shardingsphere/infra/expr/core/InlineExpressionParserFactory.java
index d0ce9bfdec5f84..f2077be762f39b 100644
--- a/infra/expr/core/src/main/java/org/apache/shardingsphere/infra/expr/core/InlineExpressionParserFactory.java
+++ b/infra/expr/core/src/main/java/org/apache/shardingsphere/infra/expr/core/InlineExpressionParserFactory.java
@@ -33,6 +33,14 @@ public final class InlineExpressionParserFactory {
private static final String TYPE_NAME_BEGIN_SYMBOL = "<";
private static final String TYPE_NAME_END_SYMBOL = ">";
+
+ /**
+ * ShardingSphere has never directly supported the `GROOVY` implementation of Row Value Expression SPI under GraalVM Native Image.
+ * Therefore, ShardingSphere JDBC Core will directly avoid compiling `Closure` related classes under GraalVM Native Image until a new solution emerges.
+ *
+ * @see groovy.lang.Closure
+ */
+ private static final String DEFAULT_TYPE_NAME = null == System.getProperty("org.graalvm.nativeimage.imagecode") ? "GROOVY" : "LITERAL";
/**
* Create new instance of inline expression parser by inlineExpression.
@@ -44,11 +52,11 @@ public final class InlineExpressionParserFactory {
public static InlineExpressionParser newInstance(final String inlineExpression) {
Properties props = new Properties();
if (null == inlineExpression) {
- return TypedSPILoader.getService(InlineExpressionParser.class, "GROOVY", props);
+ return TypedSPILoader.getService(InlineExpressionParser.class, DEFAULT_TYPE_NAME, props);
}
if (!inlineExpression.startsWith(TYPE_NAME_BEGIN_SYMBOL)) {
props.setProperty(InlineExpressionParser.INLINE_EXPRESSION_KEY, inlineExpression);
- return TypedSPILoader.getService(InlineExpressionParser.class, "GROOVY", props);
+ return TypedSPILoader.getService(InlineExpressionParser.class, DEFAULT_TYPE_NAME, props);
}
Integer typeBeginIndex = inlineExpression.indexOf(TYPE_NAME_BEGIN_SYMBOL);
Integer typeEndIndex = inlineExpression.indexOf(TYPE_NAME_END_SYMBOL);
@@ -57,7 +65,7 @@ public static InlineExpressionParser newInstance(final String inlineExpression)
}
private static String getTypeName(final String inlineExpression, final Integer beginIndex, final Integer endIndex) {
- return beginIndex.equals(-1) || endIndex.equals(-1) ? "GROOVY" : inlineExpression.substring(beginIndex + 1, endIndex);
+ return beginIndex.equals(-1) || endIndex.equals(-1) ? DEFAULT_TYPE_NAME : inlineExpression.substring(beginIndex + 1, endIndex);
}
private static String getExprWithoutTypeName(final String inlineExpression, final Integer beginIndex, final Integer endIndex) {
diff --git a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.groovy/groovy/4.0.10/reflect-config.json b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.groovy/groovy/4.0.10/reflect-config.json
index 5449d84e76d290..1cb1c3d99a6693 100644
--- a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.groovy/groovy/4.0.10/reflect-config.json
+++ b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.groovy/groovy/4.0.10/reflect-config.json
@@ -115,6 +115,10 @@
"condition":{"typeReachable":"org.codehaus.groovy.reflection.GeneratedMetaMethod$DgmMethodRecord"},
"name":"groovy.util.BufferedIterator"
},
+{
+ "condition":{"typeReachable":"org.codehaus.groovy.reflection.GeneratedMetaMethod$DgmMethodRecord"},
+ "name":"java.lang.Boolean"
+},
{
"condition":{"typeReachable":"org.codehaus.groovy.reflection.GeneratedMetaMethod$DgmMethodRecord"},
"name":"java.lang.Thread"
diff --git a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.groovy/groovy/4.0.10/resource-config.json b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.groovy/groovy/4.0.10/resource-config.json
new file mode 100644
index 00000000000000..87e3c880925ca3
--- /dev/null
+++ b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.groovy/groovy/4.0.10/resource-config.json
@@ -0,0 +1,8 @@
+{
+ "resources":{
+ "includes":[{
+ "condition":{"typeReachable":"org.codehaus.groovy.reflection.GeneratedMetaMethod$DgmMethodRecord"},
+ "pattern":"\\QMETA-INF/dgminfo\\E"
+ }]},
+ "bundles":[]
+}
diff --git a/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/native-image.properties b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/native-image.properties
new file mode 100644
index 00000000000000..2a4e2b71cecae1
--- /dev/null
+++ b/infra/reachability-metadata/src/main/resources/META-INF/native-image/org.apache.shardingsphere/shardingsphere-infra-reachability-metadata/native-image.properties
@@ -0,0 +1 @@
+Args = --report-unsupported-elements-at-runtime
diff --git a/pom.xml b/pom.xml
index ff32ff9b0442a7..7a1f448118581d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1011,10 +1011,6 @@
generateMetadata
17
- true
- true
- true
- true
true
@@ -1041,8 +1037,8 @@
Conditional
- ${user.dir}/test/natived/native-image-filter/user-code-filter.json
- ${user.dir}/test/natived/native-image-filter/extra-filter.json
+ ${user.dir}/test/native/native-image-filter/user-code-filter.json
+ ${user.dir}/test/native/native-image-filter/extra-filter.json
true
@@ -1098,9 +1094,6 @@
${native-maven-plugin.version}
true
-
- --report-unsupported-elements-at-runtime
-
${project.build.outputDirectory}
true
diff --git a/test/native/pom.xml b/test/native/pom.xml
index 49121ac32698a8..8f861e0099eaf8 100644
--- a/test/native/pom.xml
+++ b/test/native/pom.xml
@@ -26,10 +26,6 @@
shardingsphere-test-native
${project.artifactId}
-
- true
-
-
org.apache.shardingsphere
@@ -43,16 +39,6 @@
hamcrest
test
-
- com.zaxxer
- HikariCP
- test
-
-
- com.h2database
- h2
- test
-
diff --git a/test/native/src/test/resources/META-INF/native-image/shardingsphere-test-native-metadata/reflect-config.json b/test/native/src/test/resources/META-INF/native-image/shardingsphere-test-native-test-metadata/reflect-config.json
similarity index 100%
rename from test/native/src/test/resources/META-INF/native-image/shardingsphere-test-native-metadata/reflect-config.json
rename to test/native/src/test/resources/META-INF/native-image/shardingsphere-test-native-test-metadata/reflect-config.json
diff --git a/test/native/src/test/resources/META-INF/native-image/shardingsphere-test-native-metadata/resource-config.json b/test/native/src/test/resources/META-INF/native-image/shardingsphere-test-native-test-metadata/resource-config.json
similarity index 100%
rename from test/native/src/test/resources/META-INF/native-image/shardingsphere-test-native-metadata/resource-config.json
rename to test/native/src/test/resources/META-INF/native-image/shardingsphere-test-native-test-metadata/resource-config.json
diff --git a/test/native/src/test/resources/yaml/readwrite-splitting.yaml b/test/native/src/test/resources/yaml/readwrite-splitting.yaml
index 36782ac1bd9f6d..d8fa8fa18acc57 100644
--- a/test/native/src/test/resources/yaml/readwrite-splitting.yaml
+++ b/test/native/src/test/resources/yaml/readwrite-splitting.yaml
@@ -43,7 +43,7 @@ dataSources:
rules:
- !READWRITE_SPLITTING
# We need to prevent the logical database name, writeDataSourceName and readDataSourceNames from being parsed by
- # GroovyShell under Native Image for the read-write separation function.
+ # `groovy.lang.Closure` under Native Image for the read-write separation function.
# That is, switch to another Row Value Expression SPI implementation.
dataSources:
readwrite_ds:
diff --git a/test/native/src/test/resources/yaml/sharding.yaml b/test/native/src/test/resources/yaml/sharding.yaml
index 363122a894c59d..860cf57c9a421b 100644
--- a/test/native/src/test/resources/yaml/sharding.yaml
+++ b/test/native/src/test/resources/yaml/sharding.yaml
@@ -58,7 +58,7 @@ rules:
shardingColumn: user_id
shardingAlgorithmName: inline
shardingAlgorithms:
- # GroovyShell related classes are not available on GraalVM CE 23.0.2 For JDK 17.0.9,
+ # `groovy.lang.Closure` related classes are not available on GraalVM CE 23.0.2 For JDK 17.0.9,
# This CLASS_BASE algorithm class is designed to emulate INLINE's `ds_${user_id % 2}`.
# See https://github.com/oracle/graal/issues/5522 .
inline: