Skip to content

Commit

Permalink
improve comments discussing the whys of using reflection
Browse files Browse the repository at this point in the history
  • Loading branch information
anavarr committed May 23, 2022
1 parent 1e6427f commit 01b3f28
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,13 @@ public Executor get() {
public static final Supplier<Executor> VIRTUAL_EXECUTOR_SUPPLIER = new Supplier<Executor>() {
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];
Expand All @@ -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 {
Expand Down

0 comments on commit 01b3f28

Please sign in to comment.