Skip to content
Browse files
添加dubbo3.0支持graalvm文档(英文) (#866)
  • Loading branch information
weeeeiz committed Jul 16, 2021
1 parent d54ff28 commit b6f99341d5afb4635d053c0f4ffa9b87abe785d8
Show file tree
Hide file tree
Showing 2 changed files with 159 additions and 0 deletions.
@@ -0,0 +1,7 @@
type: docs
title: "graalvm support"
linkTitle: "support graalvm"
weight: 40
description: ""
@@ -0,0 +1,152 @@
## Overview

This document will show you how to access GraalVM with a dubbo project and how to compile the project to a binary executable using native-image.

For more information about GraalVM, read

## Demo

Before compiling the dubbo project, make sure that we are programming based on the GraalVM environment.

1. Install GraalVM

Visite the official website ( ) and install the latest version based on your system:


After installation, configure the path of JAVA_HOME. You should see thr following in your local jdk after this step:


GraalVM we use here is based on jdk version 1.8.
To install native-image, run 'gu install native-image'.

2. Pull dubbo code and switch to branch [apache:3.0](

3. Manually generate SPI code

Currently native-image compiling does not support dynamic code generation. Therefore we need to first manually generate the part of the code that is generated dynamically. The tool function is provided here:


Execute CodeGenerator can generate SPI code under the dubbo-native module.

4. Execute 'install' under the root directory

MacdeMacBook-pro-3:incubator-dubbo mac$ pwd
MacdeMacBook-pro-3:incubator-dubbo mac$ mvn clean package install -Dmaven.test.skip=true

5. Compile the project demo

Here we provide a demo project that can be directly compiled: dubbo-demo / dubbo-demo-native. After installation, first go to the provider in dubbo-demo-native and execute native-image compilation:

mvn clean package -P native -Dmaven.test.skip=true

Since we have imported native-image plugin in maven, here we can use '-P native' to execute the plugin.


After a success compilation, we can find the generated binary file under target. Succefully iniate a zookeeper locally and execute the binary executable file should show us this:


Compile on consumer' side will generate a binary executable file 'demo-native-consumer' under consumer's target. Execute the file will give us the following output:


### Additional Steps

In this demo, we did extra work to make sure the project can be compiled. Here are the additional steps:

- Import dependency dubbo-native


Our generated SPI code is in this module.

- Import native-image plug-in


Generated image names and parameters used for generating image are defined.

- Mount native-image-agent

Since some classes, including reflection and JNI, need to be assigned, we have to use the agent to run the json information that generate these classes.

Add the following to startup parameters:


Launch in conventional way, create folder 'META-INF.native-image' under the resources folder and paste the generated files in the local directory into the folder.


(Missing classes' information may exist. These information need to be manually added according to the error message reported while compiling or running.)

**Finished the steps above, now you can compile your project.**

0 comments on commit b6f9934

Please sign in to comment.