1 /* |
1 /* |
2 * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
70 } |
70 } |
71 |
71 |
72 public static void main(String [] args) throws Exception { |
72 public static void main(String [] args) throws Exception { |
73 String classVersion = getProperty("java.class.version"); |
73 String classVersion = getProperty("java.class.version"); |
74 String javaVersion = getProperty("java.version"); |
74 String javaVersion = getProperty("java.version"); |
75 String VMVersion = getProperty("java.vm.version"); |
|
76 String runtimeVersion = getProperty("java.runtime.version"); |
75 String runtimeVersion = getProperty("java.runtime.version"); |
77 String specVersion = getProperty("java.specification.version"); |
76 String specVersion = getProperty("java.specification.version"); |
|
77 String vmSpecVersion = getProperty("java.vm.specification.version"); |
|
78 String featureVersion = Integer.toString(Runtime.version().feature()); |
78 |
79 |
79 if (! (javaVersion.startsWith(specVersion) && |
80 if (! (javaVersion.startsWith(specVersion) && |
80 runtimeVersion.startsWith(specVersion))) |
81 runtimeVersion.startsWith(specVersion) && |
|
82 specVersion.equals(featureVersion) && |
|
83 vmSpecVersion.equals(featureVersion))) { |
81 throw new Exception("Invalid version-related system properties"); |
84 throw new Exception("Invalid version-related system properties"); |
|
85 } |
82 |
86 |
83 //---------------------------------------------------------------- |
87 //---------------------------------------------------------------- |
84 // Check that java.class.version is correct. |
88 // Check that java.class.version is correct. |
85 // Injecting a larger major or minor version number into a |
89 // Injecting a larger major or minor version number into a |
86 // .class file should result in UnsupportedClassVersionError. |
90 // .class file should result in UnsupportedClassVersionError. |