|
1 | 1 | /** |
2 | | - * Copyright 2009-2017 the original author or authors. |
| 2 | + * Copyright 2009-2018 the original author or authors. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
|
31 | 31 | import java.util.List; |
32 | 32 | import java.util.Locale; |
33 | 33 | import java.util.Map; |
| 34 | +import java.util.Optional; |
34 | 35 | import java.util.Properties; |
35 | 36 | import java.util.Set; |
36 | 37 |
|
|
80 | 81 | import org.apache.ibatis.mapping.SqlSource; |
81 | 82 | import org.apache.ibatis.mapping.StatementType; |
82 | 83 | import org.apache.ibatis.parsing.PropertyParser; |
| 84 | +import org.apache.ibatis.reflection.Jdk; |
83 | 85 | import org.apache.ibatis.reflection.TypeParameterResolver; |
84 | 86 | import org.apache.ibatis.scripting.LanguageDriver; |
85 | 87 | import org.apache.ibatis.session.Configuration; |
@@ -447,13 +449,11 @@ private Class<?> getReturnType(Method method) { |
447 | 449 | returnType = (Class<?>) ((ParameterizedType) returnTypeParameter).getRawType(); |
448 | 450 | } |
449 | 451 | } |
450 | | - } else if ("java.util.Optional".equals(rawType.getName())) { |
| 452 | + } else if (Jdk.optionalExists && Optional.class.equals(rawType)) { |
451 | 453 | Type[] actualTypeArguments = parameterizedType.getActualTypeArguments(); |
452 | | - if (actualTypeArguments != null && actualTypeArguments.length == 1) { |
453 | | - Type returnTypeParameter = actualTypeArguments[0]; |
454 | | - if (returnTypeParameter instanceof Class<?>) { |
455 | | - returnType = (Class<?>) returnTypeParameter; |
456 | | - } |
| 454 | + Type returnTypeParameter = actualTypeArguments[0]; |
| 455 | + if (returnTypeParameter instanceof Class<?>) { |
| 456 | + returnType = (Class<?>) returnTypeParameter; |
457 | 457 | } |
458 | 458 | } |
459 | 459 | } |
|
0 commit comments