Jdk.java

  1. /*
  2.  *    Copyright 2009-2023 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.  *       https://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.    *
  25.    * @deprecated Since 3.5.0, Will remove this field at feature(next major version up)
  26.    */
  27.   @Deprecated
  28.   public static final boolean parameterExists;

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

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

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

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

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

  69.   private Jdk() {
  70.   }
  71. }