View Javadoc
1   /**
2    *    Copyright 2009-2018 the original author or authors.
3    *
4    *    Licensed under the Apache License, Version 2.0 (the "License");
5    *    you may not use this file except in compliance with the License.
6    *    You may obtain a copy of the License at
7    *
8    *       http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *    Unless required by applicable law or agreed to in writing, software
11   *    distributed under the License is distributed on an "AS IS" BASIS,
12   *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *    See the License for the specific language governing permissions and
14   *    limitations under the License.
15   */
16  package org.apache.ibatis.reflection;
17  
18  import org.apache.ibatis.io.Resources;
19  
20  /**
21   * To check the existence of version dependent classes.
22   */
23  public class Jdk {
24  
25    /**
26     * <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)
28     */
29    @Deprecated
30    public static final boolean parameterExists;
31  
32    static {
33      boolean available = false;
34      try {
35        Resources.classForName("java.lang.reflect.Parameter");
36        available = true;
37      } catch (ClassNotFoundException e) {
38        // ignore
39      }
40      parameterExists = available;
41    }
42  
43    /**
44     * @deprecated Since 3.5.0, Will remove this field at feature(next major version up)
45     */
46    @Deprecated
47    public static final boolean dateAndTimeApiExists;
48  
49    static {
50      boolean available = false;
51      try {
52        Resources.classForName("java.time.Clock");
53        available = true;
54      } catch (ClassNotFoundException e) {
55        // ignore
56      }
57      dateAndTimeApiExists = available;
58    }
59  
60    /**
61     * @deprecated Since 3.5.0, Will remove this field at feature(next major version up)
62     */
63    @Deprecated
64    public static final boolean optionalExists;
65  
66    static {
67      boolean available = false;
68      try {
69        Resources.classForName("java.util.Optional");
70        available = true;
71      } catch (ClassNotFoundException e) {
72        // ignore
73      }
74      optionalExists = available;
75    }
76  
77    private Jdk() {
78      super();
79    }
80  }