Skip to content

Make it possible to run Spring ConversionService with Substrate VM  #507

Closed
@sdeleuze

Description

@sdeleuze

With this simple project that has only a dependency on spring-core-5.0.7.RELEASE:

import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.support.DefaultConversionService;

public class Converter {

	private ConversionService service = new DefaultConversionService();

	public static void main(String[] args) {
		new Converter().convert("12345", Integer.class);
	}

	private void convert(String string, Class<Integer> type) {
		assert service.canConvert(String.class, Integer.class);
		System.err.println(service.convert(string, type));
	}
}

With following proxy configuration:

[
  ["java.lang.reflect.ParameterizedType", "org.springframework.core.SerializableTypeWrapper$SerializableTypeProxy", "java.io.Serializable"]
]

Using on GraalVM master, it complies fine but generates this error when running:

Exception in thread "main" java.lang.reflect.InvocationTargetException
	at java.lang.Throwable.<init>(Throwable.java:310)
	at java.lang.Exception.<init>(Exception.java:102)
	at java.lang.ReflectiveOperationException.<init>(ReflectiveOperationException.java:89)
	at java.lang.reflect.InvocationTargetException.<init>(InvocationTargetException.java:72)
	at com.oracle.svm.reflect.proxies.Proxy_1_Converter_main.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:173)
Caused by: java.lang.IllegalArgumentException: Unsupported Type class: java.lang.Class
	at java.lang.Throwable.<init>(Throwable.java:265)
	at java.lang.Exception.<init>(Exception.java:66)
	at java.lang.RuntimeException.<init>(RuntimeException.java:62)
	at java.lang.IllegalArgumentException.<init>(IllegalArgumentException.java:52)
	at org.springframework.core.SerializableTypeWrapper.forTypeProvider(SerializableTypeWrapper.java:161)
	at org.springframework.core.SerializableTypeWrapper.forGenericInterfaces(SerializableTypeWrapper.java:102)
	at org.springframework.core.ResolvableType.getInterfaces(ResolvableType.java:476)
	at org.springframework.core.ResolvableType.as(ResolvableType.java:436)
	at org.springframework.core.convert.support.GenericConversionService.getRequiredTypeInfo(GenericConversionService.java:292)
	at org.springframework.core.convert.support.GenericConversionService.addConverterFactory(GenericConversionService.java:111)
	at org.springframework.core.convert.support.DefaultConversionService.addScalarConverters(DefaultConversionService.java:135)
	at org.springframework.core.convert.support.DefaultConversionService.addDefaultConverters(DefaultConversionService.java:88)
	at org.springframework.core.convert.support.DefaultConversionService.<init>(DefaultConversionService.java:52)
	at Converter.<init>(Converter.java:6)
	at Converter.main(Converter.java:9)
	... 3 more

Any chance to fix this or to give us some hints about how to find to right configuration to avoid this error?

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions