Upgrade to Boot 3.x

- For now port spring-native to framework config.
- 3rd party configs should go somewhere else.
- Fix changes from javax to jakarta.
- Change java settings as we now require jdk 17.
- Fixes #385
This commit is contained in:
Janne Valkealahti
2022-07-24 08:07:14 +01:00
parent 218abd7095
commit e193ca1d24
41 changed files with 589 additions and 858 deletions

View File

@@ -19,6 +19,7 @@ import org.jline.utils.AttributedString;
import org.jline.utils.AttributedStyle;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.Banner.Mode;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.shell.jline.PromptProvider;
@@ -35,7 +36,11 @@ import org.springframework.shell.jline.PromptProvider;
public class SpringShellSample {
public static void main(String[] args) throws Exception {
SpringApplication.run(SpringShellSample.class, args);
SpringApplication application = new SpringApplication(SpringShellSample.class);
application.setBannerMode(Mode.OFF);
application.run(args);
// TODO: follow up with boot why spring.main.banner-mode=off doesn't work
// SpringApplication.run(SpringShellSample.class, args);
}
@Bean

View File

@@ -0,0 +1,99 @@
/*
* Copyright 2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.shell.samples.config;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.springframework.aot.hint.MemberCategory;
import org.springframework.aot.hint.ProxyHints;
import org.springframework.aot.hint.ReflectionHints;
import org.springframework.aot.hint.ResourceHints;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
import org.springframework.aot.hint.TypeReference;
import org.springframework.util.ClassUtils;
public class SamplesRuntimeHints implements RuntimeHintsRegistrar {
@Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
ResourceHints resource = hints.resources();
ProxyHints proxy = hints.proxies();
ReflectionHints reflection = hints.reflection();
// should go graalvm-reachability-metadata
registerResources(resource);
// should go graalvm-reachability-metadata
registerProxies(proxy, "com.sun.jna.Library", "com.sun.jna.Callback",
"org.jline.terminal.impl.jna.win.Kernel32", "org.jline.terminal.impl.jna.linux.CLibrary");
// should go graalvm-reachability-metadata
registerForMostReflection(reflection, "com.sun.jna.CallbackReference", "com.sun.jna.Native",
"com.sun.jna.NativeLong", "com.sun.jna.Pointer", "com.sun.jna.Structure",
"com.sun.jna.ptr.IntByReference", "com.sun.jna.ptr.PointerByReference", "com.sun.jna.Klass",
"com.sun.jna.Structure$FFIType", "com.sun.jna.Structure$FFIType$size_t");
// should go graalvm-reachability-metadata
registerForMostReflection(reflection, "org.jline.terminal.impl.jna.win.Kernel32$CHAR_INFO",
"org.jline.terminal.impl.jna.win.Kernel32$CONSOLE_CURSOR_INFO",
"org.jline.terminal.impl.jna.win.Kernel32$CONSOLE_SCREEN_BUFFER_INFO",
"org.jline.terminal.impl.jna.win.Kernel32$COORD",
"org.jline.terminal.impl.jna.win.Kernel32$INPUT_RECORD",
"org.jline.terminal.impl.jna.win.Kernel32$INPUT_RECORD$EventUnion",
"org.jline.terminal.impl.jna.win.Kernel32$KEY_EVENT_RECORD",
"org.jline.terminal.impl.jna.win.Kernel32$MOUSE_EVENT_RECORD",
"org.jline.terminal.impl.jna.win.Kernel32$WINDOW_BUFFER_SIZE_RECORD",
"org.jline.terminal.impl.jna.win.Kernel32$MENU_EVENT_RECORD",
"org.jline.terminal.impl.jna.win.Kernel32$FOCUS_EVENT_RECORD",
"org.jline.terminal.impl.jna.win.Kernel32$SMALL_RECT",
"org.jline.terminal.impl.jna.win.Kernel32$UnionChar");
// from spring-native sb-3.0.x branch
registerHibernateValidatorHints(hints, classLoader);
}
private void registerHibernateValidatorHints(RuntimeHints hints, ClassLoader classLoader) {
if (!ClassUtils.isPresent("org.hibernate.validator.HibernateValidator", classLoader)) {
return;
}
hints.reflection().registerType(TypeReference.of("org.hibernate.validator.internal.util.logging.Log_$logger"),
hint -> hint.withMembers(MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS));
hints.reflection().registerType(
TypeReference.of("org.hibernate.validator.internal.util.logging.Messages_$bundle"),
hint -> hint.withField("INSTANCE", fieldHint -> {
}));
}
private void registerResources(ResourceHints resource) {
resource.registerPattern("com/sun/jna/win32-x86-64/jnidispatch.dll");
}
private void registerProxies(ProxyHints proxy, String... classNames) {
typeReferences(classNames)
.forEach(tr -> proxy.registerJdkProxy(jdkProxyHint -> jdkProxyHint.proxiedInterfaces(tr)));
}
private void registerForMostReflection(ReflectionHints reflection, String... classNames) {
reflection.registerTypes(typeReferences(classNames),
hint -> {
hint.withMembers(MemberCategory.DECLARED_CLASSES, MemberCategory.DECLARED_FIELDS,
MemberCategory.PUBLIC_CLASSES, MemberCategory.PUBLIC_FIELDS,
MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.INVOKE_PUBLIC_METHODS);
});
}
private Iterable<TypeReference> typeReferences(String... classNames) {
return Stream.of(classNames).map(TypeReference::of).collect(Collectors.toList());
}
}

View File

@@ -15,172 +15,172 @@
*/
package org.springframework.shell.samples.config;
import com.sun.jna.CallbackReference;
import com.sun.jna.Native;
import com.sun.jna.NativeLong;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;
// import com.sun.jna.CallbackReference;
// import com.sun.jna.Native;
// import com.sun.jna.NativeLong;
// import com.sun.jna.Pointer;
// import com.sun.jna.Structure;
// import com.sun.jna.ptr.IntByReference;
// import com.sun.jna.ptr.PointerByReference;
import org.springframework.nativex.hint.FieldHint;
import org.springframework.nativex.hint.JdkProxyHint;
import org.springframework.nativex.hint.MethodHint;
import org.springframework.nativex.hint.NativeHint;
import org.springframework.nativex.hint.ResourceHint;
import org.springframework.nativex.hint.TypeAccess;
import org.springframework.nativex.hint.TypeHint;
import org.springframework.nativex.type.NativeConfiguration;
// import org.springframework.nativex.hint.FieldHint;
// import org.springframework.nativex.hint.JdkProxyHint;
// import org.springframework.nativex.hint.MethodHint;
// import org.springframework.nativex.hint.NativeHint;
// import org.springframework.nativex.hint.ResourceHint;
// import org.springframework.nativex.hint.TypeAccess;
// import org.springframework.nativex.hint.TypeHint;
// import org.springframework.nativex.type.NativeConfiguration;
@NativeHint(
resources = {
@ResourceHint(
patterns = {
"com/sun/jna/win32-x86-64/jnidispatch.dll"
}
),
},
types = {
@TypeHint(
types = {
CallbackReference.class, Native.class, NativeLong.class, PointerByReference.class, IntByReference.class
},
typeNames = { "com.sun.jna.Klass" },
access = {
TypeAccess.PUBLIC_CLASSES, TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.PUBLIC_FIELDS,
TypeAccess.PUBLIC_METHODS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
}
),
@TypeHint(
types = Structure.class,
fields = {
@FieldHint( name = "memory", allowWrite = true),
@FieldHint( name = "typeInfo")
},
methods = {
@MethodHint( name = "newInstance", parameterTypes = { Class.class, Pointer.class }),
@MethodHint( name = "newInstance", parameterTypes = { Class.class, long.class }),
@MethodHint( name = "newInstance", parameterTypes = { Class.class })
},
access = {
TypeAccess.PUBLIC_CLASSES, TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.PUBLIC_FIELDS,
TypeAccess.PUBLIC_METHODS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
}
),
@TypeHint(
typeNames = "com.sun.jna.Structure$FFIType",
access = {
TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
}
),
@TypeHint(
typeNames = "com.sun.jna.Structure$FFIType$size_t",
access = {
TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
}
),
@TypeHint(
typeNames = "org.jline.terminal.impl.jna.win.Kernel32$CHAR_INFO",
access = {
TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
}
),
@TypeHint(
typeNames = "org.jline.terminal.impl.jna.win.Kernel32$CONSOLE_CURSOR_INFO",
access = {
TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
}
),
@TypeHint(
typeNames = "org.jline.terminal.impl.jna.win.Kernel32$CONSOLE_SCREEN_BUFFER_INFO",
access = {
TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
}
),
@TypeHint(
typeNames = "org.jline.terminal.impl.jna.win.Kernel32$COORD",
access = {
TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
}
),
@TypeHint(
typeNames = "org.jline.terminal.impl.jna.win.Kernel32$INPUT_RECORD",
access = {
TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
}
),
@TypeHint(
typeNames = "org.jline.terminal.impl.jna.win.Kernel32$INPUT_RECORD$EventUnion",
access = {
TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
}
),
@TypeHint(
typeNames = "org.jline.terminal.impl.jna.win.Kernel32$KEY_EVENT_RECORD",
access = {
TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
}
),
@TypeHint(
typeNames = "org.jline.terminal.impl.jna.win.Kernel32$MOUSE_EVENT_RECORD",
access = {
TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
}
),
@TypeHint(
typeNames = "org.jline.terminal.impl.jna.win.Kernel32$WINDOW_BUFFER_SIZE_RECORD",
access = {
TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
}
),
@TypeHint(
typeNames = "org.jline.terminal.impl.jna.win.Kernel32$MENU_EVENT_RECORD",
access = {
TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
}
),
@TypeHint(
typeNames = "org.jline.terminal.impl.jna.win.Kernel32$FOCUS_EVENT_RECORD",
access = {
TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
}
),
@TypeHint(
typeNames = "org.jline.terminal.impl.jna.win.Kernel32$SMALL_RECT",
access = {
TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
}
),
@TypeHint(
typeNames = "org.jline.terminal.impl.jna.win.Kernel32$UnionChar",
access = {
TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
}
)
},
jdkProxies = {
@JdkProxyHint( typeNames = { "com.sun.jna.Library" }),
@JdkProxyHint( typeNames = { "com.sun.jna.Callback" }),
@JdkProxyHint( typeNames = { "org.jline.terminal.impl.jna.win.Kernel32" }),
@JdkProxyHint( typeNames = { "org.jline.terminal.impl.jna.linux.CLibrary" })
}
)
public class SpringShellNativeConfiguration implements NativeConfiguration {
// @NativeHint(
// resources = {
// @ResourceHint(
// patterns = {
// "com/sun/jna/win32-x86-64/jnidispatch.dll"
// }
// ),
// },
// types = {
// @TypeHint(
// types = {
// CallbackReference.class, Native.class, NativeLong.class, PointerByReference.class, IntByReference.class
// },
// typeNames = { "com.sun.jna.Klass" },
// access = {
// TypeAccess.PUBLIC_CLASSES, TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.PUBLIC_FIELDS,
// TypeAccess.PUBLIC_METHODS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
// TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
// }
// ),
// @TypeHint(
// types = Structure.class,
// fields = {
// @FieldHint( name = "memory", allowWrite = true),
// @FieldHint( name = "typeInfo")
// },
// methods = {
// @MethodHint( name = "newInstance", parameterTypes = { Class.class, Pointer.class }),
// @MethodHint( name = "newInstance", parameterTypes = { Class.class, long.class }),
// @MethodHint( name = "newInstance", parameterTypes = { Class.class })
// },
// access = {
// TypeAccess.PUBLIC_CLASSES, TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.PUBLIC_FIELDS,
// TypeAccess.PUBLIC_METHODS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
// TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
// }
// ),
// @TypeHint(
// typeNames = "com.sun.jna.Structure$FFIType",
// access = {
// TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
// TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
// }
// ),
// @TypeHint(
// typeNames = "com.sun.jna.Structure$FFIType$size_t",
// access = {
// TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
// TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
// }
// ),
// @TypeHint(
// typeNames = "org.jline.terminal.impl.jna.win.Kernel32$CHAR_INFO",
// access = {
// TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
// TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
// }
// ),
// @TypeHint(
// typeNames = "org.jline.terminal.impl.jna.win.Kernel32$CONSOLE_CURSOR_INFO",
// access = {
// TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
// TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
// }
// ),
// @TypeHint(
// typeNames = "org.jline.terminal.impl.jna.win.Kernel32$CONSOLE_SCREEN_BUFFER_INFO",
// access = {
// TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
// TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
// }
// ),
// @TypeHint(
// typeNames = "org.jline.terminal.impl.jna.win.Kernel32$COORD",
// access = {
// TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
// TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
// }
// ),
// @TypeHint(
// typeNames = "org.jline.terminal.impl.jna.win.Kernel32$INPUT_RECORD",
// access = {
// TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
// TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
// }
// ),
// @TypeHint(
// typeNames = "org.jline.terminal.impl.jna.win.Kernel32$INPUT_RECORD$EventUnion",
// access = {
// TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
// TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
// }
// ),
// @TypeHint(
// typeNames = "org.jline.terminal.impl.jna.win.Kernel32$KEY_EVENT_RECORD",
// access = {
// TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
// TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
// }
// ),
// @TypeHint(
// typeNames = "org.jline.terminal.impl.jna.win.Kernel32$MOUSE_EVENT_RECORD",
// access = {
// TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
// TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
// }
// ),
// @TypeHint(
// typeNames = "org.jline.terminal.impl.jna.win.Kernel32$WINDOW_BUFFER_SIZE_RECORD",
// access = {
// TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
// TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
// }
// ),
// @TypeHint(
// typeNames = "org.jline.terminal.impl.jna.win.Kernel32$MENU_EVENT_RECORD",
// access = {
// TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
// TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
// }
// ),
// @TypeHint(
// typeNames = "org.jline.terminal.impl.jna.win.Kernel32$FOCUS_EVENT_RECORD",
// access = {
// TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
// TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
// }
// ),
// @TypeHint(
// typeNames = "org.jline.terminal.impl.jna.win.Kernel32$SMALL_RECT",
// access = {
// TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
// TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
// }
// ),
// @TypeHint(
// typeNames = "org.jline.terminal.impl.jna.win.Kernel32$UnionChar",
// access = {
// TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
// TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
// }
// )
// },
// jdkProxies = {
// @JdkProxyHint( typeNames = { "com.sun.jna.Library" }),
// @JdkProxyHint( typeNames = { "com.sun.jna.Callback" }),
// @JdkProxyHint( typeNames = { "org.jline.terminal.impl.jna.win.Kernel32" }),
// @JdkProxyHint( typeNames = { "org.jline.terminal.impl.jna.linux.CLibrary" })
// }
// )
public class SpringShellNativeConfiguration /*implements NativeConfiguration*/ {
}

View File

@@ -21,7 +21,7 @@ import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import javax.validation.constraints.Size;
import jakarta.validation.constraints.Size;
import org.springframework.shell.standard.ShellComponent;
import org.springframework.shell.standard.ShellMethod;

View File

@@ -1,512 +0,0 @@
[
{
"name" : "com.sun.jna.Native",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
},
{
"name" : "java.lang.Class",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
},
{
"name" : "java.lang.reflect.Method",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
},
{
"name" : "java.lang.String",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
},
{
"name" : "java.nio.Buffer",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
},
{
"name" : "java.nio.ByteBuffer",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
},
{
"name" : "java.nio.CharBuffer",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
},
{
"name" : "java.nio.ShortBuffer",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
},
{
"name" : "java.nio.IntBuffer",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
},
{
"name" : "java.nio.LongBuffer",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
},
{
"name" : "java.nio.FloatBuffer",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
},
{
"name" : "java.nio.DoubleBuffer",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
},
{
"name" : "java.lang.Void",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"fields" : [
{ "name" : "TYPE" }
]
},
{
"name" : "java.lang.Boolean",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"fields" : [
{ "name" : "value", "allowWrite" : true },
{ "name" : "TYPE" }
]
},
{
"name" : "java.lang.Byte",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"fields" : [
{ "name" : "value", "allowWrite" : true },
{ "name" : "TYPE" }
]
},
{
"name" : "java.lang.Character",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"fields" : [
{ "name" : "value", "allowWrite" : true },
{ "name" : "TYPE" }
]
},
{
"name" : "java.lang.Short",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"fields" : [
{ "name" : "value", "allowWrite" : true },
{ "name" : "TYPE" }
]
},
{
"name" : "java.lang.Integer",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"fields" : [
{ "name" : "value", "allowWrite" : true },
{ "name" : "TYPE" }
]
},
{
"name" : "java.lang.Long",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"fields" : [
{ "name" : "value", "allowWrite" : true },
{ "name" : "TYPE" }
]
},
{
"name" : "java.lang.Float",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"fields" : [
{ "name" : "value", "allowWrite" : true },
{ "name" : "TYPE" }
]
},
{
"name" : "java.lang.Double",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"fields" : [
{ "name" : "value", "allowWrite" : true },
{ "name" : "TYPE" }
]
},
{
"name" : "com.sun.jna.Pointer",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"fields" : [
{ "name" : "peer", "allowWrite" : true }
]
},
{
"name" : "com.sun.jna.Structure$ByValue",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
},
{
"name" : "com.sun.jna.WString",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
},
{
"name" : "com.sun.jna.NativeMapped",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
},
{
"name" : "com.sun.jna.IntegerType",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
},
{
"name" : "com.sun.jna.PointerType",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
},
{
"name" : "com.sun.jna.JNIEnv",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
},
{
"name" : "com.sun.jna.Native$ffi_callback",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
},
{
"name" : "com.sun.jna.FromNativeConverter",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
},
{
"name" : "com.sun.jna.Structure",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"fields" : [
{ "name" : "memory", "allowWrite" : true },
{ "name" : "typeInfo", "allowWrite" : true }
],
"methods" : [
{ "name" : "newInstance", "parameterTypes" : ["java.lang.Class","com.sun.jna.Pointer"] },
{ "name" : "newInstance", "parameterTypes" : ["java.lang.Class", "long"] },
{ "name" : "newInstance", "parameterTypes" : ["java.lang.Class"] },
{ "name" : "getTypeInfo", "parameterTypes": ["java.lang.Object"] }
]
},
{
"name" : "com.sun.jna.Callback",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
},
{
"name" : "com.sun.jna.CallbackReference$AttachOptions",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
},
{
"name" : "com.sun.jna.CallbackReference",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
},
{
"name" : "com.sun.jna.IntegerType",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"fields" : [
{ "name" : "value", "allowWrite" : true }
]
},
{
"name" : "com.sun.jna.PointerType",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"fields" : [
{ "name" : "pointer", "allowWrite" : true }
]
},
{
"name" : "com.sun.jna.Structure$FFIType",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
},
{
"name" : "com.sun.jna.Structure$FFIType$size_t",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
},
{
"name" : "com.sun.jna.Structure$FFIType$FFITypes",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"fields" : [
{ "name" : "ffi_type_void", "allowWrite" : true },
{ "name" : "ffi_type_float", "allowWrite" : true },
{ "name" : "ffi_type_double", "allowWrite" : true },
{ "name" : "ffi_type_longdouble", "allowWrite" : true },
{ "name" : "ffi_type_uint8", "allowWrite" : true },
{ "name" : "ffi_type_sint8", "allowWrite" : true },
{ "name" : "ffi_type_uint16", "allowWrite" : true },
{ "name" : "ffi_type_sint16", "allowWrite" : true },
{ "name" : "ffi_type_uint32", "allowWrite" : true },
{ "name" : "ffi_type_sint32", "allowWrite" : true },
{ "name" : "ffi_type_uint64", "allowWrite" : true },
{ "name" : "ffi_type_sint64", "allowWrite" : true },
{ "name" : "ffi_type_pointer", "allowWrite" : true }
]
},
{
"name" : "com.sun.jna.NativeLong",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
},
{
"name" : "com.sun.jna.ptr.PointerByReference",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true
},
{
"name" : "org.jline.terminal.impl.jna.win.Kernel32$CHAR_INFO",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"fields" : [
{ "name" : "uChar", "allowWrite" : true },
{ "name" : "Attributes", "allowWrite" : true }
]
},
{
"name" : "org.jline.terminal.impl.jna.win.Kernel32$CONSOLE_CURSOR_INFO",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"fields" : [
{ "name" : "dwSize", "allowWrite" : true },
{ "name" : "bVisible", "allowWrite" : true }
]
},
{
"name" : "org.jline.terminal.impl.jna.win.Kernel32$CONSOLE_SCREEN_BUFFER_INFO",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"fields" : [
{ "name" : "dwSize", "allowWrite" : true },
{ "name" : "dwCursorPosition", "allowWrite" : true },
{ "name" : "wAttributes", "allowWrite" : true },
{ "name" : "srWindow", "allowWrite" : true },
{ "name" : "dwMaximumWindowSize", "allowWrite" : true }
]
},
{
"name" : "org.jline.terminal.impl.jna.win.Kernel32$COORD",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"fields" : [
{ "name" : "X", "allowWrite" : true },
{ "name" : "Y", "allowWrite" : true }
]
},
{
"name" : "org.jline.terminal.impl.jna.win.Kernel32$INPUT_RECORD",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"fields" : [
{ "name" : "EventType", "allowWrite" : true },
{ "name" : "Event", "allowWrite" : true }
]
},
{
"name" : "org.jline.terminal.impl.jna.win.Kernel32$INPUT_RECORD$EventUnion",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"fields" : [
{ "name" : "KeyEvent", "allowWrite" : true },
{ "name" : "MouseEvent", "allowWrite" : true },
{ "name" : "WindowBufferSizeEvent", "allowWrite" : true },
{ "name" : "MenuEvent", "allowWrite" : true },
{ "name" : "FocusEvent", "allowWrite" : true }
]
},
{
"name" : "org.jline.terminal.impl.jna.win.Kernel32$KEY_EVENT_RECORD",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"fields" : [
{ "name" : "bKeyDown", "allowWrite" : true },
{ "name" : "wRepeatCount", "allowWrite" : true },
{ "name" : "wVirtualKeyCode", "allowWrite" : true },
{ "name" : "wVirtualScanCode", "allowWrite" : true },
{ "name" : "uChar", "allowWrite" : true },
{ "name" : "dwControlKeyState", "allowWrite" : true }
]
},
{
"name" : "org.jline.terminal.impl.jna.win.Kernel32$MOUSE_EVENT_RECORD",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"fields" : [
{ "name" : "dwMousePosition", "allowWrite" : true },
{ "name" : "dwButtonState", "allowWrite" : true },
{ "name" : "dwControlKeyState", "allowWrite" : true },
{ "name" : "dwEventFlags", "allowWrite" : true }
]
},
{
"name" : "org.jline.terminal.impl.jna.win.Kernel32$WINDOW_BUFFER_SIZE_RECORD",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"fields" : [
{ "name" : "dwSize", "allowWrite" : true }
]
},
{
"name" : "org.jline.terminal.impl.jna.win.Kernel32$MENU_EVENT_RECORD",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"fields" : [
{ "name" : "dwCommandId", "allowWrite" : true }
]
},
{
"name" : "org.jline.terminal.impl.jna.win.Kernel32$FOCUS_EVENT_RECORD",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"fields" : [
{ "name" : "bSetFocus", "allowWrite" : true }
]
},
{
"name" : "org.jline.terminal.impl.jna.win.Kernel32$SMALL_RECT",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"fields" : [
{ "name" : "Left", "allowWrite" : true },
{ "name" : "Top", "allowWrite" : true },
{ "name" : "Right", "allowWrite" : true },
{ "name" : "Bottom", "allowWrite" : true }
]
},
{
"name" : "org.jline.terminal.impl.jna.win.Kernel32$UnionChar",
"allDeclaredConstructors" : true,
"allPublicConstructors" : true,
"allDeclaredMethods" : true,
"allPublicMethods" : true,
"fields" : [
{ "name" : "UnicodeChar", "allowWrite" : true },
{ "name" : "AsciiChar", "allowWrite" : true }
]
}
]

View File

@@ -1,2 +0,0 @@
org.springframework.nativex.type.NativeConfiguration=\
org.springframework.shell.samples.config.SpringShellNativeConfiguration

View File

@@ -0,0 +1,2 @@
org.springframework.aot.hint.RuntimeHintsRegistrar=\
org.springframework.shell.samples.config.SamplesRuntimeHints

View File

@@ -0,0 +1,45 @@
package org.springframework.shell.samples.config;
import java.util.Arrays;
import java.util.Set;
import java.util.stream.Stream;
import org.junit.jupiter.api.Test;
import org.springframework.aot.hint.MemberCategory;
import org.springframework.aot.hint.ReflectionHints;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.TypeHint;
import org.springframework.aot.hint.TypeReference;
import static org.assertj.core.api.Assertions.assertThat;
public class SamplesRuntimeHintsTests {
@Test
void test() {
String[] classNames = Arrays.asList("com.sun.jna.CallbackReference", "com.sun.jna.Native",
"com.sun.jna.NativeLong", "com.sun.jna.Pointer", "com.sun.jna.Structure",
"com.sun.jna.ptr.IntByReference", "com.sun.jna.ptr.PointerByReference", "com.sun.jna.Klass",
"com.sun.jna.Structure$FFIType", "com.sun.jna.Structure$FFIType$size_t").toArray(new String[0]);
ReflectionHints hints = registerHints();
typeReferences(classNames).forEach(typeReference -> {
TypeHint typeHint = hints.getTypeHint(typeReference);
assertThat(typeHint).withFailMessage(() -> "No hints found for typeReference " + typeReference).isNotNull();
Set<MemberCategory> memberCategories = typeHint.getMemberCategories();
assertThat(memberCategories).containsExactlyInAnyOrder(MemberCategory.DECLARED_CLASSES,
MemberCategory.DECLARED_FIELDS, MemberCategory.PUBLIC_CLASSES, MemberCategory.PUBLIC_FIELDS,
MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.INVOKE_PUBLIC_METHODS);
});
}
private ReflectionHints registerHints() {
RuntimeHints hints = new RuntimeHints();
new SamplesRuntimeHints().registerHints(hints, getClass().getClassLoader());
return hints.reflection();
}
private Stream<TypeReference> typeReferences(String... classNames) {
return Stream.of(classNames).map(TypeReference::of);
}
}