001/*002 * Copyright 2012-2015 the original author or authors.003 *004 * Licensed under the Apache License, Version 2.0 (the "License");005 * you may not use this file except in compliance with the License.006 * You may obtain a copy of the License at007 *008 * http://www.apache.org/licenses/LICENSE-2.0009 *010 * Unless required by applicable law or agreed to in writing, software011 * distributed under the License is distributed on an "AS IS" BASIS,012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.013 * See the License for the specific language governing permissions and014 * limitations under the License.015 */016017package org.springframework.boot.autoconfigure.condition;018019import java.lang.annotation.Documented;020import java.lang.annotation.ElementType;021import java.lang.annotation.Retention;022import java.lang.annotation.RetentionPolicy;023import java.lang.annotation.Target;024025import org.springframework.context.annotation.Conditional;026import org.springframework.util.Assert;027import org.springframework.util.ClassUtils;028029/**030 * {@link Conditional} that matches based on the JVM version the application is running031 * on.032 *033 * @author Oliver Gierke034 * @author Phillip Webb035 * @author Andy Wilkinson036 * @since 1.1.0037 */038@Target({ ElementType.TYPE, ElementType.METHOD })039@Retention(RetentionPolicy.RUNTIME)040@Documented041@Conditional(OnJavaCondition.class)042public @interface ConditionalOnJava {043044 /**045 * Configures whether the value configured in {@link #value()} shall be considered the046 * upper exclusive or lower inclusive boundary. Defaults to047 * {@link Range#EQUAL_OR_NEWER}.048 * @return the range049 */050 Range range() default Range.EQUAL_OR_NEWER;051052 /**053 * The {@link JavaVersion} to check for. Use {@link #range()} to specify whether the054 * configured value is an upper-exclusive or lower-inclusive boundary.055 * @return the java version056 */057 JavaVersion value();058059 /**060 * Range options.061 */062 enum Range {063064 /**065 * Equal to, or newer than the specified {@link JavaVersion}.066 */067 EQUAL_OR_NEWER,068069 /**070 * Older than the specified {@link JavaVersion}.071 */072 OLDER_THAN073074 }075076 /**077 * Java versions.078 */079 enum JavaVersion {080081 /**082 * Java 1.9.