本文整理了Java中com.thoughtworks.xstream.core.JVM.isVersion()
方法的一些代码示例,展示了JVM.isVersion()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JVM.isVersion()
方法的具体详情如下:
包路径:com.thoughtworks.xstream.core.JVM
类名称:JVM
方法名:isVersion
[英]Checks current runtime against provided major Java version.
[中]根据提供的主要Java版本检查当前运行时。
代码示例来源:origin: com.thoughtworks.xstream/xstream
/**
* @deprecated As of 1.4.4, minimal JDK version will be 1.7 for next major release
*/
public static boolean is15() {
return isVersion(5);
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
/**
* @deprecated As of 1.4.4, minimal JDK version will be 1.7 for next major release
*/
public static boolean is16() {
return isVersion(6);
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
/**
* @since 1.4
* @deprecated As of 1.4.11 use {@link #isVersion(int)}.
*/
public static boolean is18() {
return isVersion(8);
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
/**
* @since 1.4
* @deprecated As of 1.4.10, minimal JDK version will be 1.7 for next major release
*/
public static boolean is17() {
return isVersion(7);
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
/**
* @since 1.4.10
* @deprecated As of 1.4.11 use {@link #isVersion(int)}
*/
public static boolean is9() {
return isVersion(9);
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
/**
* @deprecated As of 1.4.4, minimal JDK version is 1.4 already
*/
public static boolean is14() {
return isVersion(4);
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
protected void validateFieldAccess(Field field) {
if (Modifier.isFinal(field.getModifiers())) {
if (JVM.isVersion(5)) {
if (!field.isAccessible()) {
field.setAccessible(true);
}
} else {
throw new ObjectAccessException("Invalid final field "
+ field.getDeclaringClass().getName() + "." + field.getName());
}
}
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
public ISO8601GregorianCalendarConverter() {
SingleValueConverter svConverter = null;
final Class type = JVM.loadClassForName(JVM.isVersion(8)
? "com.thoughtworks.xstream.core.util.ISO8601JavaTimeConverter"
: "com.thoughtworks.xstream.core.util.ISO8601JodaTimeConverter");
try {
svConverter = (SingleValueConverter)type.getDeclaredConstructor(EMPTY_CLASS_ARRAY).newInstance(
EMPTY_OBJECT_ARRAY);
} catch (final InstantiationException e) {
// ignore
} catch (final IllegalAccessException e) {
// ignore
} catch (final InvocationTargetException e) {
// ignore
} catch (final NoSuchMethodException e) {
// ignore
}
converter = svConverter;
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
/**
* Get the XMLOutputFactory implementation used normally by the current Java runtime as
* standard.
* <p>
* In contrast to XMLOutputFactory.newFactory() this method will ignore any implementations
* provided with the system property <em>javax.xml.stream.XMLOutputFactory</em>,
* implementations configured in <em>lib/stax.properties</em> or registered with the Service
* API.
* </p>
*
* @return the XMLOutputFactory implementation or null
* @throws ClassNotFoundException if the standard class cannot be found
* @since 1.4.5
*/
public static Class getStaxOutputFactory() throws ClassNotFoundException {
if (isVersion(6)) {
if (isIBM()) {
return Class.forName("com.ibm.xml.xlxp.api.stax.XMLOutputFactoryImpl");
} else {
return Class.forName("com.sun.xml.internal.stream.XMLOutputFactoryImpl");
}
}
return null;
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
/**
* Get the XMLInputFactory implementation used normally by the current Java runtime as
* standard.
* <p>
* In contrast to XMLInputFactory.newFactory() this method will ignore any implementations
* provided with the system property <em>javax.xml.stream.XMLInputFactory</em>,
* implementations configured in <em>lib/stax.properties</em> or registered with the Service
* API.
* </p>
*
* @return the XMLInputFactory implementation or null
* @throws ClassNotFoundException if the standard class cannot be found
* @since 1.4.5
*/
public static Class getStaxInputFactory() throws ClassNotFoundException {
if (isVersion(6)) {
if (isIBM()) {
return Class.forName("com.ibm.xml.xlxp.api.stax.XMLInputFactoryImpl");
} else {
return Class.forName("com.sun.xml.internal.stream.XMLInputFactoryImpl");
}
}
return null;
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
/**
* Create the DocumentBuilderFactory instance.
*
* @return the new instance
* @since 1.4.9
*/
protected DocumentBuilderFactory createDocumentBuilderFactory() {
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
if (JVM.isVersion(5)) {
try {
Method method = DocumentBuilderFactory.class.getMethod("setFeature",
new Class[]{ String.class, boolean.class });
method.invoke(factory, new Object[]{ "http://apache.org/xml/features/disallow-doctype-decl", Boolean.TRUE });
} catch (NoSuchMethodException e) {
// Ignore
} catch (IllegalAccessException e) {
throw new ObjectAccessException("Cannot set feature of DocumentBuilderFactory.", e);
} catch (InvocationTargetException e) {
Throwable cause = e.getCause();
if (JVM.isVersion(6)
|| (cause instanceof ParserConfigurationException
&& cause.getMessage().indexOf("disallow-doctype-decl") < 0)) {
throw new StreamException(cause);
}
}
}
factory.setExpandEntityReferences(false);
return factory;
}
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
enumMapper = JVM.isVersion(5) ? UseAttributeForEnumMapper.createEnumMapper(mapper) : null;
代码示例来源:origin: com.thoughtworks.xstream/xstream
this.valueAsAttribute = valueAsAttribute;
this.lookup = lookup;
enumMapper = JVM.isVersion(5) ? UseAttributeForEnumMapper.createEnumMapper(mapper) : null;
代码示例来源:origin: com.thoughtworks.xstream/xstream
alias("gregorian-calendar", Calendar.class);
if (JVM.isVersion(4)) {
aliasDynamically("auth-subject", "javax.security.auth.Subject");
alias("linked-hash-map", JVM.loadClassForName("java.util.LinkedHashMap"));
if (JVM.isVersion(5)) {
aliasDynamically("xml-duration", "javax.xml.datatype.Duration");
alias("concurrent-hash-map", JVM.loadClassForName("java.util.concurrent.ConcurrentHashMap"));
if (JVM.isVersion(7)) {
aliasType("path", JVM.loadClassForName("java.nio.file.Path"));
if (JVM.isVersion(8)) {
alias("fixed-clock", JVM.loadClassForName("java.time.Clock$FixedClock"));
alias("offset-clock", JVM.loadClassForName("java.time.Clock$OffsetClock"));
代码示例来源:origin: com.thoughtworks.xstream/xstream
attributes = Collections.EMPTY_MAP;
if (!JVM.isVersion(6)) {
for (Iterator iter = attributes.values().iterator(); iter.hasNext(); ) {
if (iter.next() == null) {
代码示例来源:origin: com.thoughtworks.xstream/xstream
types.add(JVM.loadClassForName("java.sql.Date"));
if (JVM.isVersion(8)) {
xstream.allowTypeHierarchy(JVM.loadClassForName("java.time.Clock"));
types.add(JVM.loadClassForName("java.time.Duration"));
代码示例来源:origin: com.thoughtworks.xstream/xstream
registerConverter(new GregorianCalendarConverter(), PRIORITY_NORMAL);
if (JVM.isVersion(4)) {
if (JVM.isVersion(5)) {
PRIORITY_NORMAL, null, null);
if (JVM.isVersion(7)) {
registerConverterDynamically("com.thoughtworks.xstream.converters.extended.PathConverter",
PRIORITY_NORMAL, null, null);
if (JVM.isVersion(8)) {
registerConverterDynamically("com.thoughtworks.xstream.converters.time.ChronologyConverter",
PRIORITY_NORMAL, null, null);
代码示例来源:origin: com.thoughtworks.xstream/xstream
mapper = new DefaultImplementationsMapper(mapper);
mapper = new AttributeMapper(mapper, converterLookup, reflectionProvider);
if (JVM.isVersion(5)) {
mapper = buildMapperDynamically(
"com.thoughtworks.xstream.mapper.EnumMapper", new Class[]{Mapper.class},
if (JVM.isVersion(8)) {
mapper = buildMapperDynamically("com.thoughtworks.xstream.mapper.LambdaMapper", new Class[]{Mapper.class},
new Object[]{mapper});
if (JVM.isVersion(5)) {
mapper = buildMapperDynamically(ANNOTATION_MAPPER_TYPE, new Class[]{
Mapper.class, ConverterRegistry.class, ConverterLookup.class,
代码示例来源:origin: com.thoughtworks.xstream/xstream
addImmutableType(Class.class, false);
if (JVM.isVersion(7)) {
Class type = JVM.loadClassForName("java.nio.file.Paths");
if (type != null) {
if (JVM.isVersion(4)) {
if (JVM.isVersion(5)) {
addImmutableTypeDynamically("java.util.UUID", true);
addImmutableType(Collections.EMPTY_MAP.getClass(), true);
if (JVM.isVersion(8)) {
addImmutableTypeDynamically("java.time.Duration", false);
addImmutableTypeDynamically("java.time.Instant", false);
代码示例来源:origin: x-stream/xstream
/**
* @since 1.4.10
* @deprecated As of 1.4.11 use {@link #isVersion(int)}
*/
@Deprecated
public static boolean is9() {
return isVersion(9);
}
内容来源于网络,如有侵权,请联系作者删除!