@Test public void testJavaVersion() { Java.Version v = Java.parseVersion("9"); assertThat(v.majorVersion).isEqualTo(9); assertThat(v.minorVersion).isEqualTo(0); assertThat(v.isJava9Compatible()).isTrue(); v = Java.parseVersion("9.0.1"); assertThat(v.majorVersion).isEqualTo(9); assertThat(v.minorVersion).isEqualTo(0); assertThat(v.isJava9Compatible()).isTrue(); v = Java.parseVersion("9.0.0.15"); assertThat(v.majorVersion).isEqualTo(9); assertThat(v.minorVersion).isEqualTo(0); assertThat(v.isJava9Compatible()).isTrue(); v = Java.parseVersion("9.1"); assertThat(v.majorVersion).isEqualTo(9); assertThat(v.minorVersion).isEqualTo(1); assertThat(v.isJava9Compatible()).isTrue(); v = Java.parseVersion("1.8.0_152"); assertThat(v.majorVersion).isEqualTo(1); assertThat(v.minorVersion).isEqualTo(8); assertThat(v.isJava9Compatible()).isFalse(); v = Java.parseVersion("1.7.0_80"); assertThat(v.majorVersion).isEqualTo(1); assertThat(v.minorVersion).isEqualTo(7); assertThat(v.isJava9Compatible()).isFalse(); }
static Version parseVersion(String versionString) { final StringTokenizer st = new StringTokenizer(versionString, "."); int majorVersion = Integer.parseInt(st.nextToken()); int minorVersion; if (st.hasMoreTokens()) minorVersion = Integer.parseInt(st.nextToken()); else minorVersion = 0; return new Version(majorVersion, minorVersion); }
Java { static Version parseVersion(String versionString) { final StringTokenizer st = new StringTokenizer(versionString, "."); int majorVersion = Integer.parseInt(st.nextToken()); int minorVersion; if (st.hasMoreTokens()) minorVersion = Integer.parseInt(st.nextToken()); else minorVersion = 0; return new Version(majorVersion, minorVersion); } }
Java { static Version parseVersion(String versionString) { final StringTokenizer st = new StringTokenizer(versionString, "."); int majorVersion = Integer.parseInt(st.nextToken()); int minorVersion; if (st.hasMoreTokens()) minorVersion = Integer.parseInt(st.nextToken()); else minorVersion = 0; return new Version(majorVersion, minorVersion); } private  Java(); }
Java { static Version parseVersion(String versionString) { final StringTokenizer st = new StringTokenizer(versionString, "."); int majorVersion = Integer.parseInt(st.nextToken()); int minorVersion; if (st.hasMoreTokens()) minorVersion = Integer.parseInt(st.nextToken()); else minorVersion = 0; return new Version(majorVersion, minorVersion); } private  Java();  }
Java { static Version parseVersion(String versionString) { final StringTokenizer st = new StringTokenizer(versionString, "."); int majorVersion = Integer.parseInt(st.nextToken()); int minorVersion; if (st.hasMoreTokens()) minorVersion = Integer.parseInt(st.nextToken()); else minorVersion = 0; return new Version(majorVersion, minorVersion); } private  Java();  static final boolean IS_JAVA9_COMPATIBLE; }