/* * Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
// Returns major version number from os.version system property. // E.g. 3 on SLES 11.3 (for the linux kernel version). publicstaticint getOsVersionMajor() { if (osVersionMajor == -1) init_version(); return osVersionMajor;
}
// Returns minor version number from os.version system property. // E.g. 0 on SLES 11.3 (for the linux kernel version). publicstaticint getOsVersionMinor() { if (osVersionMinor == -1) init_version(); return osVersionMinor;
}
/** * Return a boolean for whether SA and jhsdb are ported/available * on this platform.
*/ publicstaticboolean hasSA() { if (isZero()) { returnfalse; // SA is not enabled.
} if (isAix()) { returnfalse; // SA not implemented.
} elseif (isLinux()) { if (isS390x() || isARM()) { returnfalse; // SA not implemented.
}
} // Other platforms expected to work: returntrue;
}
/** * Return true if the test JDK is hardened, otherwise false. Only valid on OSX.
*/ publicstaticboolean isHardenedOSX() throws IOException { // We only care about hardened binaries for 10.14 and later (actually 10.14.5, but // for simplicity we'll also include earlier 10.14 versions). if (getOsVersionMajor() == 10 && getOsVersionMinor() < 14) { returnfalse; // assume not hardened
}
// Find the path to the java binary.
String jdkPath = System.getProperty("java.home");
Path javaPath = Paths.get(jdkPath + "/bin/java");
String javaFileName = javaPath.toAbsolutePath().toString(); if (Files.notExists(javaPath)) { thrownew FileNotFoundException("Could not find file " + javaFileName);
}
// Run codesign on the java binary.
ProcessBuilder pb = new ProcessBuilder("codesign", "--display", "--verbose", javaFileName);
pb.redirectErrorStream(true); // redirect stderr to stdout
Process codesignProcess = pb.start();
BufferedReader is = new BufferedReader(new InputStreamReader(codesignProcess.getInputStream()));
String line; boolean isHardened = false; boolean hardenedStatusConfirmed = false; // set true when we confirm whether or not hardened while ((line = is.readLine()) != null) {
System.out.println("STDOUT: " + line); if (line.indexOf("flags=0x10000(runtime)") != -1 ) {
hardenedStatusConfirmed = true;
isHardened = true;
System.out.println("Target JDK is hardened. Some tests may be skipped.");
} elseif (line.indexOf("flags=0x20002(adhoc,linker-signed)") != -1 ) {
hardenedStatusConfirmed = true;
isHardened = false;
System.out.println("Target JDK is adhoc signed, but not hardened.");
} elseif (line.indexOf("code object is not signed at all") != -1) {
hardenedStatusConfirmed = true;
isHardened = false;
System.out.println("Target JDK is not signed, therefore not hardened.");
}
} if (!hardenedStatusConfirmed) {
System.out.println("Could not confirm if TargetJDK is hardened. Assuming not hardened.");
isHardened = false;
}
try { if (codesignProcess.waitFor(10, TimeUnit.SECONDS) == false) {
System.err.println("Timed out waiting for the codesign process to complete. Assuming not hardened.");
codesignProcess.destroyForcibly(); returnfalse; // assume not hardened
}
} catch (InterruptedException e) { thrownew RuntimeException(e);
}
/** * Returns file extension of shared library, e.g. "so" on linux, "dll" on windows. * @return file extension
*/ publicstatic String sharedLibraryExt() { if (isWindows()) { return"dll";
} elseif (isOSX()) { return"dylib";
} else { return"so";
}
}
/* * Returns name of system variable containing paths to shared native libraries.
*/ publicstatic String sharedLibraryPathVariableName() { if (isWindows()) { return"PATH";
} elseif (isOSX()) { return"DYLD_LIBRARY_PATH";
} elseif (isAix()) { return"LIBPATH";
} else { return"LD_LIBRARY_PATH";
}
}
/** * Returns absolute path to directory containing shared libraries in the tested JDK.
*/ publicstatic Path libDir() { return libDir(Paths.get(testJdk)).toAbsolutePath();
}
/** * Resolves a given path, to a JDK image, to the directory containing shared libraries. * * @param image the path to a JDK image * @return the resolved path to the directory containing shared libraries
*/ publicstatic Path libDir(Path image) { if (Platform.isWindows()) { return image.resolve("bin");
} else { return image.resolve("lib");
}
}
/* * This should match the #if condition in ClassListParser::load_class_from_source().
*/ publicstaticboolean areCustomLoadersSupportedForCDS() { return (is64bit() && (isLinux() || isOSX() || isWindows()));
}
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.1 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.