@Test
public void testMajorVersionFromJavaSpecificationVersion() {

    final SecurityManager current = System.getSecurityManager();
    try {
        System.setSecurityManager(new SecurityManager() {
            @Override
            public void checkPropertyAccess(String key) {
                if (key.equals("java.specification.version")) {
                    // deny
                    throw new SecurityException(key);
                }
            }
            // so we can restore the security manager
            @Override
            public void checkPermission(Permission perm) {
            }
        });
        assertEquals(6, PlatformDependent0.majorVersionFromJavaSpecificationVersion());
    } finally {
        System.setSecurityManager(current);
    }
}