Skip to content

Commit

Permalink
Fix jOOQ compilation with GraalVM
Browse files Browse the repository at this point in the history
  • Loading branch information
luneo7 committed Oct 25, 2022
1 parent 8494774 commit ff71fa1
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus.version>2.5.1.Final</quarkus.version>
<org.jooq.version>3.15.5</org.jooq.version>
<org.jooq.version>3.15.12</org.jooq.version>
</properties>

<scm>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package io.quarkiverse.jooq.runtime.graal;

import java.util.function.BooleanSupplier;

public class PostgreSQLNotPresent implements BooleanSupplier {
@Override
public boolean getAsBoolean() {
try {
Class.forName("org.postgresql.util.PGInterval");
return false;
} catch (ClassNotFoundException e) {
return true;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package io.quarkiverse.jooq.runtime.graal;

import org.jooq.types.DayToSecond;
import org.jooq.types.YearToMonth;
import org.jooq.types.YearToSecond;

import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;

@TargetClass(className = "org.jooq.util.postgres.PostgresUtils", onlyWith = PostgreSQLNotPresent.class)
public final class PostgresUtilsSubstitutions {

@Substitute
public static DayToSecond toDayToSecond(Object pgInterval) {
throw new IllegalArgumentException(
"Unsupported interval type. Make sure you have the pgjdbc or redshift driver on your classpath: " + pgInterval);
}

@Substitute
public static YearToMonth toYearToMonth(Object pgInterval) {
throw new IllegalArgumentException(
"Unsupported interval type. Make sure you have the pgjdbc or redshift driver on your classpath: " + pgInterval);
}

@Substitute
public static Object toPGInterval(DayToSecond interval) {
throw new IllegalArgumentException(
"Unsupported interval type. Make sure you have the pgjdbc or redshift driver on your classpath: " + interval);

}

@Substitute
public static Object toPGInterval(YearToSecond interval) {
throw new IllegalArgumentException(
"Unsupported interval type. Make sure you have the pgjdbc or redshift driver on your classpath: " + interval);
}

@Substitute
public static Object toPGInterval(YearToMonth interval) {
throw new IllegalArgumentException(
"Unsupported interval type. Make sure you have the pgjdbc or redshift driver on your classpath: " + interval);
}

@Substitute
private static final boolean pgIntervalAvailable() {
return false;
}
}

0 comments on commit ff71fa1

Please sign in to comment.