mirror of
https://github.com/wxd-gaming/test-all.git
synced 2026-07-01 03:44:19 +08:00
【新增】编译测试文件
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -44,3 +44,4 @@ build/
|
||||
/spring-test/target
|
||||
/spring-test/.idea
|
||||
/wxdgaming-mmoarpg/.idea
|
||||
/gvm/native-image
|
||||
|
||||
9
gvm/.idea/compiler.xml
generated
9
gvm/.idea/compiler.xml
generated
@@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<option name="BUILD_PROCESS_HEAP_SIZE" value="1700" />
|
||||
<annotationProcessing>
|
||||
<profile name="Maven default annotation processors profile" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
@@ -12,12 +13,4 @@
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
<component name="JavacSettings">
|
||||
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
|
||||
<module name="a" options="-Xpkginfo:always -Xlint:deprecation --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-exports=java.base/sun.security.pkcs=ALL-UNNAMED --add-exports=java.base/sun.reflect.annotation=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED" />
|
||||
<module name="b" options="-Xpkginfo:always -Xlint:deprecation --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-exports=java.base/sun.security.pkcs=ALL-UNNAMED --add-exports=java.base/sun.reflect.annotation=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED" />
|
||||
<module name="c" options="-Xpkginfo:always -Xlint:deprecation --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-exports=java.base/sun.security.pkcs=ALL-UNNAMED --add-exports=java.base/sun.reflect.annotation=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED" />
|
||||
<module name="gvm" options="" />
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
2
gvm/.idea/misc.xml
generated
2
gvm/.idea/misc.xml
generated
@@ -8,7 +8,7 @@
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" project-jdk-name="graalvm-21" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
8
gvm/.idea/modules.xml
generated
Normal file
8
gvm/.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/gvm.iml" filepath="$PROJECT_DIR$/gvm.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,4 +1,4 @@
|
||||
package gvm.a;
|
||||
package gvm.test.a;
|
||||
|
||||
public class Main {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package gvm.a;
|
||||
package gvm.test.a;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
@@ -19,6 +19,7 @@ import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
|
||||
@@ -254,7 +255,7 @@ public class ReflectContext {
|
||||
.filter(v -> !filterAbstract || !Modifier.isAbstract(v.getModifiers()))
|
||||
.filter(v -> !filterEnum || !v.isEnum())
|
||||
.filter(v -> !v.isAnnotation())
|
||||
.toList();
|
||||
.collect(Collectors.toList());
|
||||
return new ReflectContext(list);
|
||||
}
|
||||
|
||||
@@ -274,23 +275,28 @@ public class ReflectContext {
|
||||
url = resources.nextElement();
|
||||
if (url != null) {
|
||||
String type = url.getProtocol();
|
||||
String urlPath = URLDecoder.decode(url.getPath(), StandardCharsets.UTF_8);
|
||||
String urlPath = URLDecoder.decode(url.getPath(), StandardCharsets.UTF_8.toString());
|
||||
System.out.println("url info:" + type + " - " + urlPath);
|
||||
switch (type) {
|
||||
case "file" -> {
|
||||
case "file":
|
||||
String dir = urlPath.substring(0, urlPath.lastIndexOf(packagePath));
|
||||
findClassByFile(dir, urlPath, consumer);
|
||||
}
|
||||
case "jar", "zip" -> findClassByJar(urlPath, consumer);
|
||||
case "resource" -> {
|
||||
break;
|
||||
case "jar":
|
||||
case "zip":
|
||||
findClassByJar(urlPath, consumer);
|
||||
break;
|
||||
case "resource":
|
||||
getResources()
|
||||
.stream()
|
||||
.filter(v -> v.startsWith(packageName))
|
||||
.forEach(v -> {
|
||||
loadClass(v, consumer);
|
||||
});
|
||||
}
|
||||
case null, default -> System.out.println("未知类型:" + type + " - " + urlPath);
|
||||
break;
|
||||
default:
|
||||
System.out.println("未知类型:" + type + " - " + urlPath);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
findClassByJars(
|
||||
@@ -345,7 +351,12 @@ public class ReflectContext {
|
||||
|
||||
if (urls != null) {
|
||||
for (URL url : urls) {
|
||||
String urlPath = URLDecoder.decode(url.getPath(), StandardCharsets.UTF_8);
|
||||
String urlPath = null;
|
||||
try {
|
||||
urlPath = URLDecoder.decode(url.getPath(), StandardCharsets.UTF_8.toString());
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
// 不必搜索classes文件夹
|
||||
if (urlPath.endsWith("classes/")) {
|
||||
continue;
|
||||
@@ -1,59 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<parent>
|
||||
<artifactId>gvm</artifactId>
|
||||
<groupId>gvm</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>b</artifactId>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.6.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<transformers>
|
||||
<transformer>
|
||||
<mainClass>gvm.b.Main</mainClass>
|
||||
</transformer>
|
||||
</transformers>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>gvm</pattern>
|
||||
<shadedPattern>shaded.yourcompany.yourapp</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.13.2</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>hamcrest-core</artifactId>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.graalvm.sdk</groupId>
|
||||
<artifactId>graal-sdk</artifactId>
|
||||
<version>24.0.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<parent>
|
||||
<artifactId>gvm</artifactId>
|
||||
<groupId>gvm</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>b</artifactId>
|
||||
<build>
|
||||
<plugins>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package gvm.b;
|
||||
package gvm.test.b;
|
||||
|
||||
public class Main {
|
||||
|
||||
public void point() throws Exception {
|
||||
gvm.a.Main.print();
|
||||
gvm.test.a.Main.print();
|
||||
System.out.println(Main.class.getName() + " Hello world!");
|
||||
|
||||
}
|
||||
@@ -57,24 +57,24 @@
|
||||
<addClasspath>true</addClasspath>
|
||||
<classpathPrefix>lib/</classpathPrefix>
|
||||
<useUniqueVersions>false</useUniqueVersions>
|
||||
<mainClass>gvm.c.Main</mainClass>
|
||||
<mainClass>gvm.test.c.Main</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<!-- https://gitee.com/roseboy/classfinal -->
|
||||
<groupId>net.roseboy</groupId>
|
||||
<artifactId>classfinal-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<password>#</password><!--加密打包之后pom.xml会被删除,不用担心在jar包里找到此密码-->
|
||||
<packages>gvm</packages>
|
||||
<!-- <cfgfiles>application.yml</cfgfiles>-->
|
||||
<!-- <excludes>org.spring</excludes>-->
|
||||
<!-- <libjars>lib/a-1.0-SNAPSHOT.jar,b.jar</libjars>-->
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- <plugin>-->
|
||||
<!-- <!– https://gitee.com/roseboy/classfinal –>-->
|
||||
<!-- <groupId>net.roseboy</groupId>-->
|
||||
<!-- <artifactId>classfinal-maven-plugin</artifactId>-->
|
||||
<!-- <configuration>-->
|
||||
<!-- <password>#</password><!–加密打包之后pom.xml会被删除,不用担心在jar包里找到此密码–>-->
|
||||
<!-- <packages>gvm</packages>-->
|
||||
<!-- <!– <cfgfiles>application.yml</cfgfiles>–>-->
|
||||
<!-- <!– <excludes>org.spring</excludes>–>-->
|
||||
<!-- <!– <libjars>lib/a-1.0-SNAPSHOT.jar,b.jar</libjars>–>-->
|
||||
<!-- </configuration>-->
|
||||
<!-- </plugin>-->
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
package gvm.c;
|
||||
package gvm.test.c;
|
||||
|
||||
|
||||
import gvm.a.ReflectContext;
|
||||
import gvm.test.a.ReflectContext;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
System.setProperty("jdk.attach.allowAttachSelf", "false");
|
||||
System.out.println("=================start=================");
|
||||
ClassLoader classLoader = Main.class.getClassLoader();
|
||||
|
||||
// classLoader = RemoteClassLoader.build(
|
||||
// Main.class.getClassLoader(),
|
||||
@@ -22,16 +23,24 @@ public class Main {
|
||||
// "http://localhost/qj5/b.jar"
|
||||
// );
|
||||
|
||||
ReflectContext.Builder gvm = ReflectContext.Builder.of(classLoader, "gvm");
|
||||
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
||||
System.out.println(classLoader);
|
||||
|
||||
Enumeration<URL> urls = classLoader.getResources("gvm/test");
|
||||
while (urls.hasMoreElements()) {
|
||||
URL next = urls.nextElement();
|
||||
System.out.println(next);
|
||||
}
|
||||
|
||||
ReflectContext.Builder gvm = ReflectContext.Builder.of(classLoader, "gvm.test");
|
||||
ArrayList<String> resources = gvm.getResources();
|
||||
gvm
|
||||
.build()
|
||||
.classStream()
|
||||
.forEach(c -> System.out.println("ReflectContext:" + c));
|
||||
|
||||
System.out.println(classLoader);
|
||||
|
||||
Class<?> aClass = classLoader.loadClass("gvm.b.Main");
|
||||
Class<?> aClass = classLoader.loadClass("gvm.test.b.Main");
|
||||
if (aClass != null) {
|
||||
System.out.println(aClass.getClassLoader().hashCode());
|
||||
System.out.println(aClass.hashCode());
|
||||
@@ -1,8 +1,8 @@
|
||||
package gvm.c;
|
||||
package gvm.test.c;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import gvm.a.ReflectContext;
|
||||
import gvm.test.a.ReflectContext;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -25,7 +25,7 @@ public class NativeClassAction {
|
||||
ArrayList<String> classNames = new ArrayList<>();
|
||||
|
||||
ReflectContext.Builder
|
||||
.of(Thread.currentThread().getContextClassLoader(), "gvm").build()
|
||||
.of(Thread.currentThread().getContextClassLoader(), "gvm.test").build()
|
||||
.classStream()
|
||||
.forEach(c -> {
|
||||
System.out.println("ReflectContext:" + c);
|
||||
67
gvm/c/src/main/java/gvm/test/c/NativeMain.java
Normal file
67
gvm/c/src/main/java/gvm/test/c/NativeMain.java
Normal file
@@ -0,0 +1,67 @@
|
||||
package gvm.test.c;
|
||||
|
||||
|
||||
import gvm.test.a.ReflectContext;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
|
||||
public class NativeMain {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
System.setProperty("jdk.attach.allowAttachSelf", "false");
|
||||
System.out.println("=================start=================");
|
||||
|
||||
// classLoader = RemoteClassLoader.build(
|
||||
// Main.class.getClassLoader(),
|
||||
// "http://localhost/qj5/a.jar",
|
||||
// "http://localhost/qj5/b.jar"
|
||||
// );
|
||||
|
||||
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
|
||||
System.out.println(classLoader);
|
||||
|
||||
Enumeration<URL> urls = classLoader.getResources("gvm/test");
|
||||
while (urls.hasMoreElements()) {
|
||||
URL next = urls.nextElement();
|
||||
System.out.println(next);
|
||||
}
|
||||
|
||||
ReflectContext.Builder gvm = ReflectContext.Builder.of(classLoader, "gvm.test");
|
||||
ArrayList<String> resources = gvm.getResources();
|
||||
gvm
|
||||
.build()
|
||||
.classStream()
|
||||
.forEach(c -> System.out.println("ReflectContext:" + c));
|
||||
|
||||
|
||||
Class<?> aClass = classLoader.loadClass("gvm.test.b.Main");
|
||||
if (aClass != null) {
|
||||
System.out.println(aClass.getClassLoader().hashCode());
|
||||
System.out.println(aClass.hashCode());
|
||||
|
||||
Method point = aClass.getMethod("point");
|
||||
point.invoke(aClass.getConstructor().newInstance());
|
||||
}
|
||||
System.out.println("敲入回车关闭:");
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
|
||||
reader.readLine();
|
||||
|
||||
}
|
||||
|
||||
public static void files(String split, File file) {
|
||||
System.out.println(split + file);
|
||||
File[] files = file.listFiles();
|
||||
if (files != null) {
|
||||
for (File f : files) {
|
||||
files(split + "-", f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
1
gvm/c/src/main/resources/META-INF/native-image/.lock
Normal file
1
gvm/c/src/main/resources/META-INF/native-image/.lock
Normal file
@@ -0,0 +1 @@
|
||||
23056
|
||||
@@ -1,10 +1,10 @@
|
||||
[
|
||||
"gvm.a.Main",
|
||||
"gvm.a.ReflectContext",
|
||||
"gvm.a.ReflectContext$Builder",
|
||||
"gvm.a.ReflectContext$Builder$1",
|
||||
"gvm.a.ReflectContext$Content",
|
||||
"gvm.b.Main",
|
||||
"gvm.c.Main",
|
||||
"gvm.c.NativeClassAction"
|
||||
"gvm.test.a.Main",
|
||||
"gvm.test.a.ReflectContext",
|
||||
"gvm.test.a.ReflectContext$Builder",
|
||||
"gvm.test.a.ReflectContext$Builder$1",
|
||||
"gvm.test.a.ReflectContext$Content",
|
||||
"gvm.test.b.Main",
|
||||
"gvm.test.c.Main",
|
||||
"gvm.test.c.NativeClassAction"
|
||||
]
|
||||
56
gvm/c/src/test/java/action/NativeClassActionTest.java
Normal file
56
gvm/c/src/test/java/action/NativeClassActionTest.java
Normal file
@@ -0,0 +1,56 @@
|
||||
package action;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import gvm.test.a.ReflectContext;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* 资源读取
|
||||
*
|
||||
* @author: Troy.Chen(無心道, 15388152619)
|
||||
* @version: 2024-07-10 09:37
|
||||
**/
|
||||
public class NativeClassActionTest {
|
||||
|
||||
/**
|
||||
* 通过mvn编译调用
|
||||
* mvn clean compiler test -Dtest=action.NativeClassActionTest#f1 -DfailIfNoTests=false package -f pom.xml
|
||||
* @throws Exception
|
||||
* @author: Troy.Chen(無心道, 15388152619)
|
||||
* @version: 2024-07-12 09:56
|
||||
*/
|
||||
@Test
|
||||
public void f1() throws Exception {
|
||||
|
||||
ArrayList<String> classNames = new ArrayList<>();
|
||||
|
||||
ReflectContext.Builder
|
||||
.of(Thread.currentThread().getContextClassLoader(), "gvm.test").build()
|
||||
.classStream()
|
||||
.forEach(c -> {
|
||||
System.out.println("ReflectContext:" + c);
|
||||
classNames.add(c.getName());
|
||||
});
|
||||
|
||||
String jsonString = JSON.toJSONString(classNames, SerializerFeature.WriteNullStringAsEmpty, SerializerFeature.PrettyFormat);
|
||||
System.out.println(jsonString);
|
||||
|
||||
String first = "c/src/main/resources/resources.json";
|
||||
new File(first).getParentFile().mkdirs();
|
||||
Files.write(Paths.get(first),
|
||||
jsonString.getBytes(StandardCharsets.UTF_8),
|
||||
StandardOpenOption.CREATE,
|
||||
StandardOpenOption.TRUNCATE_EXISTING
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,13 +1,11 @@
|
||||
#!/bin/bash
|
||||
cd c/target
|
||||
pwd
|
||||
|
||||
option=""
|
||||
|
||||
option="${option} -H:+UnlockExperimentalVMOptions"
|
||||
option="${option} -H:+ReportExceptionStackTraces"
|
||||
option="${option} -H:-ParseRuntimeOptions"
|
||||
option="${option} -H:ConfigurationFileDirectories=META-INF/native-image"
|
||||
option="${option} -H:ConfigurationFileDirectories=native-image/config"
|
||||
option="${option} --enable-http"
|
||||
option="${option} --enable-https"
|
||||
option="${option} --no-fallback"
|
||||
@@ -22,6 +20,7 @@ option="${option} --initialize-at-build-time=org.apache.log4j"
|
||||
option="${option} --initialize-at-build-time=ch.qos.logback"
|
||||
option="${option} --initialize-at-build-time=io.netty"
|
||||
option="${option} --initialize-at-build-time=gvm"
|
||||
option="${option} --initialize-at-build-time=com.alibaba"
|
||||
|
||||
#<!--build-time-->
|
||||
|
||||
@@ -31,6 +30,7 @@ option="${option} --initialize-at-run-time=com.lang.server.handler.FarChannelHan
|
||||
option="${option} --initialize-at-run-time=org.slf4j.impl.StaticLoggerBinder"
|
||||
option="${option} --initialize-at-run-time=io.netty"
|
||||
option="${option} --initialize-at-run-time=gvm"
|
||||
option="${option} --initialize-at-run-time=com.alibaba"
|
||||
|
||||
|
||||
#<!--新增-->
|
||||
@@ -45,13 +45,14 @@ option="${option} --trace-class-initialization=java.beans.Introspector"
|
||||
option="${option} --trace-class-initialization=java.beans.ThreadGroupContext"
|
||||
option="${option} --trace-class-initialization=ch.qos.logback"
|
||||
option="${option} --trace-class-initialization=gvm"
|
||||
option="${option} --trace-class-initialization=com.alibaba"
|
||||
|
||||
|
||||
option="${option} -Dio.netty.tryReflectionSetAccessible=true"
|
||||
option="${option} --add-exports=java.base/java.nio=ALL-UNNAMED"
|
||||
option="${option} --add-opens java.base/java.nio=ALL-UNNAMED"
|
||||
|
||||
/usr/local/graalvm-jdk-21.0.3+7.1/bin/native-image $option -jar server-boot.jar graalvm-test
|
||||
/usr/local/graalvm-jdk-17.0.11+7.1/bin/native-image $option -cp "c/target/lib/*" -jar c/target/server-boot.jar native-image/graalvm-test
|
||||
#rm -rfv lib/gvm.*-1.0-SNAPSHOT.jar
|
||||
|
||||
./graalvm-test
|
||||
./native-image/graalvm-test
|
||||
@@ -1,7 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 设置JAVA_HOME环境变量
|
||||
export JAVA_HOME=/usr/local/graalvm-jdk-21.0.3+7.1
|
||||
#export JAVA_HOME=/usr/local/graalvm-jdk-17.0.11+7.1
|
||||
export JAVA_HOME=/usr/local/jdk-1.8.0_301
|
||||
# 将JAVA_HOME加入到PATH变量中
|
||||
export PATH=$JAVA_HOME/bin:$PATH
|
||||
# 打印出Java版本信息以验证设置是否成功
|
||||
@@ -9,8 +10,5 @@ java -version
|
||||
#cd /mnt/e/work/engine712-server
|
||||
mvn clean package -f pom.xml
|
||||
|
||||
cd c/target
|
||||
pwd
|
||||
|
||||
#/usr/local/graalvm-jdk-21.0.3+7.1/bin/java -agentlib:native-image-agent=config-merge-dir=META-INF/native-image -classpath .:lib/*:server-boot.jar gvm.c.Main
|
||||
/usr/local/graalvm-jdk-21.0.3+7.1/bin/java -agentlib:native-image-agent=config-merge-dir=META-INF/native-image -jar server-boot.jar
|
||||
/usr/local/graalvm-jdk-17.0.11+7.1/bin/java -agentlib:native-image-agent=config-merge-dir=native-image/config -cp "c/target/lib/*:c/target/server-boot.jar" gvm.test.c.NativeMain
|
||||
@@ -7,7 +7,7 @@ export PATH=$JAVA_HOME/bin:$PATH
|
||||
# 打印出Java版本信息以验证设置是否成功
|
||||
java -version
|
||||
#cd /mnt/e/work/engine712-server
|
||||
mvn clean package -f pom.xml
|
||||
mvn clean compiler test -Dtest=action.NativeClassActionTest#f1 -DfailIfNoTests=false package -f pom.xml
|
||||
|
||||
cd c/target
|
||||
|
||||
|
||||
52
gvm/pom.xml
52
gvm/pom.xml
@@ -15,8 +15,8 @@
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
@@ -56,28 +56,24 @@
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.30</version>
|
||||
<version>1.18.20</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--日志框架-->
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-access</artifactId>
|
||||
<version>1.4.14</version>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.4.14</version>
|
||||
<version>1.1.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-core</artifactId>
|
||||
<version>1.4.14</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>2.0.7</version>
|
||||
<version>1.1.3</version>
|
||||
</dependency>
|
||||
<!--日志框架-->
|
||||
<dependency>
|
||||
@@ -112,7 +108,7 @@
|
||||
<version>0.10.2</version>
|
||||
<configuration>
|
||||
<imageName>gvm-test</imageName>
|
||||
<mainClass>gvm.b.Main</mainClass>
|
||||
<mainClass>gvm.c.Main</mainClass>
|
||||
<buildArgs>
|
||||
<!-- 这些配置类基本都是指定初始化时间和一些配置,都不用管,并且不要动,否则可能会打包失败 -->
|
||||
--no-fallback
|
||||
@@ -143,20 +139,20 @@
|
||||
<!-- <fork>true</fork>-->
|
||||
<meminitial>128m</meminitial> <!-- 编译器初始化内存大小 -->
|
||||
<maxmem>1624m</maxmem> <!-- 编译器最大可用内存 -->
|
||||
<compilerArgs>
|
||||
<arg>-Xpkginfo:always</arg>
|
||||
<!-- 过期的方法的警告-->
|
||||
<arg>-Xlint:deprecation</arg>
|
||||
<arg>--add-opens=java.base/java.lang=ALL-UNNAMED</arg>
|
||||
<arg>--add-opens=java.base/java.util=ALL-UNNAMED</arg>
|
||||
<arg>--add-exports=java.base/sun.security.pkcs=ALL-UNNAMED</arg>
|
||||
<arg>--add-exports=java.base/sun.reflect.annotation=ALL-UNNAMED</arg>
|
||||
<arg>--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED</arg>
|
||||
<arg>--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg>
|
||||
<arg>--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</arg>
|
||||
<arg>--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</arg>
|
||||
<arg>--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</arg>
|
||||
</compilerArgs>
|
||||
<!-- <compilerArgs>-->
|
||||
<!-- <arg>-Xpkginfo:always</arg>-->
|
||||
<!-- <!– 过期的方法的警告–>-->
|
||||
<!-- <arg>-Xlint:deprecation</arg>-->
|
||||
<!-- <arg>--add-opens=java.base/java.lang=ALL-UNNAMED</arg>-->
|
||||
<!-- <arg>--add-opens=java.base/java.util=ALL-UNNAMED</arg>-->
|
||||
<!-- <arg>--add-exports=java.base/sun.security.pkcs=ALL-UNNAMED</arg>-->
|
||||
<!-- <arg>--add-exports=java.base/sun.reflect.annotation=ALL-UNNAMED</arg>-->
|
||||
<!-- <arg>--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED</arg>-->
|
||||
<!-- <arg>--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg>-->
|
||||
<!-- <arg>--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</arg>-->
|
||||
<!-- <arg>--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</arg>-->
|
||||
<!-- <arg>--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</arg>-->
|
||||
<!-- </compilerArgs>-->
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
||||
Reference in New Issue
Block a user