Skip to content

Commit a2ef920

Browse files
committed
Drop special logics and annotation that indicates using java 8 and 7
Related with #1207
1 parent 78375bf commit a2ef920

20 files changed

+39
-77
lines changed

src/main/java/org/apache/ibatis/binding/MapperMethod.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121
import org.apache.ibatis.mapping.MappedStatement;
2222
import org.apache.ibatis.mapping.SqlCommandType;
2323
import org.apache.ibatis.mapping.StatementType;
24-
import org.apache.ibatis.reflection.Jdk;
2524
import org.apache.ibatis.reflection.MetaObject;
26-
import org.apache.ibatis.reflection.OptionalUtil;
2725
import org.apache.ibatis.reflection.ParamNameResolver;
2826
import org.apache.ibatis.reflection.TypeParameterResolver;
2927
import org.apache.ibatis.session.Configuration;
@@ -86,7 +84,7 @@ public Object execute(SqlSession sqlSession, Object[] args) {
8684
result = sqlSession.selectOne(command.getName(), param);
8785
if (method.returnsOptional() &&
8886
(result == null || !method.getReturnType().equals(result.getClass()))) {
89-
result = OptionalUtil.ofNullable(result);
87+
result = Optional.ofNullable(result);
9088
}
9189
}
9290
break;
@@ -296,7 +294,7 @@ public MethodSignature(Configuration configuration, Class<?> mapperInterface, Me
296294
this.returnsVoid = void.class.equals(this.returnType);
297295
this.returnsMany = configuration.getObjectFactory().isCollection(this.returnType) || this.returnType.isArray();
298296
this.returnsCursor = Cursor.class.equals(this.returnType);
299-
this.returnsOptional = Jdk.optionalExists && Optional.class.equals(this.returnType);
297+
this.returnsOptional = Optional.class.equals(this.returnType);
300298
this.mapKey = getMapKey(method);
301299
this.returnsMap = this.mapKey != null;
302300
this.rowBoundsIndex = getUniqueParamIndex(method, RowBounds.class);

src/main/java/org/apache/ibatis/binding/MapperProxy.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import java.lang.reflect.Modifier;
2424
import java.util.Map;
2525

26-
import org.apache.ibatis.lang.UsesJava7;
2726
import org.apache.ibatis.reflection.ExceptionUtil;
2827
import org.apache.ibatis.session.SqlSession;
2928

@@ -63,7 +62,6 @@ private MapperMethod cachedMapperMethod(Method method) {
6362
return methodCache.computeIfAbsent(method, k -> new MapperMethod(mapperInterface, method, sqlSession.getConfiguration()));
6463
}
6564

66-
@UsesJava7
6765
private Object invokeDefaultMethod(Object proxy, Method method, Object[] args)
6866
throws Throwable {
6967
final Constructor<MethodHandles.Lookup> constructor = MethodHandles.Lookup.class

src/main/java/org/apache/ibatis/builder/annotation/MapperAnnotationBuilder.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@
8181
import org.apache.ibatis.mapping.SqlSource;
8282
import org.apache.ibatis.mapping.StatementType;
8383
import org.apache.ibatis.parsing.PropertyParser;
84-
import org.apache.ibatis.reflection.Jdk;
8584
import org.apache.ibatis.reflection.TypeParameterResolver;
8685
import org.apache.ibatis.scripting.LanguageDriver;
8786
import org.apache.ibatis.session.Configuration;
@@ -451,7 +450,7 @@ private Class<?> getReturnType(Method method) {
451450
returnType = (Class<?>) ((ParameterizedType) returnTypeParameter).getRawType();
452451
}
453452
}
454-
} else if (Jdk.optionalExists && Optional.class.equals(rawType)) {
453+
} else if (Optional.class.equals(rawType)) {
455454
Type[] actualTypeArguments = parameterizedType.getActualTypeArguments();
456455
Type returnTypeParameter = actualTypeArguments[0];
457456
if (returnTypeParameter instanceof Class<?>) {

src/main/java/org/apache/ibatis/mapping/ResultMap.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import org.apache.ibatis.builder.BuilderException;
2929
import org.apache.ibatis.logging.Log;
3030
import org.apache.ibatis.logging.LogFactory;
31-
import org.apache.ibatis.reflection.Jdk;
3231
import org.apache.ibatis.reflection.ParamNameUtil;
3332
import org.apache.ibatis.session.Configuration;
3433

@@ -193,7 +192,7 @@ private List<String> getArgNames(Constructor<?> constructor) {
193192
break;
194193
}
195194
}
196-
if (name == null && resultMap.configuration.isUseActualParamName() && Jdk.parameterExists) {
195+
if (name == null && resultMap.configuration.isUseActualParamName()) {
197196
if (actualParamNames == null) {
198197
actualParamNames = ParamNameUtil.getParamNames(constructor);
199198
}

src/main/java/org/apache/ibatis/reflection/Jdk.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ public class Jdk {
2424

2525
/**
2626
* <code>true</code> if <code>java.lang.reflect.Parameter</code> is available.
27+
* @deprecated Since 3.5.0, Will remove this field at feature(next major version up)
2728
*/
29+
@Deprecated
2830
public static final boolean parameterExists;
2931

3032
static {
@@ -38,6 +40,10 @@ public class Jdk {
3840
parameterExists = available;
3941
}
4042

43+
/**
44+
* @deprecated Since 3.5.0, Will remove this field at feature(next major version up)
45+
*/
46+
@Deprecated
4147
public static final boolean dateAndTimeApiExists;
4248

4349
static {
@@ -51,6 +57,10 @@ public class Jdk {
5157
dateAndTimeApiExists = available;
5258
}
5359

60+
/**
61+
* @deprecated Since 3.5.0, Will remove this field at feature(next major version up)
62+
*/
63+
@Deprecated
5464
public static final boolean optionalExists;
5565

5666
static {

src/main/java/org/apache/ibatis/reflection/OptionalUtil.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@
1818

1919
import java.util.Optional;
2020

21-
import org.apache.ibatis.lang.UsesJava8;
22-
21+
/**
22+
* @deprecated Since 3.5.0, Will remove this class at future(next major version up).
23+
*/
24+
@Deprecated
2325
public abstract class OptionalUtil {
2426

25-
@UsesJava8
2627
public static Object ofNullable(Object value) {
2728
return Optional.ofNullable(value);
2829
}

src/main/java/org/apache/ibatis/reflection/ParamNameResolver.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,7 @@ public ParamNameResolver(Configuration config, Method method) {
8585
}
8686

8787
private String getActualParamName(Method method, int paramIndex) {
88-
if (Jdk.parameterExists) {
89-
return ParamNameUtil.getParamNames(method).get(paramIndex);
90-
}
91-
return null;
88+
return ParamNameUtil.getParamNames(method).get(paramIndex);
9289
}
9390

9491
private static boolean isSpecialParameter(Class<?> clazz) {

src/main/java/org/apache/ibatis/reflection/ParamNameUtil.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222
import java.util.ArrayList;
2323
import java.util.List;
2424

25-
import org.apache.ibatis.lang.UsesJava8;
26-
27-
@UsesJava8
2825
public class ParamNameUtil {
2926
public static List<String> getParamNames(Method method) {
3027
return getParameterNames(method);

src/main/java/org/apache/ibatis/type/InstantTypeHandler.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2009-2017 the original author or authors.
2+
* Copyright 2009-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,13 +22,10 @@
2222
import java.sql.Timestamp;
2323
import java.time.Instant;
2424

25-
import org.apache.ibatis.lang.UsesJava8;
26-
2725
/**
2826
* @since 3.4.5
2927
* @author Tomas Rohovsky
3028
*/
31-
@UsesJava8
3229
public class InstantTypeHandler extends BaseTypeHandler<Instant> {
3330

3431
@Override

src/main/java/org/apache/ibatis/type/JapaneseDateTypeHandler.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2009-2017 the original author or authors.
2+
* Copyright 2009-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,15 +23,12 @@
2323
import java.time.LocalDate;
2424
import java.time.chrono.JapaneseDate;
2525

26-
import org.apache.ibatis.lang.UsesJava8;
27-
2826
/**
2927
* Type Handler for {@link JapaneseDate}.
3028
*
3129
* @since 3.4.5
3230
* @author Kazuki Shimizu
3331
*/
34-
@UsesJava8
3532
public class JapaneseDateTypeHandler extends BaseTypeHandler<JapaneseDate> {
3633

3734
@Override

0 commit comments

Comments
 (0)