use of org.springframework.boot.system.JavaVersion in project spring-boot by spring-projects.
the class OnJavaCondition method getMatchOutcome.
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
Map<String, Object> attributes = metadata.getAnnotationAttributes(ConditionalOnJava.class.getName());
Range range = (Range) attributes.get("range");
JavaVersion version = (JavaVersion) attributes.get("value");
return getMatchOutcome(range, JVM_VERSION, version);
}
use of org.springframework.boot.system.JavaVersion in project spring-boot by spring-projects.
the class ConditionalOnJavaTests method getJavaVersion.
private String getJavaVersion(Class<?>... hiddenClasses) throws Exception {
FilteredClassLoader classLoader = new FilteredClassLoader(hiddenClasses);
Class<?> javaVersionClass = Class.forName(JavaVersion.class.getName(), false, classLoader);
Method getJavaVersionMethod = ReflectionUtils.findMethod(javaVersionClass, "getJavaVersion");
Object javaVersion = ReflectionUtils.invokeMethod(getJavaVersionMethod, null);
classLoader.close();
return javaVersion.toString();
}
Aggregations