public final class PlatformSpecific extends Object
RequiresJdk8
: animal-sniffer will not scan the annotated class or methods
for Java 6 API compatibility, so use this annotation at the smallest possible scope
createXYZ
public static method in PlatformSpecific
utility
classPlatformSpecific.createXYZ
whenever you need a new instancepublic static <S> MethodProbe createLongMethodProbe(Method method, Probe probe, int type) { if (JavaVersion.isAtLeast(JAVA_8)) { return new LongMethodProbeJdk8<S>(method, probe, type); } else { return new MethodProbe.LongMethodProbe<S>(method, probe, type); } }This should be tested in two separate tests, to ensure the proper instance is created depending on Java runtime version, like this:
@Test public void testJdk8Probe() { // ensure this test only runs on JDK 8+ assumeJdk8OrNewer(); MethodProbe jdk8Probe = PlatformSpecific.createLongMethodProbe(...); assertTrue(jdk8Probe instanceof LongMethodProbeJdk8.class); }
Copyright © 2019 Hazelcast, Inc.. All rights reserved.