Jdk.java

  1. /*
  2.  *    Copyright 2009-2021 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. import org.apache.ibatis.io.Resources;

  18. /**
  19.  * To check the existence of version dependent classes.
  20.  */
  21. public class Jdk {

  22.   /**
  23.    * <code>true</code> if <code>java.lang.reflect.Parameter</code> is available.
  24.    * @deprecated Since 3.5.0, Will remove this field at feature(next major version up)
  25.    */
  26.   @Deprecated
  27.   public static final boolean parameterExists;

  28.   static {
  29.     boolean available = false;
  30.     try {
  31.       Resources.classForName("java.lang.reflect.Parameter");
  32.       available = true;
  33.     } catch (ClassNotFoundException e) {
  34.       // ignore
  35.     }
  36.     parameterExists = available;
  37.   }

  38.   /**
  39.    * @deprecated Since 3.5.0, Will remove this field at feature(next major version up)
  40.    */
  41.   @Deprecated
  42.   public static final boolean dateAndTimeApiExists;

  43.   static {
  44.     boolean available = false;
  45.     try {
  46.       Resources.classForName("java.time.Clock");
  47.       available = true;
  48.     } catch (ClassNotFoundException e) {
  49.       // ignore
  50.     }
  51.     dateAndTimeApiExists = available;
  52.   }

  53.   /**
  54.    * @deprecated Since 3.5.0, Will remove this field at feature(next major version up)
  55.    */
  56.   @Deprecated
  57.   public static final boolean optionalExists;

  58.   static {
  59.     boolean available = false;
  60.     try {
  61.       Resources.classForName("java.util.Optional");
  62.       available = true;
  63.     } catch (ClassNotFoundException e) {
  64.       // ignore
  65.     }
  66.     optionalExists = available;
  67.   }

  68.   private Jdk() {
  69.     super();
  70.   }
  71. }