Skip to content

Commit b400b0f

Browse files
remove redundant reflective class access (#1426)
1 parent 5fb6b6a commit b400b0f

File tree

1 file changed

+14
-27
lines changed

1 file changed

+14
-27
lines changed

querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/JavaTypeMapping.java

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@
2828
import com.querydsl.r2dbc.types.DoubleType;
2929
import com.querydsl.r2dbc.types.FloatType;
3030
import com.querydsl.r2dbc.types.IntegerType;
31+
import com.querydsl.r2dbc.types.JSR310InstantType;
32+
import com.querydsl.r2dbc.types.JSR310LocalDateTimeType;
33+
import com.querydsl.r2dbc.types.JSR310LocalDateType;
34+
import com.querydsl.r2dbc.types.JSR310LocalTimeType;
35+
import com.querydsl.r2dbc.types.JSR310OffsetDateTimeType;
36+
import com.querydsl.r2dbc.types.JSR310OffsetTimeType;
37+
import com.querydsl.r2dbc.types.JSR310ZonedDateTimeType;
3138
import com.querydsl.r2dbc.types.LocaleType;
3239
import com.querydsl.r2dbc.types.LongType;
3340
import com.querydsl.r2dbc.types.NullType;
@@ -82,33 +89,13 @@ class JavaTypeMapping {
8289
registerDefault(new UtilUUIDType());
8390

8491
// initialize java time api (JSR 310) converters only if java 8 is available
85-
try {
86-
Class.forName("java.time.Instant");
87-
registerDefault(
88-
(Type<?, ?>) Class.forName("com.querydsl.r2dbc.types.JSR310InstantType").newInstance());
89-
registerDefault(
90-
(Type<?, ?>)
91-
Class.forName("com.querydsl.r2dbc.types.JSR310LocalDateTimeType").newInstance());
92-
registerDefault(
93-
(Type<?, ?>) Class.forName("com.querydsl.r2dbc.types.JSR310LocalDateType").newInstance());
94-
registerDefault(
95-
(Type<?, ?>) Class.forName("com.querydsl.r2dbc.types.JSR310LocalTimeType").newInstance());
96-
registerDefault(
97-
(Type<?, ?>)
98-
Class.forName("com.querydsl.r2dbc.types.JSR310OffsetDateTimeType").newInstance());
99-
registerDefault(
100-
(Type<?, ?>)
101-
Class.forName("com.querydsl.r2dbc.types.JSR310OffsetTimeType").newInstance());
102-
registerDefault(
103-
(Type<?, ?>)
104-
Class.forName("com.querydsl.r2dbc.types.JSR310ZonedDateTimeType").newInstance());
105-
} catch (ClassNotFoundException e) {
106-
// converters for JSR 310 are not loaded
107-
} catch (InstantiationException e) {
108-
throw new RuntimeException(e);
109-
} catch (IllegalAccessException e) {
110-
throw new RuntimeException(e);
111-
}
92+
registerDefault(new JSR310InstantType());
93+
registerDefault(new JSR310LocalDateTimeType());
94+
registerDefault(new JSR310LocalDateType());
95+
registerDefault(new JSR310LocalTimeType());
96+
registerDefault(new JSR310OffsetDateTimeType());
97+
registerDefault(new JSR310OffsetTimeType());
98+
registerDefault(new JSR310ZonedDateTimeType());
11299
}
113100

114101
private static void registerDefault(Type<?, ?> type) {

0 commit comments

Comments
 (0)