Skip to content

Missing AOT hints for for types associated with remote chunking #4307

Closed
@joshlong

Description

@joshlong

I spent some time trying to get a sample application that uses remote chunking to work in an AOT/GraalVM native image.

I registered a handful of hints related to my own business domain types in each of the leader and worker nodes, but the following RuntimeHintsRegistrar configuration is generalized, and was needed both leader and worker.

	static class Hints implements RuntimeHintsRegistrar {

		@Override
		public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
			var classLiterals = Set.of(
					// batch
					org.springframework.batch.core.JobParameters.class,
					org.springframework.batch.core.JobParameter.class, ChunkRequest.class, ExitStatus.class,
					StepContribution.class, JobExecution.class, Entity.class, ExecutionContext.class,
					StepExecution.class, ChunkResponse.class, Chunk.class, JobInstance.class,

					// jdk
					java.util.LinkedHashSet.class, java.util.LinkedHashMap.class, java.util.HashSet.class,
					ReentrantLock.class, ConcurrentHashMap.class, AbstractOwnableSynchronizer.class,
					AbstractQueuedSynchronizer.class);
			var classStrings = Set.of(
					// jdk
					"java.time.Ser", "java.util.Collections$SynchronizedSet",
					"java.util.Collections$SynchronizedCollection", "java.util.concurrent.locks.ReentrantLock$Sync",
					"java.util.concurrent.locks.ReentrantLock$FairSync",
					"java.util.concurrent.locks.ReentrantLock$NonfairSync",
					"java.util.concurrent.ConcurrentHashMap$Segment");
			var all = new HashSet<String>();
			all.addAll(classLiterals.stream().map(Class::getName).collect(Collectors.toSet()));
			all.addAll(classStrings);

			var typeReferences = all.stream().map(TypeReference::of).collect(Collectors.toSet());
			typeReferences.forEach(c -> hints.serialization().registerType(c));
			typeReferences.forEach(c -> hints.reflection().registerType(c, MemberCategory.values()));

		}

	}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions