From 01b3f2871d34da5b4ea887ee3f4b9c8e08ea7534 Mon Sep 17 00:00:00 2001 From: anavarr Date: Mon, 23 May 2022 16:40:27 +0200 Subject: [PATCH] improve comments discussing the whys of using reflection --- .../runtime/ResteasyReactiveRecorder.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive/runtime/src/main/java/io/quarkus/resteasy/reactive/server/runtime/ResteasyReactiveRecorder.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive/runtime/src/main/java/io/quarkus/resteasy/reactive/server/runtime/ResteasyReactiveRecorder.java index b32ea256221b4b..1ab27aef29823e 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive/runtime/src/main/java/io/quarkus/resteasy/reactive/server/runtime/ResteasyReactiveRecorder.java +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive/runtime/src/main/java/io/quarkus/resteasy/reactive/server/runtime/ResteasyReactiveRecorder.java @@ -70,8 +70,13 @@ public Executor get() { public static final Supplier VIRTUAL_EXECUTOR_SUPPLIER = new Supplier() { Executor current = null; - //This method is used to specify a custom executor to dispatch virtual threads on carrier threads - //It is used for test purposes for now + /** + * This method is used to specify a custom executor to dispatch virtual threads on carrier threads + * We need reflection for both ease of use (see {@link #get() Get} method) but also because we call methods + * of private classes from the java.lang package. + * + * It is used for testing purposes only for now + */ private Executor setVirtualThreadCustomScheduler(Executor executor) throws ClassNotFoundException, InvocationTargetException, InstantiationException, IllegalAccessException, NoSuchMethodException { var vtf = Class.forName("java.lang.ThreadBuilders").getDeclaredClasses()[0]; @@ -85,11 +90,13 @@ private Executor setVirtualThreadCustomScheduler(Executor executor) throws Class .invoke(this, tf); } + /** + * This method uses reflection in order to allow developers to quickly test quarkus-loom without needing to + * change --release, --source, --target flags and to enable previews. + * Since we try to load the "Loom-preview" classes/methods at runtime, the application can even be compiled + * using java 11 and executed with a loom-compliant JDK. + */ @Override - //This method uses reflection in order to allow developers to quickly test quarkus-loom without needing to - //change --release, --source, --target flags and to enable previews - //Since we try to load the "Loom-preview" classes/methods at runtime, the application can even be compiled using - //java 11 and executed with a loom-compliant JDK. public Executor get() { if (current == null) { try {