# HG changeset patch # User mikael # Date 1562925043 25200 # Node ID d755f53becea0e8a251dbf382e12266bdffd6fd4 # Parent a35a210e6c0f7908d144836334cc9f5b0c828e20# Parent a87f5fdcd177d8150b4cd1800d036da87ce96d1d Merge diff -r a35a210e6c0f -r d755f53becea .hgtags --- a/.hgtags Thu Jul 11 15:58:54 2019 +0000 +++ b/.hgtags Fri Jul 12 02:50:43 2019 -0700 @@ -571,4 +571,5 @@ e64383344f144217c36196c3c8a2df8f588a2af3 jdk-14+3 1e95931e7d8fa7e3899340a9c7cb28dbea50c10c jdk-13+28 19d0b382f0869f72d4381b54fa129f1c74b6e766 jdk-14+4 +3081f39a3d30d63b112098386ac2bb027c2b7223 jdk-13+29 0f1e29c77e50c7da11d83df410026392c4d1a28c jdk-14+5 diff -r a35a210e6c0f -r d755f53becea make/Images.gmk --- a/make/Images.gmk Thu Jul 11 15:58:54 2019 +0000 +++ b/make/Images.gmk Fri Jul 12 02:50:43 2019 -0700 @@ -138,7 +138,7 @@ -Xmx128M -Xms128M $(LOG_INFO), \ )) - JDK_TARGETS += $(gen_cds_archive_jdk) + JRE_TARGETS += $(gen_cds_archive_jre) endif ################################################################################ diff -r a35a210e6c0f -r d755f53becea make/data/docs-resources/resources/jdk-default.css --- a/make/data/docs-resources/resources/jdk-default.css Thu Jul 11 15:58:54 2019 +0000 +++ b/make/data/docs-resources/resources/jdk-default.css Fri Jul 12 02:50:43 2019 -0700 @@ -85,6 +85,8 @@ margin-top: -1em; } +a { text-decoration: none } + a:link { color: #4A6782; } diff -r a35a210e6c0f -r d755f53becea src/java.base/share/classes/javax/crypto/CipherSpi.java --- a/src/java.base/share/classes/javax/crypto/CipherSpi.java Thu Jul 11 15:58:54 2019 +0000 +++ b/src/java.base/share/classes/javax/crypto/CipherSpi.java Fri Jul 12 02:50:43 2019 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2019, 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 @@ -761,78 +761,87 @@ + " bytes of space in output buffer"); } + // detecting input and output buffer overlap may be tricky + // we can only write directly into output buffer when we + // are 100% sure it's safe to do so + boolean a1 = input.hasArray(); boolean a2 = output.hasArray(); int total = 0; - byte[] inArray, outArray; - if (a2) { // output has an accessible byte[] - outArray = output.array(); - int outPos = output.position(); - int outOfs = output.arrayOffset() + outPos; + + if (a1) { // input has an accessible byte[] + byte[] inArray = input.array(); + int inOfs = input.arrayOffset() + inPos; + + if (a2) { // output has an accessible byte[] + byte[] outArray = output.array(); + int outPos = output.position(); + int outOfs = output.arrayOffset() + outPos; - if (a1) { // input also has an accessible byte[] - inArray = input.array(); - int inOfs = input.arrayOffset() + inPos; + // check array address and offsets and use temp output buffer + // if output offset is larger than input offset and + // falls within the range of input data + boolean useTempOut = false; + if (inArray == outArray && + ((inOfs < outOfs) && (outOfs < inOfs + inLen))) { + useTempOut = true; + outArray = new byte[outLenNeeded]; + outOfs = 0; + } if (isUpdate) { total = engineUpdate(inArray, inOfs, inLen, outArray, outOfs); } else { total = engineDoFinal(inArray, inOfs, inLen, outArray, outOfs); } + if (useTempOut) { + output.put(outArray, outOfs, total); + } else { + // adjust output position manually + output.position(outPos + total); + } + // adjust input position manually input.position(inLimit); - } else { // input does not have accessible byte[] - inArray = new byte[getTempArraySize(inLen)]; - do { - int chunk = Math.min(inLen, inArray.length); - if (chunk > 0) { - input.get(inArray, 0, chunk); - } - int n; - if (isUpdate || (inLen > chunk)) { - n = engineUpdate(inArray, 0, chunk, outArray, outOfs); - } else { - n = engineDoFinal(inArray, 0, chunk, outArray, outOfs); - } - total += n; - outOfs += n; - inLen -= chunk; - } while (inLen > 0); - } - output.position(outPos + total); - } else { // output does not have an accessible byte[] - if (a1) { // but input has an accessible byte[] - inArray = input.array(); - int inOfs = input.arrayOffset() + inPos; + } else { // output does not have an accessible byte[] + byte[] outArray = null; if (isUpdate) { outArray = engineUpdate(inArray, inOfs, inLen); } else { outArray = engineDoFinal(inArray, inOfs, inLen); } - input.position(inLimit); if (outArray != null && outArray.length != 0) { output.put(outArray); total = outArray.length; } - } else { // input also does not have an accessible byte[] - inArray = new byte[getTempArraySize(inLen)]; - do { - int chunk = Math.min(inLen, inArray.length); - if (chunk > 0) { - input.get(inArray, 0, chunk); - } - int n; - if (isUpdate || (inLen > chunk)) { - outArray = engineUpdate(inArray, 0, chunk); - } else { - outArray = engineDoFinal(inArray, 0, chunk); - } - if (outArray != null && outArray.length != 0) { - output.put(outArray); - total += outArray.length; - } - inLen -= chunk; - } while (inLen > 0); + // adjust input position manually + input.position(inLimit); + } + } else { // input does not have an accessible byte[] + // have to assume the worst, since we have no way of determine + // if input and output overlaps or not + byte[] tempOut = new byte[outLenNeeded]; + int outOfs = 0; + + byte[] tempIn = new byte[getTempArraySize(inLen)]; + do { + int chunk = Math.min(inLen, tempIn.length); + if (chunk > 0) { + input.get(tempIn, 0, chunk); + } + int n; + if (isUpdate || (inLen > chunk)) { + n = engineUpdate(tempIn, 0, chunk, tempOut, outOfs); + } else { + n = engineDoFinal(tempIn, 0, chunk, tempOut, outOfs); + } + outOfs += n; + total += n; + inLen -= chunk; + } while (inLen > 0); + if (total > 0) { + output.put(tempOut, 0, total); } } + return total; } diff -r a35a210e6c0f -r d755f53becea src/java.base/share/classes/sun/security/util/CurveDB.java --- a/src/java.base/share/classes/sun/security/util/CurveDB.java Thu Jul 11 15:58:54 2019 +0000 +++ b/src/java.base/share/classes/sun/security/util/CurveDB.java Fri Jul 12 02:50:43 2019 -0700 @@ -104,21 +104,10 @@ if (namedCurve.getCurve().getField().getFieldSize() != fieldSize) { continue; } - if (namedCurve.getCurve().equals(params.getCurve()) == false) { - continue; - } - if (namedCurve.getGenerator().equals(params.getGenerator()) == - false) { - continue; + if (ECUtil.equals(namedCurve, params)) { + // everything matches our named curve, return it + return namedCurve; } - if (namedCurve.getOrder().equals(params.getOrder()) == false) { - continue; - } - if (namedCurve.getCofactor() != params.getCofactor()) { - continue; - } - // everything matches our named curve, return it - return namedCurve; } // no match found return null; diff -r a35a210e6c0f -r d755f53becea src/java.base/share/classes/sun/security/util/ECUtil.java --- a/src/java.base/share/classes/sun/security/util/ECUtil.java Thu Jul 11 15:58:54 2019 +0000 +++ b/src/java.base/share/classes/sun/security/util/ECUtil.java Fri Jul 12 02:50:43 2019 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2019, 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 @@ -32,7 +32,7 @@ import java.security.spec.*; import java.util.Arrays; -public class ECUtil { +public final class ECUtil { // Used by SunPKCS11 and SunJSSE. public static ECPoint decodePoint(byte[] data, EllipticCurve curve) @@ -220,6 +220,21 @@ return nameSpec.getName(); } + public static boolean equals(ECParameterSpec spec1, ECParameterSpec spec2) { + if (spec1 == spec2) { + return true; + } + + if (spec1 == null || spec2 == null) { + return false; + } + return (spec1.getCofactor() == spec2.getCofactor() && + spec1.getOrder().equals(spec2.getOrder()) && + spec1.getCurve().equals(spec2.getCurve()) && + spec1.getGenerator().equals(spec2.getGenerator())); + } + + // Convert the concatenation R and S in into their DER encoding public static byte[] encodeSignature(byte[] signature) throws SignatureException { diff -r a35a210e6c0f -r d755f53becea src/java.base/share/classes/sun/security/util/SignatureUtil.java --- a/src/java.base/share/classes/sun/security/util/SignatureUtil.java Thu Jul 11 15:58:54 2019 +0000 +++ b/src/java.base/share/classes/sun/security/util/SignatureUtil.java Fri Jul 12 02:50:43 2019 -0700 @@ -28,6 +28,7 @@ import java.io.IOException; import java.security.*; import java.security.spec.*; +import java.util.Locale; import sun.security.rsa.RSAUtil; import jdk.internal.access.SharedSecrets; @@ -74,14 +75,9 @@ AlgorithmParameters params) throws ProviderException { - sigName = checkName(sigName); + sigName = checkName(sigName).toUpperCase(Locale.ENGLISH); AlgorithmParameterSpec paramSpec = null; if (params != null) { - if (sigName.toUpperCase().indexOf("RSA") == -1) { - throw new ProviderException - ("Unrecognized algorithm for signature parameters " + - sigName); - } // AlgorithmParameters.getAlgorithm() may returns oid if it's // created during DER decoding. Convert to use the standard name // before passing it to RSAUtil @@ -93,7 +89,20 @@ throw new ProviderException(e); } } - paramSpec = RSAUtil.getParamSpec(params); + + if (sigName.indexOf("RSA") != -1) { + paramSpec = RSAUtil.getParamSpec(params); + } else if (sigName.indexOf("ECDSA") != -1) { + try { + paramSpec = params.getParameterSpec(ECParameterSpec.class); + } catch (Exception e) { + throw new ProviderException("Error handling EC parameters", e); + } + } else { + throw new ProviderException + ("Unrecognized algorithm for signature parameters " + + sigName); + } } return paramSpec; } @@ -103,17 +112,31 @@ public static AlgorithmParameterSpec getParamSpec(String sigName, byte[] paramBytes) throws ProviderException { - sigName = checkName(sigName); + sigName = checkName(sigName).toUpperCase(Locale.ENGLISH); AlgorithmParameterSpec paramSpec = null; + if (paramBytes != null) { - if (sigName.toUpperCase().indexOf("RSA") == -1) { + if (sigName.indexOf("RSA") != -1) { + AlgorithmParameters params = + createAlgorithmParameters(sigName, paramBytes); + paramSpec = RSAUtil.getParamSpec(params); + } else if (sigName.indexOf("ECDSA") != -1) { + try { + Provider p = Signature.getInstance(sigName).getProvider(); + paramSpec = ECUtil.getECParameterSpec(p, paramBytes); + } catch (Exception e) { + throw new ProviderException("Error handling EC parameters", e); + } + // ECUtil discards exception and returns null, so we need to check + // the returned value + if (paramSpec == null) { + throw new ProviderException("Error handling EC parameters"); + } + } else { throw new ProviderException ("Unrecognized algorithm for signature parameters " + sigName); } - AlgorithmParameters params = - createAlgorithmParameters(sigName, paramBytes); - paramSpec = RSAUtil.getParamSpec(params); } return paramSpec; } diff -r a35a210e6c0f -r d755f53becea src/java.base/share/man/java.1 --- a/src/java.base/share/man/java.1 Thu Jul 11 15:58:54 2019 +0000 +++ b/src/java.base/share/man/java.1 Fri Jul 12 02:50:43 2019 -0700 @@ -109,7 +109,7 @@ .SH DESCRIPTION .PP The \f[CB]java\f[R] command starts a Java application. -It does this by starting the Java Runtime Environment (JRE), loading the +It does this by starting the Java Virtual Machine (JVM), loading the specified class, and calling that class\[aq]s \f[CB]main()\f[R] method. The method must be declared \f[CB]public\f[R] and \f[CB]static\f[R], it must not return any value, and it must accept a \f[CB]String\f[R] array as a @@ -566,7 +566,7 @@ .RS .RE .TP -.B \f[CB]\-disableassertions\f[R][\f[CB]:\f[R][\f[I]packagename\f[R]]...|\f[CB]:\f[R]\f[I]classname\f[R]] or \f[CB]\-da\\[\f[R]:\f[CB]\\[*packagename*\\]...|\f[R]:`\f[I]classname\f[R]] +.B \f[CB]\-disableassertions\f[R][\f[CB]:\f[R][\f[I]packagename\f[R]]...|\f[CB]:\f[R]\f[I]classname\f[R]] or \f[CB]\-da\f[R][\f[CB]:\f[R][\f[I]packagename\f[R]]...|\f[CB]:\f[R]\f[I]classname\f[R]] Disables assertions. By default, assertions are disabled in all packages and classes. With no arguments, \f[CB]\-disableassertions\f[R] (\f[CB]\-da\f[R]) disables @@ -606,7 +606,7 @@ .RS .RE .TP -.B \f[CB]\-enableassertions\f[R][\f[CB]:\f[R][\f[I]packagename\f[R]]...|\f[CB]:\f[R]\f[I]classname\f[R]] or \f[CB]\-ea\\[\f[R]:\f[CB]\\[*packagename*\\]...|\f[R]:`\f[I]classname\f[R]] +.B \f[CB]\-enableassertions\f[R][\f[CB]:\f[R][\f[I]packagename\f[R]]...|\f[CB]:\f[R]\f[I]classname\f[R]] or \f[CB]\-ea\f[R][\f[CB]:\f[R][\f[I]packagename\f[R]]...|\f[CB]:\f[R]\f[I]classname\f[R]] Enables assertions. By default, assertions are disabled in all packages and classes. With no arguments, \f[CB]\-enableassertions\f[R] (\f[CB]\-ea\f[R]) enables @@ -659,6 +659,7 @@ .TP .B \f[CB]\-javaagent:\f[R]\f[I]jarpath\f[R][\f[CB]=\f[R]\f[I]options\f[R]] Loads the specified Java programming language agent. +See \f[CB]java.lang.instrument\f[R]. .RS .RE .TP @@ -718,12 +719,12 @@ .RE .TP .B \f[CB]\-\-version\f[R] -Prints product version to the error stream and exits. +Prints product version to the output stream and exits. .RS .RE .TP .B \f[CB]\-version\f[R] -Prints product version to the output stream and exits. +Prints product version to the error stream and exits. .RS .RE .TP @@ -747,7 +748,7 @@ files after shell expansion, but before argument processing. Contents in the argument files are expanded because otherwise, they would be specified on the command line until the -\f[CB]\-Xdisable\-\@files\f[R] option was encountered. +\f[CB]\-\-disable\-\@files\f[R] option was encountered. .RS .PP The argument files can also contain the main class name and all options. @@ -856,7 +857,7 @@ .TP .B \f[CB]\-Xmn\f[R] \f[I]size\f[R] Sets the initial and maximum size (in bytes) of the heap for the young -generation (nursery). +generation (nursery) in the generational collectors. Append the letter \f[CB]k\f[R] or \f[CB]K\f[R] to indicate kilobytes, \f[CB]m\f[R] or \f[CB]M\f[R] to indicate megabytes, or \f[CB]g\f[R] or \f[CB]G\f[R] to indicate gigabytes. @@ -866,8 +867,10 @@ garbage collections are performed. If the size is too large, then only full garbage collections are performed, which can take a long time to complete. -It is recommended that you keep the size for the young generation -greater than 25% and less than 50% of the overall heap size. +It is recommended that you do not set the size for the young generation +for the G1 collector, and keep the size for the young generation greater +than 25% and less than 50% of the overall heap size for other +collectors. The following examples show how to set the initial and maximum size of young generation to 256 MB using various units: .RS @@ -887,7 +890,7 @@ .RE .TP .B \f[CB]\-Xms\f[R] \f[I]size\f[R] -Sets the initial size (in bytes) of the heap. +Sets the minimum and initial size (in bytes) of the heap. This value must be a multiple of 1024 and greater than 1 MB. Append the letter \f[CB]k\f[R] or \f[CB]K\f[R] to indicate kilobytes, \f[CB]m\f[R] or \f[CB]M\f[R] to indicate megabytes, \f[CB]g\f[R] or \f[CB]G\f[R] @@ -904,16 +907,18 @@ \f[R] .fi .PP -If you don\[aq]t set this option, then the initial size is set as the -sum of the sizes allocated for the old generation and the young -generation. +Instead of the \f[CB]\-Xms\f[R] option to set both the minimum and initial +size of the heap, you can use \f[CB]\-XX:MinHeapSize\f[R] to set the +minimum size and \f[CB]\-XX:InitialHeapSize\f[R] to set the initial size. +.PP +If you don\[aq]t set this option, the initial size is set as the sum of +the sizes allocated for the old generation and the young generation. The initial size of the heap for the young generation can be set using the \f[CB]\-Xmn\f[R] option or the \f[CB]\-XX:NewSize\f[R] option. .RE .TP .B \f[CB]\-Xmx\f[R] \f[I]size\f[R] -Specifies the maximum size (in bytes) of the memory allocation pool in -bytes. +Specifies the maximum size (in bytes) of the heap. This value must be a multiple of 1024 and greater than 2 MB. Append the letter \f[CB]k\f[R] or \f[CB]K\f[R] to indicate kilobytes, \f[CB]m\f[R] or \f[CB]M\f[R] to indicate megabytes, or \f[CB]g\f[R] or @@ -1205,13 +1210,6 @@ .RS .RE .TP -.B \f[CB]\-\-disable\-\@files\f[R] -Can be used anywhere on the command line, including in an argument file, -to prevent further \f[CB]\@\f[R]\f[I]filename\f[R] expansion. -This option stops expanding \f[CB]\@\f[R]\-argfiles after the option. -.RS -.RE -.TP .B \f[CB]\-\-source\f[R] \f[I]version\f[R] Sets the version of the source in source\-file mode. .RS @@ -1392,32 +1390,13 @@ .RS .RE .TP -.B \f[CB]\-XX:+FlightRecorder\f[R] -Enables the use of Java Flight Recorder (JFR) during the runtime of the -application. -.RS -.RS -.PP -\f[B]Note:\f[R] The \f[CB]\-XX:+FlightRecorder\f[R] option is no longer -required to use JFR. -This was a change made in JDK 8u40. -.RE -.RE -.TP -.B \f[CB]\-XX:FlightRecorderOptions=\f[R]\f[I]parameter\f[R]\f[CB]=\f[R]\f[I]value\f[R] +.B \f[CB]\-XX:FlightRecorderOptions=\f[R]\f[I]parameter\f[R]\f[CB]=\f[R]\f[I]value\f[R] (or)\f[CB]\-XX:FlightRecorderOptions:\f[R]\f[I]parameter\f[R]\f[CB]=\f[R]\f[I]value\f[R] Sets the parameters that control the behavior of JFR. .RS .PP The following list contains the available JFR \f[I]parameter\f[R]\f[CB]=\f[R]\f[I]value\f[R] entries: .TP -.B \f[CB]allow_threadbuffers_to_disk=\f[R]{\f[CB]true\f[R]|\f[CB]false\f[R]} -Specifies whether thread buffers are written directly to disk if the -buffer thread is blocked. -By default, this parameter is disabled. -.RS -.RE -.TP .B \f[CB]globalbuffersize=\f[R]\f[I]size\f[R] Specifies the total amount of primary memory used for data retention. The default value is based on the value specified for @@ -1492,7 +1471,8 @@ .TP .B \f[CB]threadbuffersize=\f[R]\f[I]size\f[R] Specifies the per\-thread local buffer size (in bytes). -By default, the local buffer size is set to 8 kilobytes. +By default, the local buffer size is set to 8 kilobytes, with a minimum +value of 4 kilobytes. Overriding this parameter could reduce performance and is not recommended. .RS @@ -2978,19 +2958,17 @@ This sets various parameters to be optimal for long\-running jobs with intensive memory allocation, based on the configuration of the computer (RAM and CPU). -By default, the option is disabled and the heap isn't optimized. +By default, the option is disabled and the heap sizes are configured +less aggressively. .RS .RE .TP .B \f[CB]\-XX:+AlwaysPreTouch\f[R] -Enables touching of every page on the Java heap during JVM -initialization. -This gets all pages into memory before entering the \f[CB]main()\f[R] -method. -The option can be used in testing to simulate a long\-running system -with all virtual memory mapped to physical memory. -By default, this option is disabled and all pages are committed as JVM -heap space fills. +Requests the VM to touch every page on the Java heap after requesting it +from the operating system and before handing memory out to the +application. +By default, this option is disabled and all pages are committed as the +application uses the heap space. .RS .RE .TP @@ -3026,12 +3004,10 @@ .RS .PP The following example shows how to set the factor to 20%: -.IP -.nf -\f[CB] ->\ \ \ `\-XX:CMSInitiatingOccupancyFraction=20` -\f[R] -.fi +.RS +.PP +\f[CB]\-XX:CMSInitiatingOccupancyFraction=20\f[R] +.RE .RE .TP .B \f[CB]\-XX:CMSIncrementalDutySafetyFactor=\f[R]\f[I]percent\f[R] @@ -3095,11 +3071,14 @@ .RS .RE .TP -.B \f[CB]\-XX:+ExplicitGCInvokesConcurrentAndUnloadsClasses\f[R] -Enables invoking of concurrent GC by using the \f[CB]System.gc()\f[R] -request and unloading of classes during the concurrent GC cycle. -This option is disabled by default and can be enabled only with the -deprecated \f[CB]\-XX:+UseConcMarkSweepGC\f[R] option. +.B \f[CB]\-XX:G1AdaptiveIHOPNumInitialSamples=\f[R]\f[I]number\f[R] +When \f[CB]\-XX:UseAdaptiveIHOP\f[R] is enabled, this option sets the +number of completed marking cycles used to gather samples until G1 +adaptively determines the optimum value of +\f[CB]\-XX:InitiatingHeapOccupancyPercent\f[R]. +Before, G1 uses the value of +\f[CB]\-XX:InitiatingHeapOccupancyPercent\f[R] directly for this purpose. +The default value is 3. .RS .RE .TP @@ -3107,10 +3086,8 @@ Sets the size of the regions into which the Java heap is subdivided when using the garbage\-first (G1) collector. The value is a power of 2 and can range from 1 MB to 32 MB. -The goal is to have around 2048 regions based on the minimum Java heap -size. The default region size is determined ergonomically based on the heap -size. +size with a goal of approximately 2048 regions. .RS .PP The following example sets the size of the subdivisions to 16 MB: @@ -3137,8 +3114,6 @@ .PP This is an experimental flag. This setting replaces the \f[CB]\-XX:DefaultMaxNewGenPercent\f[R] setting. -.PP -This setting isn\[aq]t available in Java HotSpot VM build 23 or earlier. .RE .TP .B \f[CB]\-XX:G1MixedGCCountTarget=\f[R]\f[I]number\f[R] @@ -3148,8 +3123,6 @@ The default is 8 mixed garbage collections. The goal for mixed collections is to be within this target number. .RS -.PP -This setting isn\[aq]t available in Java HotSpot VM build 23 or earlier. .RE .TP .B \f[CB]\-XX:G1MixedGCLiveThresholdPercent=\f[R]\f[I]percent\f[R] @@ -3161,8 +3134,6 @@ This is an experimental flag. This setting replaces the \f[CB]\-XX:G1OldCSetRegionLiveThresholdPercent\f[R] setting. -.PP -This setting isn\[aq]t available in Java HotSpot VM build 23 or earlier. .RE .TP .B \f[CB]\-XX:G1NewSizePercent=\f[R]\f[I]percent\f[R] @@ -3173,8 +3144,6 @@ .PP This is an experimental flag. This setting replaces the \f[CB]\-XX:DefaultMinNewGenPercent\f[R] setting. -.PP -This setting isn\[aq]t available in Java HotSpot VM build 23 or earlier. .RE .TP .B \f[CB]\-XX:G1OldCSetRegionThresholdPercent=\f[R]\f[I]percent\f[R] @@ -3182,8 +3151,6 @@ a mixed garbage collection cycle. The default is 10 percent of the Java heap. .RS -.PP -This setting isn\[aq]t available in Java HotSpot VM build 23 or earlier. .RE .TP .B \f[CB]\-XX:G1ReservePercent=\f[R]\f[I]percent\f[R] @@ -3202,10 +3169,20 @@ .RE .RE .TP -.B \f[CB]\-XX:InitialHeapOccupancyPercent=\f[R]\f[I]percent\f[R] -Sets the Java heap occupancy threshold that triggers a marking cycle. -The default occupancy is 45 percent of the entire Java heap. -.RS +.B \f[CB]\-XX:+G1UseAdaptiveIHOP\f[R] +Controls adaptive calculation of the old generation occupancy to start +background work preparing for an old generation collection. +If enabled, G1 uses \f[CB]\-XX:InitiatingHeapOccupancyPercent\f[R] for the +first few times as specified by the value of +\f[CB]\-XX:G1AdaptiveIHOPNumInitialSamples\f[R], and after that adaptively +calculates a new optimum value for the initiating occupancy +automatically. +Otherwise, the old generation collection process always starts at the +old generation occupancy determined by +\f[CB]\-XX:InitiatingHeapOccupancyPercent\f[R]. +.RS +.PP +The default is enabled. .RE .TP .B \f[CB]\-XX:InitialHeapSize=\f[R]\f[I]size\f[R] @@ -3276,15 +3253,18 @@ .RE .TP .B \f[CB]\-XX:InitiatingHeapOccupancyPercent=\f[R]\f[I]percent\f[R] -Sets the percentage of the heap occupancy (0 to 100) at which to start a -concurrent GC cycle. -It\[aq]s used by garbage collectors that trigger a concurrent GC cycle -based on the occupancy of the entire heap, not just one of the -generations (for example, the G1 garbage collector). +Sets the percentage of the old generation occupancy (0 to 100) at which +to start the first few concurrent marking cycles for the G1 garbage +collector. .RS .PP By default, the initiating value is set to 45%. -A value of 0 implies nonstop GC cycles. +A value of 0 implies nonstop concurrent GC cycles from the beginning +until G1 adaptively sets this value. +.PP +See also the \f[CB]\-XX:G1UseAdaptiveIHOP\f[R] and +\f[CB]\-XX:G1AdaptiveIHOPNumInitialSamples\f[R] options. +.PP The following example shows how to set the initiating heap occupancy to 75%: .RS @@ -3298,7 +3278,9 @@ This is a soft goal, and the JVM will make its best effort to achieve it. The specified value doesn\[aq]t adapt to your heap size. -By default, there\[aq]s no maximum pause time value. +By default, for G1 the maximum pause time target is 200 milliseconds. +The other generational collectors do not use a pause time goal by +default. .RS .PP The following example shows how to set the maximum target pause time to @@ -3332,13 +3314,6 @@ \f[R] .fi .PP -On Oracle Solaris 7 and Oracle Solaris 8 SPARC platforms, the upper -limit for this value is approximately 4,000 MB minus overhead amounts. -On Oracle Solaris 2.6 and x86 platforms, the upper limit is -approximately 2,000 MB minus overhead amounts. -On Linux platforms, the upper limit is approximately 2,000 MB minus -overhead amounts. -.PP The \f[CB]\-XX:MaxHeapSize\f[R] option is equivalent to \f[CB]\-Xmx\f[R]. .RE .TP @@ -3450,6 +3425,32 @@ embedded applications. .RE .TP +.B \f[CB]\-XX:MinHeapSize=\f[R]\f[I]size\f[R] +Sets the minimum size (in bytes) of the memory allocation pool. +This value must be either 0, or a multiple of 1024 and greater than 1 +MB. +Append the letter \f[CB]k\f[R] or \f[CB]K\f[R] to indicate kilobytes, +\f[CB]m\f[R] or \f[CB]M\f[R] to indicate megabytes, or \f[CB]g\f[R] or +\f[CB]G\f[R] to indicate gigabytes. +The default value is selected at run time based on the system +configuration. +.RS +.PP +The following examples show how to set the mimimum size of allocated +memory to 6 MB using various units: +.IP +.nf +\f[CB] +\-XX:MinHeapSize=6291456 +\-XX:MinHeapSize=6144k +\-XX:MinHeapSize=6m +\f[R] +.fi +.PP +If you set this option to 0, then the minimum size is set to the same +value as the initial size. +.RE +.TP .B \f[CB]\-XX:NewRatio=\f[R]\f[I]ratio\f[R] Sets the ratio between young and old generation sizes. By default, this option is set to 2. @@ -3493,23 +3494,13 @@ .RE .TP .B \f[CB]\-XX:ParallelGCThreads=\f[R]\f[I]threads\f[R] -Sets the value of the stop\-the\-world (STW) worker threads. -This option sets the value of \f[I]threads\f[R] to the number of logical -processors. -The value of \f[I]threads\f[R] is the same as the number of logical -processors up to a value of 8. -.RS -.PP -If there are more than 8 logical processors, then this option sets the -value of \f[I]threads\f[R] to approximately 5/8 of the logical -processors. -This works in most cases except for larger SPARC systems where the value -of \f[I]threads\f[R] can be approximately 5/16 of the logical processors. -.PP -The default value depends on the number of CPUs available to the JVM. -.PP -For example, to set the number of threads for parallel GC to 2, specify -the following option: +Sets the number of the stop\-the\-world (STW) worker threads. +The default value depends on the number of CPUs available to the JVM and +the garbage collector selected. +.RS +.PP +For example, to set the number of threads for G1 GC to 2, specify the +following option: .RS .PP \f[CB]\-XX:ParallelGCThreads=2\f[R] @@ -3749,6 +3740,22 @@ To disable the use of TLABs, specify the option \f[CB]\-XX:\-UseTLAB\f[R]. .RS .RE +.TP +.B \f[CB]\-XX:+UseZGC\f[R] +Enables the use of the Z garbage collector. +This garbage collector is best for providing lowest latency with large +Java heaps at some throughput cost. +This is an experimental garbage collector, you need to specify +\f[CB]\-XX:+UnlockExperimentalVMOptions\f[R] before \f[CB]\-XX:+UseZGC\f[R] +on the command line. +.RS +.PP +Example: +.RS +.PP +\f[CB]\-XX:+UnlockExperimentalVMOptions\ \-XX:+UseZGC\f[R] +.RE +.RE .SH DEPRECATED JAVA OPTIONS .PP These \f[CB]java\f[R] options are deprecated and might be removed in a @@ -3788,6 +3795,13 @@ .RS .RE .TP +.B \f[CB]\-XX:+FlightRecorder\f[R] +Enables the use of Java Flight Recorder (JFR) during the runtime of the +application. +Since JDK 8u40 this option has not been required to use JFR. +.RS +.RE +.TP .B \f[CB]\-XX:+TraceClassLoading\f[R] Enables tracing of classes as they are loaded. By default, this option is disabled and classes aren\[aq]t traced. @@ -3926,8 +3940,8 @@ argument list just as they would be specified on the command line. .PP The \f[CB]java\f[R] launcher expands the argument file contents until it -encounters the \f[CB]\-Xdisable\-\@files\f[R] option. -You can use the \f[CB]\-Xdisable\-\@files\f[R] option anywhere on the +encounters the \f[CB]\-\-disable\-\@files\f[R] option. +You can use the \f[CB]\-\-disable\-\@files\f[R] option anywhere on the command line, including in an argument file, to stop \f[CB]\@\f[R] argument files expansion. .PP @@ -5603,7 +5617,7 @@ response times for your application: .RS .PP -\f[CB]java\ \-XX:+UseG1GC\ \-Xms26g\ Xmx26g\ \-XX:MaxGCPauseMillis=500\f[R] +\f[CB]java\ \-XX:+UseG1GC\ \-XX:MaxGCPauseMillis=100\f[R] .RE .SS Keeping the Java Heap Small and Reducing the Dynamic Footprint of Embedded Applications diff -r a35a210e6c0f -r d755f53becea src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c --- a/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c Thu Jul 11 15:58:54 2019 +0000 +++ b/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c Fri Jul 12 02:50:43 2019 -0700 @@ -479,8 +479,7 @@ fp_gtk_fixed_new = dl_symbol("gtk_fixed_new"); fp_gtk_handle_box_new = dl_symbol("gtk_handle_box_new"); fp_gtk_image_new = dl_symbol("gtk_image_new"); - fp_gtk_hpaned_new = dl_symbol("gtk_hpaned_new"); - fp_gtk_vpaned_new = dl_symbol("gtk_vpaned_new"); + fp_gtk_paned_new = dl_symbol("gtk_paned_new"); fp_gtk_scale_new = dl_symbol("gtk_scale_new"); fp_gtk_hscrollbar_new = dl_symbol("gtk_hscrollbar_new"); fp_gtk_vscrollbar_new = dl_symbol("gtk_vscrollbar_new"); @@ -1083,7 +1082,7 @@ case SPLIT_PANE: if (init_result = (NULL == gtk3_widgets[_GTK_HPANED_TYPE])) { - gtk3_widgets[_GTK_HPANED_TYPE] = (*fp_gtk_hpaned_new)(); + gtk3_widgets[_GTK_HPANED_TYPE] = (*fp_gtk_paned_new)(GTK_ORIENTATION_HORIZONTAL); } result = gtk3_widgets[_GTK_HPANED_TYPE]; break; @@ -1316,7 +1315,7 @@ case VSPLIT_PANE_DIVIDER: if (init_result = (NULL == gtk3_widgets[_GTK_VPANED_TYPE])) { - gtk3_widgets[_GTK_VPANED_TYPE] = (*fp_gtk_vpaned_new)(); + gtk3_widgets[_GTK_VPANED_TYPE] = (*fp_gtk_paned_new)(GTK_ORIENTATION_VERTICAL); } result = gtk3_widgets[_GTK_VPANED_TYPE]; break; @@ -1436,6 +1435,10 @@ } else if (strcmp(detail, "option") == 0) { path = createWidgetPath (NULL); append_element(path, "radio"); + } else if (strcmp(detail, "paned") == 0) { + path = createWidgetPath (fp_gtk_style_context_get_path (widget_context)); + append_element(path, "paned"); + append_element(path, "separator"); } else { path = createWidgetPath (fp_gtk_style_context_get_path (widget_context)); append_element(path, detail); @@ -1834,22 +1837,30 @@ { gtk3_widget = gtk3_get_widget(widget_type); - GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget); - - fp_gtk_style_context_save (context); + GtkStyleContext* context = get_style(widget_type, detail); GtkStateFlags flags = get_gtk_flags(state_type); fp_gtk_style_context_set_state(context, GTK_STATE_FLAG_PRELIGHT); - if (detail != 0) { + if (detail != 0 && !(strcmp(detail, "paned") == 0)) { transform_detail_string(detail, context); fp_gtk_style_context_add_class (context, "handlebox_bin"); } - fp_gtk_render_handle(context, cr, x, y, width, height); - fp_gtk_render_background(context, cr, x, y, width, height); - - fp_gtk_style_context_restore (context); + if (!(strcmp(detail, "paned") == 0)) { + fp_gtk_render_handle(context, cr, x, y, width, height); + fp_gtk_render_background(context, cr, x, y, width, height); + } else { + if (orientation == GTK_ORIENTATION_VERTICAL) { + fp_gtk_render_handle(context, cr, x+width/2, y, 2, height); + fp_gtk_render_background(context, cr, x+width/2, y, 2, height); + } else { + fp_gtk_render_handle(context, cr, x, y+height/2, width, 2); + fp_gtk_render_background(context, cr, x, y+height/2, width, 2); + } + } + + disposeOrRestoreContext(context); } static void gtk3_paint_hline(WidgetType widget_type, GtkStateType state_type, diff -r a35a210e6c0f -r d755f53becea src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.h --- a/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.h Thu Jul 11 15:58:54 2019 +0000 +++ b/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.h Fri Jul 12 02:50:43 2019 -0700 @@ -163,6 +163,7 @@ typedef void GtkProgressBar; typedef void GtkProgress; typedef void GtkWidgetPath; +typedef void GtkPaned; /* Some real structures */ typedef struct @@ -503,8 +504,7 @@ static GtkWidget* (*fp_gtk_entry_new)(); static GtkWidget* (*fp_gtk_fixed_new)(); static GtkWidget* (*fp_gtk_handle_box_new)(); -static GtkWidget* (*fp_gtk_hpaned_new)(); -static GtkWidget* (*fp_gtk_vpaned_new)(); +static GtkWidget* (*fp_gtk_paned_new)(GtkOrientation orientation); static GtkWidget* (*fp_gtk_scale_new)(GtkOrientation orientation, GtkAdjustment* adjustment); static GtkWidget* (*fp_gtk_hscrollbar_new)(GtkAdjustment* adjustment); diff -r a35a210e6c0f -r d755f53becea src/jdk.compiler/share/man/javac.1 --- a/src/jdk.compiler/share/man/javac.1 Thu Jul 11 15:58:54 2019 +0000 +++ b/src/jdk.compiler/share/man/javac.1 Fri Jul 12 02:50:43 2019 -0700 @@ -21,147 +21,140 @@ .\" .\" Automatically generated by Pandoc 2.3.1 .\" -.TH "JAVAC" "1" "2018" "JDK 13" "JDK Commands" +.TH "JAVAC" "1" "2019" "JDK 13" "JDK Commands" .hy .SH NAME .PP -javac \- read Java class and interface definitions and compile them into -bytecode and class files +javac \- read Java declarations and compile them into class files .SH SYNOPSIS .PP -\f[CB]javac\f[R] [\f[I]options\f[R]] [\f[I]sourcefiles\f[R]] +\f[CB]javac\f[R] [\f[I]options\f[R]] [\f[I]sourcefiles\-or\-classnames\f[R]] .TP .B \f[I]options\f[R] Command\-line options. -See \f[B]Overview of javac Options\f[R]. .RS .RE .TP -.B \f[I]sourcefiles\f[R] -One or more source files to be compiled (such as \f[CB]MyClass.java\f[R]) -or processed for annotations (such as \f[CB]MyPackage.MyClass\f[R]). +.B \f[I]sourcefiles\-or\-classnames\f[R] +Source files to be compiled (for example, \f[CB]Shape.java\f[R]) or the +names of previously compiled classes to be processed for annotations +(for example, \f[CB]geometry.MyShape\f[R]). .RS .RE .SH DESCRIPTION .PP -The \f[CB]javac\f[R] command reads class and interface definitions, -written in the Java programming language, and compiles them into -bytecode class files. -The \f[CB]javac\f[R] command can also process annotations in Java source -files and classes. +The \f[CB]javac\f[R] command reads \f[I]source files\f[R] that contain +module, package and type declarations written in the Java programming +language, and compiles them into \f[I]class files\f[R] that run on the +Java Virtual Machine. +.PP +The \f[CB]javac\f[R] command can also \f[B]process annotations\f[R] in Java +source files and classes. .PP -A new launcher environment variable, \f[CB]JDK_JAVAC_OPTIONS\f[R], was -introduced in JDK 9 that prepended its content to the command line to -\f[CB]javac\f[R] . -See \f[B]Using JDK_JAVAC_OPTIONS Environment Variable\f[R]. +Source files must have a file name extension of \f[CB]\&.java\f[R]. +Class files have a file name extension of \f[CB]\&.class\f[R]. +Both source and class files normally have file names that identify the +contents. +For example, a class called \f[CB]Shape\f[R] would be declared in a source +file called \f[CB]Shape.java\f[R], and compiled into a class file called +\f[CB]Shape.class\f[R]. .PP -There are two ways to pass source code file names to \f[CB]javac\f[R]. +There are two ways to specify source files to \f[CB]javac\f[R]: .IP \[bu] 2 -For a small number of source files, you can list the file names on the +For a small number of source files, you can list their file names on the command line. .IP \[bu] 2 For a large number of source files, you can use the -\f[CB]\@\f[R]\f[I]filename\f[R] option on the \f[CB]javac\f[R] command line -to include a file that lists the source file names. +\f[CB]\@\f[R]\f[I]filename\f[R] option on the command line to specify an +\f[I]argument file\f[R] that lists their file names. See \f[B]Standard Options\f[R] for a description of the option and -\f[B]javac Command\-Line Argument Files\f[R] for a description of +\f[B]Command\-Line Argument Files\f[R] for a description of \f[CB]javac\f[R] argument files. .PP -Source code file names must have \f[CB]\&.java\f[R] suffixes, class file -names must have \f[CB]\&.class\f[R] suffixes, and both source and class -files must have root names that identify the class. -For example, a class called \f[CB]MyClass\f[R] would be written in a -source file called \f[CB]MyClass.java\f[R] and compiled into a bytecode -class file called \f[CB]MyClass.class\f[R]. +The order of source files specified on the command line or in an +argument file is not important. +\f[CB]javac\f[R] will compile the files together, as a group, and will +automatically resolve any dependencies between the declarations in the +various source files. .PP -Inner class definitions produce additional class files. -These class files have names that combine the inner and outer class -names, such as \f[CB]MyClass$MyInnerClass.class\f[R]. +\f[CB]javac\f[R] expects that source files are arranged in one or more +directory hierarchies on the file system, described in \f[B]Arrangement +of Source Code\f[R]. .PP -You should arrange the source files in a directory tree that reflects -their package tree. -For example: -.IP \[bu] 2 -\f[B]Oracle Solaris, Linux, and OS X:\f[R] If all of your source files -are in \f[CB]/workspace\f[R], then put the source code for -\f[CB]com.mysoft.mypack.MyClass\f[R] in -\f[CB]/workspace/com/mysoft/mypack/MyClass.java\f[R]. -.IP \[bu] 2 -\f[B]Windows:\f[R] If all of your source files are in -\f[CB]\\workspace\f[R], then put the source code for -\f[CB]com.mysoft.mypack.MyClass\f[R] in -\f[CB]\\workspace\\com\\mysoft\\mypack\\MyClass.java\f[R]. +To compile a source file, \f[CB]javac\f[R] needs to find the declaration +of every class or interface that is used, extended, or implemented by +the code in the source file. +This lets \f[CB]javac\f[R] check that the code has the right to access +those classes and interfaces. +Rather than specifying the source files of those classes and interfaces +explicitly, you can use command\-line options to tell \f[CB]javac\f[R] +where to search for their source files. +If you have compiled those source files previously, you can use options +to tell \f[CB]javac\f[R] where to search for the corresponding class +files. +The options, which all have names ending in "path", are described in +\f[B]Standard Options\f[R], and further described in \f[B]Configuring a +Compilation\f[R] and \f[B]Searching for Module, Package and Type +Declarations\f[R]. .PP -By default, the compiler puts each class file in the same directory as -its source file. -You can specify a separate destination directory with the \f[CB]\-d\f[R] -option described in \f[B]Standard Options\f[R]. -.SH PROGRAMMATIC INTERFACE -.PP -The \f[CB]javac\f[R] command supports the new Java Compiler API defined by -the classes and interfaces in the \f[CB]javax.tools\f[R] package. -.SH IMPLICITLY LOADED SOURCE FILES -.PP -To compile a set of source files, the compiler might need to implicitly -load additional source files. -See \f[B]Searching for Types\f[R]. -Such files are currently not subject to annotation processing. -By default, the compiler gives a warning when annotation processing -occurs and any implicitly loaded source files are compiled. -The \f[CB]\-implicit\f[R] option provides a way to suppress the warning. -.SH USING JDK_JAVAC_OPTIONS ENVIRONMENT VARIABLE +By default, \f[CB]javac\f[R] compiles each source file to a class file in +the same directory as the source file. +However, it is recommended to specify a separate destination directory +with the \f[CB]\-d\f[R] option described in \f[B]Standard Options\f[R]. .PP -The content of the \f[CB]JDK_JAVAC_OPTIONS\f[R] environment variable, -separated by white\-spaces ( ) or white\-space characters (\f[CB]\\n\f[R], -\f[CB]\\t\f[R], \f[CB]\\r\f[R], or \f[CB]\\f\f[R]) is prepended to the command -line arguments passed to \f[CB]javac\f[R] as a list of arguments. -.PP -The encoding requirement for the environment variable is the same as the -\f[CB]javac\f[R] command line on the system. -\f[CB]JDK_JAVAC_OPTIONS\f[R] environment variable content is treated in -the same manner as that specified in the command line. +Command\-line \f[B]options\f[R] and \f[B]environment variables\f[R] also +control how \f[CB]javac\f[R] performs various tasks: +.IP \[bu] 2 +Compiling code to run on earlier releases of the JDK. +.IP \[bu] 2 +Compiling code to run under a debugger. +.IP \[bu] 2 +Checking for stylistic issues in Java source code. +.IP \[bu] 2 +Checking for problems in \f[CB]javadoc\f[R] comments +(\f[CB]/**\ ...\ */\f[R]). +.IP \[bu] 2 +Processing annotations in source files and class files. +.IP \[bu] 2 +Upgrading and patching modules in the compile\-time environment. .PP -Single quotes (\f[CB]\[aq]\f[R]) or double quotes (\f[CB]"\f[R]) can be used -to enclose arguments that\ contain whitespace characters. -All content between the open quote and the first matching close quote -are preserved by simply removing the pair of quotes. -In case a matching quote is not found, the launcher will abort with an -error message. -\f[CB]\@\f[R]\f[I]files\f[R] are supported as they are specified in the -command line. -However, as in \f[CB]\@\f[R]\f[I]files\f[R], use of a wildcard is not -supported. +\f[CB]javac\f[R] supports \f[B]Compiling for Earlier Releases Of The +Platform\f[R] and can also be invoked from Java code using one of a +number of \f[B]APIs\f[R] +.SH OPTIONS .PP -\f[B]Examples of quoting arguments containing white spaces:\f[R] -.RS +\f[CB]javac\f[R] provides \f[B]standard options\f[R], and \f[B]extra +options\f[R] that are either non\-standard or are for advanced use. .PP -\f[CB]export\ JDK_JAVAC_OPTIONS=\[aq]\@"C:\\white\ spaces\\argfile"\[aq]\f[R] -.RE -.RS -.PP -\f[CB]export\ JDK_JAVAC_OPTIONS=\[aq]"\@C:\\white\ spaces\\argfile"\[aq]\f[R] -.RE -.RS -.PP -\f[CB]export\ JDK_JAVAC_OPTIONS=\[aq]\@C:\\"white\ spaces"\\argfile\[aq]\f[R] -.RE -.SH OVERVIEW OF JAVAC OPTIONS +Some options take one or more arguments. +If an argument contains spaces or other whitespace characters, the value +should be quoted according to the conventions of the environment being +used to invoke javac. +If the option begins with a single dash (\f[CB]\-\f[R]) the argument +should either directly follow the option name, or should be separated +with a colon (\f[CB]:\f[R]) or whitespace, depending on the option. +If the option begins with a double dash (\f[CB]\-\-\f[R]), the argument +may be separated either by whitespace or by an equals (\f[CB]=\f[R]) +character with no additional whitespace. +For example, +.IP +.nf +\f[CB] +\-Aname="J.\ Duke" +\-proc:only +\-d\ myDirectory +\-\-module\-version\ 3 +\-\-module\-version=3 +\f[R] +.fi .PP -The compiler has sets of standard options, and cross\-compilation -options that are supported on the current development environment. -The compiler also has a set of nonstandard options that are specific to -the current virtual machine and compiler implementations but are subject -to change in the future. -The nonstandard options begin with \f[CB]\-X\f[R] . -The different sets of \f[CB]javac\f[R] options are described in the -following sections: -.IP \[bu] 2 -\f[B]Standard Options\f[R] -.IP \[bu] 2 -\f[B]Cross\-Compilation Options for javac\f[R] -.IP \[bu] 2 -\f[B]Extra Options\f[R] -.SH STANDARD OPTIONS +In the following lists of options, an argument of \f[I]path\f[R] +represents a search path, composed of a list of file system locations +separated by the platform path separator character, (semicolon +\f[CB];\f[R] on Windows, or colon \f[CB]:\f[R] on other systems.) Depending +on the option, the file system locations may be directories, JAR files +or JMOD files. +.SS Standard Options .TP .B \f[CB]\@\f[R]\f[I]filename\f[R] Reads options and file names from a file. @@ -170,13 +163,13 @@ (except \f[CB]\-J\f[R] options). This lets you to create \f[CB]javac\f[R] commands of any length on any operating system. -See \f[B]javac Command\-Line Argument Files\f[R]. +See \f[B]Command\-Line Argument Files\f[R]. .RS .RE .TP .B \f[CB]\-A\f[R]\f[I]key\f[R][\f[CB]=\f[R]\f[I]value\f[R]] Specifies options to pass to annotation processors. -These options aren\[aq]t interpreted by \f[CB]javac\f[R] directly, but are +These options are not interpreted by \f[CB]javac\f[R] directly, but are made available for use by individual processors. The \f[I]key\f[R] value should be one or more identifiers separated by a dot (\f[CB]\&.\f[R]). @@ -194,11 +187,11 @@ Overrides the location of the bootstrap class files. .RS .PP -\f[B]Note:\f[R] -.PP -This can only be used when compiling for versions prior to JDK 9. -As applicable, see the descriptions in\ \f[CB]\-\-release\f[R], -\f[CB]\-source\f[R], or \f[CB]\-target\f[R]\ for details. +\f[B]Note:\f[R] This can only be used when compiling for releases prior +to JDK 9. +As applicable, see the descriptions in \f[CB]\-\-release\f[R], +\f[CB]\-source\f[R], or \f[CB]\-target\f[R] for details. +For JDK 9 or later, see \f[CB]\-\-system\f[R]. .RE .TP .B \f[CB]\-\-class\-path\f[R] \f[I]path\f[R], \f[CB]\-classpath\f[R] \f[I]path\f[R], or \f[CB]\-cp\f[R] \f[I]path\f[R] @@ -207,41 +200,48 @@ environment variable. .RS .IP \[bu] 2 -If \f[CB]\-\-class\-path\f[R], \f[CB]\-classpath\f[R], or \f[CB]\-cp\f[R] -aren\[aq]t specified, then the user class path is the current directory. +If \f[CB]\-\-class\-path\f[R], \f[CB]\-classpath\f[R], or \f[CB]\-cp\f[R] are +not specified, then the user class path is the value of the +\f[CB]CLASSPATH\f[R] environment variable, if that is set, or else the +current directory. .IP \[bu] 2 -If the \f[CB]\-sourcepath\f[R] option isn\[aq]t specified, then the user -class path is also searched for source files. +If not compiling code for modules, if the \f[CB]\-\-source\-path\f[R] or +\-sourcepath` option is not specified, then the user class path is also +searched for source files. .IP \[bu] 2 -If the \f[CB]\-processorpath\f[R] option isn\[aq]t specified, then the -class path is also searched for annotation processors. +If the \f[CB]\-processorpath\f[R] option is not specified, then the class +path is also searched for annotation processors. .RE .TP .B \f[CB]\-d\f[R] \f[I]directory\f[R] -Sets the destination directory for class files. +Sets the destination directory (or \f[I]class output directory\f[R]) for +class files. If a class is part of a package, then \f[CB]javac\f[R] puts the class file -in a subdirectory that reflects the package name and creates directories -as needed. -For example: +in a subdirectory that reflects the module name (if appropriate) and +package name. +The directory, and any necessary subdirectories, will be created if they +do not already exist. .RS -.IP \[bu] 2 -\f[B]Oracle Solaris, Linux, and OS X:\f[R] If you specify -\f[CB]\-d\ /home/myclasses\f[R] and the class is called -\f[CB]com.mypackage.MyClass\f[R], then the class file is -\f[CB]/home/myclasses/com/mypackage/MyClass.class\f[R]. -.IP \[bu] 2 -\f[B]Windows:\f[R] If you specify \f[CB]\-d\ C:\\myclasses\f[R] and the -class is called \f[CB]com.mypackage.MyClass\f[R], then the class file is -\f[CB]C:\\myclasses\\com\\mypackage\\MyClass.class\f[R]. .PP -If the \f[CB]\-d\f[R] option isn\[aq]t specified, then \f[CB]javac\f[R] puts +If the \f[CB]\-d\f[R] option is not specified, then \f[CB]javac\f[R] puts each class file in the same directory as the source file from which it was generated. .PP -\f[B]Note:\f[R] +Except when compiling code for multiple modules, the contents of the +class output directory will be organized in a package hierarchy. +When compiling code for multiple modules, the contents of the output +directory will be organized in a module hierarchy, with the contents of +each module in a separate subdirectory, each organized as a package +hierarchy. .PP -The directory specified by the \f[CB]\-d\f[R] option isn\[aq]t -automatically added to your user class path. +\f[B]Note:\f[R] When compiling code for one or more modules, the class +output directory will automatically be checked when searching for +previously compiled classes. +When not compiling for modules, for backwards compatibility, the +directory is \f[I]not\f[R] automatically checked for previously compiled +classes, and so it is recommended to specify the class output directory +as one of the locations on the user class path, using the +\f[CB]\-\-class\-path\f[R] option or one of its alternate forms. .RE .TP .B \f[CB]\-deprecation\f[R] @@ -265,7 +265,7 @@ .B \f[CB]\-encoding\f[R] \f[I]encoding\f[R] Specifies character encoding used by source files, such as EUC\-JP and UTF\-8. -If the \f[CB]\-encoding\f[R] option isn\[aq]t specified, then the platform +If the \f[CB]\-encoding\f[R] option is not specified, then the platform default converter is used. .RS .RE @@ -274,30 +274,29 @@ Overrides the location of the endorsed standards path. .RS .PP -\f[B]Note:\f[R] -.PP -This can only be used when compiling for versions prior to JDK 9. -As applicable, see the descriptions in\ \f[CB]\-\-release\f[R], -\f[CB]\-source\f[R], or \f[CB]\-target\f[R]\ for details. +\f[B]Note:\f[R] This can only be used when compiling for releases prior +to JDK 9. +As applicable, see the descriptions in \f[CB]\-\-release\f[R], +\f[CB]\-source\f[R], or \f[CB]\-target\f[R] for details. .RE .TP .B \f[CB]\-extdirs\f[R] \f[I]directories\f[R] Overrides the location of the installed extensions. -The \f[CB]directories\f[R] variable is a colon\-separated list of -directories. +\f[CB]directories\f[R] is a list of directories, separated by the platform +path separator (\f[CB];\f[R] on Windows, and \f[CB]:\f[R] otherwise). Each JAR file in the specified directories is searched for class files. All JAR files found become part of the class path. .RS .PP -If you are cross\-compiling, then this option specifies the directories -that contain the extension classes. -See \f[B]Cross\-Compilation Options for javac\f[R]. +If you are compiling for a release of the platform that supports the +Extension Mechanism, then this option specifies the directories that +contain the extension classes. +See [Compiling for Other Releases of the Platform]. .PP -\f[B]Note:\f[R] -.PP -This can only be used when compiling for versions prior to JDK 9. -As applicable, see the descriptions in\ \f[CB]\-\-release\f[R], -\f[CB]\-source\f[R], or \f[CB]\-target\f[R]\ for details. +\f[B]Note:\f[R] This can only be used when compiling for releases prior +to JDK 9. +As applicable, see the descriptions in \f[CB]\-\-release\f[R], +\f[CB]\-source\f[R], or \f[CB]\-target\f[R] for details. .RE .TP .B \f[CB]\-g\f[R] @@ -329,22 +328,23 @@ .RE .TP .B \f[CB]\-g:none\f[R] -Doesn\[aq]t generate debugging information. +Does not generate debugging information. .RS .RE .TP .B \f[CB]\-h\f[R] \f[I]directory\f[R] -Specfies where to place generated native header files. +Specifies where to place generated native header files. .RS .PP When you specify this option, a native header file is generated for each class that contains native methods or that has one or more constants annotated with the \f[B]\f[BC]java.lang.annotation.Native\f[B]\f[R] -[https://docs.oracle.com/javase/10/docs/api/java/lang/annotation/Native.html] annotation. If the class is part of a package, then the compiler puts the native -header file in a subdirectory that reflects the package name and creates -directories as needed. +header file in a subdirectory that reflects the module name (if +appropriate) and package name. +The directory, and any necessary subdirectories, will be created if they +do not already exist. .RE .TP .B \f[CB]\-\-help\f[R], \f[CB]\-help\f[R] or \f[CB]\-?\f[R] @@ -353,7 +353,7 @@ .RE .TP .B \f[CB]\-\-help\-extra\f[R] or \f[CB]\-X\f[R] -Prints the help for extra options. +Prints a synopsis of the set of extra options. .RS .RE .TP @@ -366,13 +366,13 @@ .IP \[bu] 2 \f[CB]\-implicit:none\f[R] \-\-\- Suppresses class file generation. .PP -If this option isn\[aq]t specified, then the default automatically +If this option is not specified, then the default automatically generates class files. In this case, the compiler issues a warning if any class files are generated when also doing annotation processing. -The warning isn\[aq]t issued when the \f[CB]\-implicit\f[R] option is +The warning is not issued when the \f[CB]\-implicit\f[R] option is explicitly set. -See \f[B]Searching for Types\f[R]. +See \f[B]Searching for Module, Package and Type Declarations\f[R]. .RE .TP .B \f[CB]\-J\f[R]\f[I]option\f[R] @@ -381,14 +381,13 @@ For example, \f[CB]\-J\-Xms48m\f[R] sets the startup memory to 48 MB. .RS .PP -\f[B]Note:\f[R] -.PP -The \f[CB]CLASSPATH\f[R] environment variable, \f[CB]\-classpath\f[R] -option, \f[CB]\-bootclasspath\f[R] option, and \f[CB]\-extdirs\f[R] option -don\[aq]t specify the classes used to run \f[CB]javac\f[R]. +\f[B]Note:\f[R] The \f[CB]CLASSPATH\f[R] environment variable, +\f[CB]\-classpath\f[R] option, \f[CB]\-bootclasspath\f[R] option, and +\f[CB]\-extdirs\f[R] option do not specify the classes used to run +\f[CB]javac\f[R]. Trying to customize the compiler implementation with these options and -variables is risky and often doesn\[aq]t accomplish what you want. -If you must customize the complier implementation, then use the +variables is risky and often does not accomplish what you want. +If you must customize the compiler implementation, then use the \f[CB]\-J\f[R] option to pass options through to the underlying Java launcher. .RE @@ -398,8 +397,9 @@ .RS .RE .TP -.B \f[CB]\-\-module\f[R] \f[I]module\-name\f[R] or \f[CB]\-m\f[R] \f[I]module\-name\f[R] -Compiles only the specified module and checks time stamps. +.B \f[CB]\-\-module\f[R] \f[I]module\-name\f[R] (\f[CB],\f[R]\f[I]module\-name\f[R])* or \f[CB]\-m\f[R] \f[I]module\-name\f[R] (\f[CB],\f[R]\f[I]module\-name\f[R])* +Compiles those source files in the named modules that are newer than the +corresponding files in the output directory. .RS .RE .TP @@ -409,7 +409,9 @@ .RE .TP .B \f[CB]\-\-module\-source\-path\f[R] \f[I]module\-source\-path\f[R] -Specifies where to find input source files for multiple modules. +Specifies where to find source files when compiling code in multiple +modules. +See [Compilation Modes] and \f[B]The Module Source Path Option\f[R]. .RS .RE .TP @@ -455,7 +457,7 @@ .TP .B \f[CB]\-\-processor\-path\f[R] \f[I]path\f[R] or \f[CB]\-processorpath\f[R] \f[I]path\f[R] Specifies where to find annotation processors. -If this option isn\[aq]t used, then the class path is searched for +If this option is not used, then the class path is searched for processors. .RS .RE @@ -464,63 +466,67 @@ Checks that the API used is available in the specified profile. .RS .PP -\f[B]Note:\f[R] -.PP -This can only be used when compiling for versions prior to JDK 9. -As applicable, see the descriptions in\ \f[CB]\-\-release\f[R], -\f[CB]\-source\f[R], or \f[CB]\-target\f[R]\ for details. +\f[B]Note:\f[R] This can only be used when compiling for releases prior +to JDK 9. +As applicable, see the descriptions in \f[CB]\-\-release\f[R], +\f[CB]\-source\f[R], or \f[CB]\-target\f[R] for details. .RE .TP .B \f[CB]\-\-release\f[R] \f[I]release\f[R] Compiles source code according to the rules of the Java programming -language for the specified Java SE release, generating class files -suitable for that release. -Additionally, compiles source code against the API of the specified Java -SE release and the API supported by the corresponding JDK release. -The supported values of \f[I]release\f[R] are the current Java SE release -and a limited number of previous releases. -The exact set of supported values is given in the command\-line help. +language for the specified Java SE release, generating class files which +target that release. +Source code is compiled against the combined Java SE and JDK API for the +specified release. .RS .PP -The API of a Java SE release consists of the \f[CB]java.*\f[R], -\f[CB]javax.*\f[R], and \f[CB]org.*\f[R] packages that are exported by Java -SE modules in the release. +The supported values of \f[I]release\f[R] are the current Java SE release +and a limited number of previous releases, detailed in the command\-line +help. +.PP +For the current release, the Java SE API consists of the +\f[CB]java.*\f[R], \f[CB]javax.*\f[R], and \f[CB]org.*\f[R] packages that are +exported by the Java SE modules in the release; the JDK API consists of +the \f[CB]com.*\f[R] and \f[CB]jdk.*\f[R] packages that are exported by the +JDK modules in the release, plus the \f[CB]javax.*\f[R] packages that are +exported by standard, but non\-Java SE, modules in the release. .PP -The API supported by a JDK release consists of the \f[CB]com.*\f[R] and -\f[CB]jdk.*\f[R] packages that are exported by JDK modules in the release, -plus the \f[CB]javax.*\f[R] packages that are exported by standard, but -non\-Java SE, modules in the release. +For previous releases, the Java SE API and the JDK API are as defined in +that release. .PP -\f[B]Note:\f[R] +\f[B]Note:\f[R] When using \f[CB]\-\-release\f[R], you cannot also use the +\f[CB]\-\-source\f[R]/\f[CB]\-source\f[R] or +\f[CB]\-\-target\f[R]/\f[CB]\-target\f[R] options. .PP -The \f[CB]\-\-add\-exports\f[R] option cannot be used to enlarge the set -of packages exported by the Java SE and JDK API. +\f[B]Note:\f[R] When using \f[CB]\-\-release\f[R] to specify a release that +supports the Java Platform Module System, the \f[CB]\-\-add\-exports\f[R] +option cannot be used to enlarge the set of packages exported by the +Java SE, JDK, and standard modules in the specified release. .RE .TP .B \f[CB]\-s\f[R] \f[I]directory\f[R] Specifies the directory used to place the generated source files. If a class is part of a package, then the compiler puts the source file -in a subdirectory that reflects the package name and creates directories -as needed. -For example: +in a subdirectory that reflects the module name (if appropriate) and +package name. +The directory, and any necessary subdirectories, will be created if they +do not already exist. .RS -.IP \[bu] 2 -\f[B]Oracle Solaris, Linux, and OS X:\f[R] If you specify -\f[CB]\-s\ /home/mysrc\f[R] and the class is called -\f[CB]com.mypackage.MyClass\f[R], then the source file is put in -\f[CB]/home/mysrc/com/mypackage/MyClass.java\f[R]. -.IP \[bu] 2 -\f[B]Windows:\f[R] If you specify \f[CB]\-s\ C:\\mysrc\f[R] and the class -is called \f[CB]com.mypackage.MyClass\f[R], then the source file is put in -\f[CB]C:\\mysrc\\com\\mypackage\\MyClass.java\f[R]. +.PP +Except when compiling code for multiple modules, the contents of the +source output directory will be organized in a package hierarchy. +When compiling code for multiple modules, the contents of the source +output directory will be organized in a module hierarchy, with the +contents of each module in a separate subdirectory, each organized as a +package hierarchy. .RE .TP .B \f[CB]\-\-source\f[R] \f[I]release\f[R] or \f[CB]\-source\f[R] \f[I]release\f[R] Compiles source code according to the rules of the Java programming language for the specified Java SE release. The supported values of \f[I]release\f[R] are the current Java SE release -and a limited number of previous releases. -The exact set of supported values is given in the command\-line help. +and a limited number of previous releases, detailed in the command\-line +help. .RS .PP If the option is not specified, the default is to compile source code @@ -529,21 +535,14 @@ .RE .TP .B \f[CB]\-\-source\-path\f[R] \f[I]path\f[R] or \f[CB]\-sourcepath\f[R] \f[I]path\f[R] -Specifies where to find input source files. -This is the source code path used to search for class or interface -definitions. -As with the user class path, source path entries are separated by colons -(\f[CB]:\f[R]) on Oracle Solaris and semicolons (\f[CB];\f[R]) on Windows. -They can be directories, JAR archives, or ZIP archives. -If packages are used, then the local path name within the directory or -archive must reflect the package name. +Specifies where to find source files. +Except when compiling multiple modules together, this is the source code +path used to search for class or interface definitions. .RS .PP -\f[B]Note:\f[R] -.PP -Classes found through the class path might be recompiled when their -source files are also found. -See \f[B]Searching for Types\f[R]. +\f[B]Note:\f[R] Classes found through the class path might be recompiled +when their source files are also found. +See \f[B]Searching for Module, Package and Type Declarations\f[R]. .RE .TP .B \f[CB]\-\-system\f[R] \f[I]jdk\f[R] | \f[CB]none\f[R] @@ -555,15 +554,13 @@ Generates \f[CB]class\f[R] files suitable for the specified Java SE release. The supported values of \f[I]release\f[R] are the current Java SE release -and a limited number of previous releases. -The exact set of supported values is given in the command\-line help. +and a limited number of previous releases, detailed in the command\-line +help. .RS .PP -\f[B]Note:\f[R] -.PP -It is an error to specify a value for \f[I]release\f[R] that is lower -than the the release for which the source code is being compiled. -(See \f[CB]\-\-source\f[R]). +\f[B]Note:\f[R] The target release must be equal to or higher than the +source release. +(See \f[CB]\-\-source\f[R].) .RE .TP .B \f[CB]\-\-upgrade\-module\-path\f[R] \f[I]path\f[R] @@ -587,23 +584,7 @@ Terminates compilation when warnings occur. .RS .RE -.SH CROSS\-COMPILATION OPTIONS FOR JAVAC -.PP -By default, for releases prior to JDK 9, classes were compiled against -the bootstrap classes of the platform that shipped with -the\f[CB]javac\f[R] command. -But \f[CB]javac\f[R] also supports cross\-compiling, in which classes are -compiled against bootstrap classes of a different Java platform -implementation. -It\[aq]s important to use the \f[CB]\-bootclasspath\f[R] and -\f[CB]\-extdirs\f[R] options when cross\-compiling. -.PP -\f[B]Note:\f[R] -.PP -This can only be used when compiling for versions prior to JDK 9. -As applicable, see the descriptions in\ \f[CB]\-\-release\f[R], -\f[CB]\-source\f[R], or \f[CB]\-target\f[R]\ for details. -.SH EXTRA OPTIONS +.SS Extra Options .TP .B \f[CB]\-\-add\-exports\f[R] \f[I]module\f[R]\f[CB]/\f[R]\f[I]package\f[R]\f[CB]=\f[R]\f[I]other\-module\f[R](\f[CB],\f[R]\f[I]other\-module\f[R])* Specifies a package to be considered as exported from its defining @@ -628,22 +609,20 @@ Overrides the location of the endorsed standards path. .RS .PP -\f[B]Note:\f[R] -.PP -This can only be used when compiling for versions prior to JDK 9. -As applicable, see the descriptions in\ \f[CB]\-\-release\f[R], -\f[CB]\-source\f[R], or \f[CB]\-target\f[R]\ for details. +\f[B]Note:\f[R] This can only be used when compiling for releases prior +to JDK 9. +As applicable, see the descriptions in \f[CB]\-\-release\f[R], +\f[CB]\-source\f[R], or \f[CB]\-target\f[R] for details. .RE .TP .B \f[CB]\-Djava.ext.dirs=\f[R]\f[I]dirs\f[R] Overrides the location of installed extensions. .RS .PP -\f[B]Note:\f[R] -.PP -This can only be used when compiling for versions prior to JDK 9. -As applicable, see the descriptions in\ \f[CB]\-\-release\f[R], -\f[CB]\-source\f[R], or \f[CB]\-target\f[R]\ for details. +\f[B]Note:\f[R] This can only be used when compiling for releases prior +to JDK 9. +As applicable, see the descriptions in \f[CB]\-\-release\f[R], +\f[CB]\-source\f[R], or \f[CB]\-target\f[R] for details. .RE .TP .B \f[CB]\-\-doclint\-format\f[R] [\f[CB]html4\f[R]|\f[CB]html5\f[R]] @@ -651,7 +630,7 @@ .RS .RE .TP -.B \f[CB]\-\-patch\-module\f[R] \f[I]module\f[R]\f[CB]=\f[R]\f[I]file\f[R](\f[CB]:\f[R]\f[I]file\f[R])* +.B \f[CB]\-\-patch\-module\f[R] \f[I]module\f[R]\f[CB]=\f[R]\f[I]path\f[R] Overrides or augments a module with classes and resources in JAR files or directories. .RS @@ -661,33 +640,30 @@ Overrides the location of the bootstrap class files. .RS .PP -\f[B]Note:\f[R] -.PP -This can only be used when compiling for versions prior to JDK 9. -As applicable, see the descriptions in\ \f[CB]\-\-release\f[R], -\f[CB]\-source\f[R], or \f[CB]\-target\f[R]\ for details. +\f[B]Note:\f[R] This can only be used when compiling for releases prior +to JDK 9. +As applicable, see the descriptions in \f[CB]\-\-release\f[R], +\f[CB]\-source\f[R], or \f[CB]\-target\f[R] for details. .RE .TP .B \f[CB]\-Xbootclasspath/a:\f[R]\f[I]path\f[R] Adds a suffix to the bootstrap class path. .RS .PP -\f[B]Note:\f[R] -.PP -This can only be used when compiling for versions prior to JDK 9. -As applicable, see the descriptions in\ \f[CB]\-\-release\f[R], -\f[CB]\-source\f[R], or \f[CB]\-target\f[R]\ for details. +\f[B]Note:\f[R] This can only be used when compiling for releases prior +to JDK 9. +As applicable, see the descriptions in \f[CB]\-\-release\f[R], +\f[CB]\-source\f[R], or \f[CB]\-target\f[R] for details. .RE .TP .B \f[CB]\-Xbootclasspath/p:\f[R]\f[I]path\f[R] Adds a prefix to the bootstrap class path. .RS .PP -\f[B]Note:\f[R] -.PP -This can only be used when compiling for versions prior to JDK 9. -As applicable, see the descriptions in\ \f[CB]\-\-release\f[R], -\f[CB]\-source\f[R], or \f[CB]\-target\f[R]\ for details. +\f[B]Note:\f[R] This can only be used when compiling for releases prior +to JDK 9. +As applicable, see the descriptions in \f[CB]\-\-release\f[R], +\f[CB]\-source\f[R], or \f[CB]\-target\f[R] for details. .RE .TP .B \f[CB]\-Xdiags:\f[R][\f[CB]compact\f[R], \f[CB]verbose\f[R]] @@ -745,7 +721,7 @@ .RE .PP The following option enables all groups of checks for all access levels, -except it won\[aq]t check for HTML errors for classes and members that +except it will not check for HTML errors for classes and members that have the access level of package and higher (which includes package, protected and public): .RS @@ -802,7 +778,7 @@ \f[CB]fallthrough\f[R]: Warns about the falling through from one case of a switch statement to the next. .IP \[bu] 2 -\f[CB]finally\f[R]: Warns about \f[CB]finally\f[R] clauses that don\[aq]t +\f[CB]finally\f[R]: Warns about \f[CB]finally\f[R] clauses that do not terminate normally. .IP \[bu] 2 \f[CB]module\f[R]: Warns about the module system\-related issues. @@ -833,7 +809,7 @@ \f[CB]requires\-transitive\-automatic\f[R]: Warns about automatic modules in requires transitive. .IP \[bu] 2 -\f[CB]serial\f[R]: Warns about the serializable classes that don\[aq]t +\f[CB]serial\f[R]: Warns about the serializable classes that do not provide a serial version ID. Also warns about access to non\-public members from a serializable element. @@ -882,15 +858,13 @@ .B \f[CB]legacy\f[R] Generates a \f[CB]package\-info.class\f[R] file only if \f[CB]package\-info.java\f[R] contains annotations. -This option doesn\[aq]t generate a \f[CB]package\-info.class\f[R] file if +This option does not generate a \f[CB]package\-info.class\f[R] file if \f[CB]package\-info.java\f[R] contains only comments. .RS .PP -\f[B]Note:\f[R] -.PP -A \f[CB]package\-info.class\f[R] file might be generated but be empty if -all the annotations in the \f[CB]package\-info.java\f[R] file have -\f[CB]RetentionPolicy.SOURCE\f[R]. +\f[B]Note:\f[R] A \f[CB]package\-info.class\f[R] file might be generated +but be empty if all the annotations in the \f[CB]package\-info.java\f[R] +file have \f[CB]RetentionPolicy.SOURCE\f[R]. .RE .TP .B \f[CB]nonempty\f[R] @@ -903,6 +877,11 @@ .TP .B \f[CB]\-Xplugin:\f[R]\f[I]name\f[R] \f[I]args\f[R] Specifies the name and optional arguments for a plug\-in to be run. +If \f[I]args\f[R] are provided, \f[I]name\f[R] and \f[I]args\f[R] should be +quoted or otherwise escape the whitespace characters between the name +and all the arguments. +For details on the API for a plugin, see the API documentation for +\f[B]jdk.compiler/com.sun.source.util.Plugin\f[R]. .RS .RE .TP @@ -910,7 +889,7 @@ Specifies which file to read when both a source file and class file are found for an implicitly compiled class using one of the following options. -See \f[B]Searching for Types\f[R]. +See \f[B]Searching for Module, Package and Type Declarations\f[R]. .RS .IP \[bu] 2 \f[CB]\-Xprefer:newer\f[R]: Reads the newer of the source or class files @@ -925,7 +904,7 @@ .B \f[CB]\-Xprint\f[R] Prints a textual representation of specified types for debugging purposes. -This doesn\[aq]t perform annotation processing or compilation. +This does not perform annotation processing or compilation. The format of the output could change. .RS .RE @@ -947,10 +926,56 @@ By default, compiler messages go to \f[CB]System.err\f[R]. .RS .RE -.SH JAVAC COMMAND\-LINE ARGUMENT FILES +.SH ENVIRONMENT VARIABLES +.SS CLASSPATH +.PP +If the \f[CB]\-\-class\-path\f[R] option or any of its alternate forms are +not specified, the class path will default to the value of the +\f[CB]CLASSPATH\f[R] environment variable if it is set. +However, it is recommended that this environment variable should +\f[I]not\f[R] be set, and that the \f[CB]\-\-class\-path\f[R] option should +be used to provide an explicit value for the class path when one is +required. +.SS JDK_JAVAC_OPTIONS +.PP +The content of the \f[CB]JDK_JAVAC_OPTIONS\f[R] environment variable, +separated by white\-spaces ( ) or white\-space characters (\f[CB]\\n\f[R], +\f[CB]\\t\f[R], \f[CB]\\r\f[R], or \f[CB]\\f\f[R]) is prepended to the command +line arguments passed to \f[CB]javac\f[R] as a list of arguments. +.PP +The encoding requirement for the environment variable is the same as the +\f[CB]javac\f[R] command line on the system. +\f[CB]JDK_JAVAC_OPTIONS\f[R] environment variable content is treated in +the same manner as that specified in the command line. .PP -An argument file can include \f[CB]javac\f[R] options and source file -names in any combination. +Single quotes (\f[CB]\[aq]\f[R]) or double quotes (\f[CB]"\f[R]) can be used +to enclose arguments that contain whitespace characters. +All content between the open quote and the first matching close quote +are preserved by simply removing the pair of quotes. +In case a matching quote is not found, the launcher will abort with an +error message. +\f[CB]\@\f[R]\f[I]files\f[R] are supported as they are specified in the +command line. +However, as in \f[CB]\@\f[R]\f[I]files\f[R], use of a wildcard is not +supported. +.PP +\f[B]Examples of quoting arguments containing white spaces:\f[R] +.RS +.PP +\f[CB]export\ JDK_JAVAC_OPTIONS=\[aq]\@"C:\\white\ spaces\\argfile"\[aq]\f[R] +.RE +.RS +.PP +\f[CB]export\ JDK_JAVAC_OPTIONS=\[aq]"\@C:\\white\ spaces\\argfile"\[aq]\f[R] +.RE +.RS +.PP +\f[CB]export\ JDK_JAVAC_OPTIONS=\[aq]\@C:\\"white\ spaces"\\argfile\[aq]\f[R] +.RE +.SH COMMAND\-LINE ARGUMENT FILES +.PP +An argument file can include command\-line options and source file names +in any combination. The arguments within a file can be separated by spaces or new line characters. If a file name contains embedded spaces, then put the whole file name in @@ -958,19 +983,19 @@ .PP File names within an argument file are relative to the current directory, not to the location of the argument file. -Wildcards (*) aren\[aq]t allowed in these lists (such as for specifying -\f[CB]*.java\f[R]). -Use of the at sign (\f[CB]\@\f[R]) to recursively interpret files -isn\[aq]t supported. -The \f[CB]\-J\f[R] options aren\[aq]t supported because they\[aq]re passed -to the launcher, which doesn\[aq]t support argument files. +Wildcards (\f[CB]*\f[R]) are not allowed in these lists (such as for +specifying \f[CB]*.java\f[R]). +Use of the at sign (\f[CB]\@\f[R]) to recursively interpret files is not +supported. +The \f[CB]\-J\f[R] options are not supported because they\[aq]re passed to +the launcher, which does not support argument files. .PP When executing the \f[CB]javac\f[R] command, pass in the path and name of each argument file with the at sign (\f[CB]\@\f[R]) leading character. When the \f[CB]javac\f[R] command encounters an argument beginning with the at sign (\f[CB]\@\f[R]), it expands the contents of that file into the argument list. -.SH EXAMPLES OF USING JAVAC \@FILENAME +.SS Examples of Using javac \@filename .TP .B Single Argument File You could use a single argument file named \f[CB]argfile\f[R] to hold all @@ -993,7 +1018,7 @@ .PP Create a file named \f[CB]options\f[R] that contains the following: .PP -\f[B]Oracle Solaris, Linux, and OS X:\f[R] +\f[B]Oracle Solaris, Linux, and macOS:\f[R] .IP .nf \f[CB] @@ -1040,6 +1065,845 @@ \f[CB]javac\ \@path1/options\ \@path2/classes\f[R] .RE .RE +.SH ARRANGEMENT OF SOURCE CODE +.PP +In the Java language, classes and interfaces can be organized into +packages, and packages can be organized into modules. +\f[CB]javac\f[R] expects that the physical arrangement of source files in +directories of the file system will mirror the organization of classes +into packages, and packages into modules. +.PP +It is a widely adopted convention that module names and package names +begin with a lower\-case letter, and that class names begin with an +upper\-case letter. +.SS Arrangement of Source Code for a Package +.PP +When classes and interfaces are organized into a package, the package is +represented as a directory, and any subpackages are represented as +subdirectories. +.PP +For example: +.IP \[bu] 2 +The package \f[CB]p\f[R] is represented as a directory called \f[CB]p\f[R]. +.IP \[bu] 2 +The package \f[CB]p.q\f[R] \-\- that is, the subpackage \f[CB]q\f[R] of +package \f[CB]p\f[R] \-\- is represented as the subdirectory \f[CB]q\f[R] of +directory \f[CB]p\f[R]. +The directory tree representing package \f[CB]p.q\f[R] is therefore +\f[CB]p\\q\f[R] on Windows, and \f[CB]p/q\f[R] on other systems. +.IP \[bu] 2 +The package \f[CB]p.q.r\f[R] is represented as the directory tree +\f[CB]p\\q\\r\f[R] (on Windows) or \f[CB]p/q/r\f[R] (on other systems). +.PP +Within a directory or subdirectory, \f[CB]\&.java\f[R] files represent +classes and interfaces in the corresponding package or subpackage. +.PP +For example: +.IP \[bu] 2 +The class \f[CB]X\f[R] declared in package \f[CB]p\f[R] is represented by +the file \f[CB]X.java\f[R] in the \f[CB]p\f[R] directory. +.IP \[bu] 2 +The class \f[CB]Y\f[R] declared in package \f[CB]p.q\f[R] is represented by +the file \f[CB]Y.java\f[R] in the \f[CB]q\f[R] subdirectory of directory +\f[CB]p\f[R]. +.IP \[bu] 2 +The class \f[CB]Z\f[R] declared in package \f[CB]p.q.r\f[R] is represented +by the file \f[CB]Z.java\f[R] in the \f[CB]r\f[R] subdirectory of +\f[CB]p\\q\f[R] (on Windows) or \f[CB]p/q\f[R] (on other systems). +.PP +In some situations, it is convenient to split the code into separate +directories, each structured as described above, and the aggregate list +of directories specified to \f[CB]javac\f[R]. +.SS Arrangement of Source Code for a Module +.PP +In the Java language, a module is a set of packages designed for reuse. +In addition to \f[CB]\&.java\f[R] files for classes and interfaces, each +module has a source file called \f[CB]module\-info.java\f[R] which: +.IP "1." 3 +declares the module\[aq]s name; +.IP "2." 3 +lists the packages exported by the module (to allow reuse by other +modules); +.IP "3." 3 +lists other modules required by the module (to reuse their exported +packages). +.PP +When packages are organized into a module, the module is represented by +one or more directories representing the packages in the module, one of +which contains the \f[CB]module\-info.java\f[R] file. +It may be convenient, but it is not required, to use a single directory, +named after the module, to contain the \f[CB]module\-info.java\f[R] file +alongside the directory tree which represents the packages in the module +(i.e., the \f[I]package hierarchy\f[R] described above). +The exact arrangement of source code for a module is typically dictated +by the conventions adopted by a development environment (IDE) or build +system. +.PP +For example: +.IP \[bu] 2 +The module \f[CB]a.b.c\f[R] may be represented by the directory +\f[CB]a.b.c\f[R], on all systems. +.IP \[bu] 2 +The module\[aq]s declaration is represented by the file +\f[CB]module\-info.java\f[R] in the \f[CB]a.b.c\f[R] directory. +.IP \[bu] 2 +If the module contains package \f[CB]p.q.r\f[R], then the \f[CB]a.b.c\f[R] +directory contains the directory tree \f[CB]p\\q\\r\f[R] (on Windows) or +\f[CB]p/q/r\f[R] (on other systems). +.PP +The development environment may prescribe some directory hierarchy +between the directory named for the module and the source files to be +read by \f[CB]javac\f[R]. +.PP +For example: +.IP \[bu] 2 +The module \f[CB]a.b.c\f[R] may be represented by the directory +\f[CB]a.b.c\f[R] +.IP \[bu] 2 +The module\[aq]s declaration and the module\[aq]s packages may be in +some subdirectory of \f[CB]a.b.c\f[R], such as \f[CB]src\\main\\java\f[R] +(on Windows) or \f[CB]src/main/java\f[R] (on other systems). +.SH CONFIGURING A COMPILATION +.PP +This section describes how to configure \f[CB]javac\f[R] to perform a +basic compilation. +.PP +See \f[B]Configuring the Module System\f[R] for additional details for +use when compiling for a release of the platform that supports modules. +.SS Source Files +.IP \[bu] 2 +Specify the source files to be compiled on the command line. +.PP +If there are no compilation errors, the corresponding class files will +be placed in the \f[B]output directory\f[R]. +.PP +Some systems may limit the amount you can put on a command line; to work +around those limits, you can use \f[B]argument files\f[R]. +.PP +When compiling code for modules, you can also specify source files +indirectly, by using the \f[CB]\-\-module\f[R] or \f[CB]\-m\f[R] option; see +\f[B]Standard Options\f[R]. +.SS Output Directory +.IP \[bu] 2 +Use the \f[CB]\-d\f[R] option to specify an output directory in which to +put the compiled class files. +.PP +This will normally be organized in a \f[B]package hierarchy\f[R], unless +you are compiling source code from multiple modules, in which case it +will be organized as a \f[B]module hierarchy\f[R]. +.PP +When the compilation has been completed, if you are compiling one or +more modules, you can place the output directory on the module path for +the Java \f[B]launcher\f[R]; otherwise, you can place the place the +output directory on the class path for the Java launcher. +.SS Precompiled Code +.PP +The code to be compiled may refer to libraries beyond what is provided +by the platform. +If so, you must place these libraries on the class path or module path. +If the library code is not in a module, place it on the class path; if +it is in a module, place it on the module path. +.IP \[bu] 2 +Use the \f[CB]\-\-class\-path\f[R] option to specify libraries to be +placed on the class path. +Locations on the class path should be organized in a \f[B]package +hierarchy\f[R]. +You can also use alternate forms of the option: \f[CB]\-classpath\f[R] or +\f[CB]\-cp\f[R]. +.IP \[bu] 2 +Use the \f[CB]\-\-module\-path\f[R] option to specify libraries to be +placed on the module path. +Locations on the module path should either be modules or directories of +modules. +You can also use an alternate form of the option: \f[CB]\-p\f[R]. +.RS 2 +.PP +See \f[B]Configuring the Module System\f[R] for details on how to modify +the default configuration of library modules. +.RE +.PP +\f[B]Note\f[R]: the options for the class path and module path are not +mutually exclusive, although it is not common to specify the class path +when compiling code for one or more modules. +.SS Additional Source Files +.PP +The code to be compiled may refer to types in additional source files +that are not specified on the command line. +If so, you must put those source files on either the source path or +module path. +You can only specify one of these options: if you are not compiling code +for a module, or if you are only compiling code for a single module, use +the source path; if you are compiling code for multiple modules, use the +module source path. +.IP \[bu] 2 +Use the \f[CB]\-\-source\-path\f[R] option to specify the locations of +additional source files that may be read by javac. +Locations on the source path should be organized in a \f[B]package +hierarchy\f[R]. +You can also use an alternate form of the option: \f[CB]\-sourcepath\f[R]. +.IP \[bu] 2 +Use the \f[CB]\-\-module\-source\-path\f[R] option one or more times to +specify the location of additional source files in different modules +that may be read by javac, or when compiling source files in multiple +modules. +You can either specify the locations for each module +\f[B]individually\f[R], or you can organize the source files so that you +can specify the locations all \f[B]together\f[R]. +For more details, see \f[B]The Module Source Path Option\f[R]. +.PP +If you want to be able to refer to types in additional source files but +do not want them to be compiled, use the \f[CB]\-implicit\f[R] option. +.PP +\f[B]Note\f[R]: if you are compiling code for multiple modules, you must +always specify a module source path, and all source files specified on +the command line must be in one of the directories on the module source +path, or in a subdirectory thereof. +.SS Example of Compiling Multiple Source Files +.PP +This example compiles the \f[CB]Aloha.java\f[R], \f[CB]GutenTag.java\f[R], +\f[CB]Hello.java\f[R], and \f[CB]Hi.java\f[R] source files in the +\f[CB]greetings\f[R] package. +.PP +\f[B]Oracle Solaris, Linux, and macOS:\f[R] +.IP +.nf +\f[CB] +%\ javac\ greetings/*.java +%\ ls\ greetings +Aloha.class\ \ \ \ \ \ \ \ \ GutenTag.class\ \ \ \ \ \ Hello.class\ \ \ \ \ \ \ \ \ Hi.class +Aloha.java\ \ \ \ \ \ \ \ \ \ GutenTag.java\ \ \ \ \ \ \ Hello.java\ \ \ \ \ \ \ \ \ \ Hi.java +\f[R] +.fi +.PP +\f[B]Windows:\f[R] +.IP +.nf +\f[CB] +C:\\>javac\ greetings\\*.java +C:\\>dir\ greetings +Aloha.class\ \ \ \ \ \ \ \ \ GutenTag.class\ \ \ \ \ \ Hello.class\ \ \ \ \ \ \ \ \ Hi.class +Aloha.java\ \ \ \ \ \ \ \ \ \ GutenTag.java\ \ \ \ \ \ \ Hello.java\ \ \ \ \ \ \ \ \ \ Hi.java +\f[R] +.fi +.SS Example of Specifying a User Class Path +.PP +After changing one of the source files in the previous example, +recompile it: +.PP +\f[B]Oracle Solaris, Linux, and macOS:\f[R] +.IP +.nf +\f[CB] +pwd +/examples +javac\ greetings/Hi.java +\f[R] +.fi +.PP +\f[B]Windows:\f[R] +.IP +.nf +\f[CB] +C:\\>cd +\\examples +C:\\>javac\ greetings\\Hi.java +\f[R] +.fi +.PP +Because \f[CB]greetings.Hi\f[R] refers to other classes in the +\f[CB]greetings\f[R] package, the compiler needs to find these other +classes. +The previous example works because the default user class path is the +directory that contains the package directory. +If you want to recompile this file without concern for which directory +you are in, then add the examples directory to the user class path by +setting \f[CB]CLASSPATH\f[R]. +This example uses the \f[CB]\-classpath\f[R] option. +.PP +\f[B]Oracle Solaris, Linux, and macOS:\f[R] +.RS +.PP +\f[CB]javac\ \-classpath\ /examples\ /examples/greetings/Hi.java\f[R] +.RE +.PP +\f[B]Windows:\f[R] +.RS +.PP +\f[CB]C:\\>javac\ \-classpath\ \\examples\ \\examples\\greetings\\Hi.java\f[R] +.RE +.PP +If you change \f[CB]greetings.Hi\f[R] to use a banner utility, then that +utility also needs to be accessible through the user class path. +.PP +\f[B]Oracle Solaris, Linux, and macOS:\f[R] +.IP +.nf +\f[CB] +javac\ \-classpath\ /examples:/lib/Banners.jar\ \\ +\ \ \ \ \ \ \ \ \ \ \ \ /examples/greetings/Hi.java +\f[R] +.fi +.PP +\f[B]Windows:\f[R] +.IP +.nf +\f[CB] +C:\\>javac\ \-classpath\ \\examples;\\lib\\Banners.jar\ ^ +\ \ \ \ \ \ \ \ \ \ \ \ \\examples\\greetings\\Hi.java +\f[R] +.fi +.PP +To execute a class in the \f[CB]greetings\f[R] package, the program needs +access to the \f[CB]greetings\f[R] package, and to the classes that the +\f[CB]greetings\f[R] classes use. +.PP +\f[B]Oracle Solaris, Linux, and macOS:\f[R] +.RS +.PP +\f[CB]java\ \-classpath\ /examples:/lib/Banners.jar\ greetings.Hi\f[R] +.RE +.PP +\f[B]Windows:\f[R] +.RS +.PP +\f[CB]C:\\>java\ \-classpath\ \\examples;\\lib\\Banners.jar\ greetings.Hi\f[R] +.RE +.SH CONFIGURING THE MODULE SYSTEM +.PP +If you want to include additional modules in your compilation, use the +\f[CB]\-\-add\-modules\f[R] option. +This may be necessary when you are compiling code that is not in a +module, or which is in an automatic module, and the code refers to API +in the additional modules. +.PP +If you want to restrict the set of modules in your compilation, use the +\f[CB]\-\-limit\-modules\f[R] option. +This may be useful if you want to ensure that the code you are compiling +is capable of running on a system with a limited set of modules +installed. +.PP +If you want to break encapsulation and specify that additional packages +should be considered as exported from a module, use the +\f[CB]\-\-add\-exports\f[R] option. +This may be useful when performing white\-box testing; relying on access +to internal API in production code is strongly discouraged. +.PP +If you want to specify that additional packages should be considered as +required by a module, use the \f[CB]\-\-add\-reads\f[R] option. +This may be useful when performing white\-box testing; relying on access +to internal API in production code is strongly discouraged. +.PP +You can patch additional content into any module using the +\f[CB]\-\-patch\-module\f[R] option. +See [Patching a Module] for more details. +.SH SEARCHING FOR MODULE, PACKAGE AND TYPE DECLARATIONS +.PP +To compile a source file, the compiler often needs information about a +module or type, but the declaration is not in the source files specified +on the command line. +.PP +\f[CB]javac\f[R] needs type information for every class or interface used, +extended, or implemented in the source file. +This includes classes and interfaces not explicitly mentioned in the +source file, but that provide information through inheritance. +.PP +For example, when you create a subclass of \f[CB]java.awt.Window\f[R], you +are also using the ancestor classes of \f[CB]Window\f[R]: +\f[CB]java.awt.Container\f[R], \f[CB]java.awt.Component\f[R], and +\f[CB]java.lang.Object\f[R]. +.PP +When compiling code for a module, the compiler also needs to have +available the declaration of that module. +.PP +A successful search may produce a class file, a source file, or both. +If both are found, then you can use the \f[CB]\-Xprefer\f[R] option to +instruct the compiler which to use; see \f[B]Extra Options\f[R]. +.PP +If a search finds and uses a source file, then by default \f[CB]javac\f[R] +compiles that source file. +This behavior can be altered with \f[CB]\-implicit\f[R]; see \f[B]Standard +Options\f[R]. +.PP +The compiler might not discover the need for some type information until +after annotation processing completes. +When the type information is found in a source file and no +\f[CB]\-implicit\f[R] option is specified, the compiler gives a warning +that the file is being compiled without being subject to annotation +processing. +To disable the warning, either specify the file on the command line (so +that it will be subject to annotation processing) or use the +\f[CB]\-implicit\f[R] option to specify whether or not class files should +be generated for such source files. +.PP +The way that \f[CB]javac\f[R] locates the declarations of those types +depends on whether the reference exists within code for a module or not. +.SS Searching Package Oriented Paths +.PP +When searching for a source or class file on a path composed of package +oriented locations, \f[CB]javac\f[R] will check each location on the path +in turn for the possible presence of the file. +The first occurrence of a particular file shadows (hides) any subsequent +occurrences of like\-named files. +This shadowing does not affect any search for any files with a different +name. +This can be convenient when searching for source files, which may be +grouped in different locations, such as shared code, platform\-specific +code and generated code. +It can also be useful when injecting alternate versions of a class file +into a package, to debugging or other instrumentation reasons. +But, it can also be dangerous, such as when putting incompatible +different versions of a library on the class path. +.SS Searching Module Oriented Paths +.PP +Prior to scanning any module paths for any package or type declarations, +\f[CB]javac\f[R] will lazily scan the following paths and locations to +determine the modules that will be used in the compilation. +.IP \[bu] 2 +The module source path (see the \f[CB]\-\-module\-source\-path\f[R] +option) +.IP \[bu] 2 +The path for upgradeable modules (see the +\f[CB]\-\-upgrade\-module\-path\f[R] option) +.IP \[bu] 2 +The system modules (see the \f[CB]\-\-system\f[R] option) +.IP \[bu] 2 +The user module path ( see the \f[CB]\-\-module\-path\f[R] option) +.PP +For any module, the first occurrence of the module during the scan +completely shadows (hides) any subsequent appearance of a like\-named +module. +While locating the modules, \f[CB]javac\f[R] is able to determine the +packages exported by the module and to associate with each module a +package oriented path for the contents of the module. +For any previously compiled module, this path will typically be a single +entry for either a directory or a file that provides an internal +directory\-like hierarchy, such as a JAR file. +Thus, when searching for a type that is in a package that is known to be +exported by a module, \f[CB]javac\f[R] can locate the declaration directly +and efficiently. +.SS Searching for the Declaration of a Module +.PP +If the module has been previously compiled, the module declaration is +located in a file named \f[CB]module\-info.class\f[R] in the root of the +package hierarchy for the content of the module. +.PP +If the module is one of those currently being compiled, the module +declaration will be either the file named \f[CB]module\-info.class\f[R] in +the root of the package hierarchy for the module in the class output +directory, or the file named \f[CB]module\-info.java\f[R] in one of the +locations on the source path or one the module source path for the +module. +.SS Searching for the Declaration of a Type When the Reference is not in +a Module +.PP +When searching for a type that is referenced in code that is not in a +module, \f[CB]javac\f[R] will look in the following places: +.IP \[bu] 2 +The platform classes (or the types in exported packages of the platform +modules) (This is for compiled class files only.) +.IP \[bu] 2 +Types in exported packages of any modules on the module path, if +applicable. +(This is for compiled class files only.) +.IP \[bu] 2 +Types in packages on the class path and/or source path: +.RS 2 +.IP \[bu] 2 +If both are specified, \f[CB]javac\f[R] looks for compiled class files on +the class path and for source files on the source path. +.IP \[bu] 2 +If the class path is specified, but not source path, \f[CB]javac\f[R] +looks for both compiled class files and source files on the class path. +.IP \[bu] 2 +If the class path is not specified, it defaults to the current +directory. +.RE +.PP +When looking for a type on the class path and/or source path, if both a +compiled class file and a source file are found, the most recently +modified file will be used by default. +If the source file is newer, it will be compiled and will may override +any previously compiled version of the file. +You can use the \f[CB]\-Xprefer\f[R] option to override the default +behavior. +.SS Searching for the Declaration of a Type When the Reference is in a +Module +.PP +When searching for a type that is referenced in code in a module, +\f[CB]javac\f[R] will examine the declaration of the enclosing module to +determine if the type is in a package that is exported from another +module that is readable by the enclosing module. +If so, \f[CB]javac\f[R] will simply and directly go to the definition of +that module to find the definition of the required type. +Unless the module is another of the modules being compiled, +\f[CB]javac\f[R] will only look for compiled class files files. +In other words, \f[CB]javac\f[R] will not look for source files in +platform modules or modules on the module path. +.PP +If the type being referenced is not in some other readable module, +\f[CB]javac\f[R] will examine the module being compiled to try and find +the declaration of the type. +\f[CB]javac\f[R] will look for the declaration of the type as follows: +.IP \[bu] 2 +Source files specified on the command line or on the source path or +module source path. +.IP \[bu] 2 +Previously compiled files in the output directory. +.SH DIRECTORY HIERARCHIES +.PP +\f[CB]javac\f[R] generally assumes that source files and compiled class +files will be organized in a file system directory hierarchy or in a +type of file that supports in an internal directory hierarchy, such as a +JAR file. +Three different kinds of hierarchy are supported: a \f[I]package +hierarchy\f[R], a \f[I]module hierarchy\f[R], and a \f[I]module source +hierarchy\f[R]. +.PP +While \f[CB]javac\f[R] is fairly relaxed about the organization of source +code, beyond the expectation that source will be organized in one or +package hierarchies, and can generally accomodate organizations +prescribed by development environments and build tools, Java tools in +general, and \f[CB]javac\f[R] and the Java launcher in particular, are +more stringent regarding the organization of compiled class files, and +will be organized in package hierarchies or module hierarchies, as +appropriate. +.PP +The location of these hierarchies are specified to \f[CB]javac\f[R] with +command\-line options, whose names typically end in "path", like +\f[CB]\-\-source\-path\f[R] or \f[CB]\-\-class\-path\f[R]. +Also as a general rule, path options whose name includes the word +\f[CB]module\f[R], like \f[CB]\-\-module\-path\f[R], are used to specify +module hierarchies, although some module\-related path options allow a +package hierarchy to be specified on a per\-module basis. +All other path options are used to specify package hierarchies. +.SS Package Hierarchy +.PP +In a package hierarchy, directories and subdirectories are used to +represent the component parts of the package name, with the source file +or compiled class file for a type being stored as a file with an +extension of \f[CB]\&.java\f[R] or \f[CB]\&.class\f[R] in the most nested +directory. +.PP +For example, in a package hierarchy, the source file for a class +\f[CB]com.example.MyClass\f[R] will be stored in the file +\f[I]com/example/MyClass.java\f[R] +.SS Module Hierarchy +.PP +In a module hierarchy, the first level of directories are named for the +modules in the hierarchy; within each of those directories the contents +of the module are organized in package hierarchies. +.PP +For example, in a module hierarchy, the compiled class file for a type +called \f[CB]com.example.MyClass\f[R] in a module called +\f[CB]my.library\f[R] will be stored in +\f[I]my.library/com/example/MyClass.class\f[R]. +.PP +The various output directories used by \f[CB]javac\f[R] (the class output +directory, the source output directory, and native header output +directory) will all be organized in a module hierarchy when multiple +modules are being compiled. +.SS Module Source Hierarchy +.PP +Although the source for each individual module should always be +organized in a package hierarchy, it may be convenient to group those +hierarchies into a module source hierarchy. +This is similar to a module hierarchy, except that there may be +intervening directories between the directory for the module and the +directory that is the root of the package hierarchy for the source code +of the module. +.PP +For example, in a module source hierarchy, the source file for a type +called \f[CB]com.example.MyClass\f[R] in a module called +\f[CB]my.library\f[R] may be stored in a file such as +\f[I]my.library/src/main/java/com/example/MyClass.java\f[R]. +.SH THE MODULE SOURCE PATH OPTION +.PP +The \f[CB]\-\-module\-source\-path\f[R] option has two forms: a +\f[I]module\-specific form\f[R], in which a package path is given for +each module containing code to be compiled, and a +\f[I]module\-pattern\f[R] form, in which the source path for each module +is specified by a pattern. +The module\-specific form is generally simpler to use when only a small +number of modules are involved; the module\-pattern form may be more +convenient when the number of modules is large and the modules are +organized in a regular manner that can be described by a pattern. +.PP +Multiple instances of the \f[CB]\-\-module\-source\-path\f[R] option may +be given, each one using either the module\-pattern form or the +module\-specific form, subject to the following limitations: +.IP \[bu] 2 +the module\-pattern form may be used at most once +.IP \[bu] 2 +the module\-specific form may be used at most once for any given module +.PP +If the module\-specific form is used for any module, the associated +search path overrides any path that might otherwise have been inferred +from the module\-pattern form. +.SS Module\-specific form +.PP +The module\-specific form allows an explicit search path to be given for +any specific module. +This form is: +.IP \[bu] 2 +\f[CB]\-\-module\-source\-path\f[R] +\f[I]module\-name\f[R]\f[CB]=\f[R]\f[I]file\-path\f[R] +(\f[I]path\-separator\f[R] \f[I]file\-path\f[R])* +.PP +The path separator character is \f[CB];\f[R] on Windows, and \f[CB]:\f[R] +otherwise. +.PP +\f[B]Note:\f[R] this is similar to the form used for the +\f[CB]\-\-patch\-module\f[R] option. +.SS Module\-pattern form +.PP +The module\-pattern form allows a concise specification of the module +source path for any number of modules organized in regular manner. +.IP \[bu] 2 +\f[CB]\-\-module\-source\-path\f[R] \f[I]pattern\f[R] +.PP +The pattern is defined by the following rules, which are applied in +order: +.IP \[bu] 2 +The argument is considered to be a series of segments separated by the +path separator character (\f[CB];\f[R] on Windows, and \f[CB]:\f[R] +otherwise). +.IP \[bu] 2 +Each segment containing curly braces of the form +.RS 2 +.IP +.nf +\f[CB] +string1{alt1\ (\ ,alt2\ )*\ }\ string2 +\f[R] +.fi +.PP +is considered to be replaced by a series of segments formed by +"expanding" the braces: +.IP +.nf +\f[CB] +string1\ alt1\ string2 +string1\ alt2\ string2 +and\ so\ on... +\f[R] +.fi +.PP +The braces may be nested. +.PP +This rule is applied for all such usages of braces. +.RE +.IP \[bu] 2 +Each segment must have at most one asterisk (\f[CB]*\f[R]). +If a segment does not contain an asterisk, it is considered to be as +though the file separator character and an asterisk are appended. +.RS 2 +.PP +For any module \f[I]M\f[R], the source path for that module is formed +from the series of segments obtained by substituting the module name +\f[I]M\f[R] for the asterisk in each segment. +.PP +\f[B]Note\f[R]: in this context, the asterisk is just used as a special +marker, to denote the position in the path of the module name. +It should not be confused with the use of \f[CB]*\f[R] as a file name +wildcard character, as found on most operating systems. +.RE +.SH PATCHING MODULES +.PP +javac allows any content, whether in source or compiled form, to be +patched into any module using the \f[CB]\-\-patch\-module\f[R] option. +You may want to do this to compile alternative implementations of a +class to be patched at runtime into a JVM, or to inject additional +classes into the module, such as when testing. +.PP +The form of the option is: +.IP \[bu] 2 +\f[CB]\-\-patch\-module\f[R] +\f[I]module\-name\f[R]\f[CB]=\f[R]\f[I]file\-path\f[R] +(\f[I]path\-separator\f[R] \f[I]file\-path\f[R] )* +.PP +The path separator character is \f[CB];\f[R] on Windows, and \f[CB]:\f[R] +otherwise. +The paths given for the module must specify the root of a package +hierarchy for the contents of the module +.PP +The option may be given at most once for any given module. +Any content on the path will hide any like\-named content later in the +path and in the patched module. +.PP +When patching source code into more than one module, the +\f[CB]\-\-module\-source\-path\f[R] must also be used, so that the output +directory is organized in a module hierarchy, and capable of holding the +compiled class files for the modules being compiled. +.SH ANNOTATION PROCESSING +.PP +The \f[CB]javac\f[R] command provides direct support for annotation +processing. +.PP +The API for annotation processors is defined in the +\f[CB]javax.annotation.processing\f[R] and \f[CB]javax.lang.model\f[R] +packages and subpackages. +.SS How Annotation Processing Works +.PP +Unless annotation processing is disabled with the \f[CB]\-proc:none\f[R] +option, the compiler searches for any annotation processors that are +available. +The search path can be specified with the \f[CB]\-processorpath\f[R] +option. +If no path is specified, then the user class path is used. +Processors are located by means of service provider\-configuration files +named \f[CB]META\-INF/services/javax.annotation.processing\f[R]. +Processor on the search path. +Such files should contain the names of any annotation processors to be +used, listed one per line. +Alternatively, processors can be specified explicitly, using the +\f[CB]\-processor\f[R] option. +.PP +After scanning the source files and classes on the command line to +determine what annotations are present, the compiler queries the +processors to determine what annotations they process. +When a match is found, the processor is called. +A processor can claim the annotations it processes, in which case no +further attempt is made to find any processors for those annotations. +After all of the annotations are claimed, the compiler does not search +for additional processors. +.PP +If any processors generate new source files, then another round of +annotation processing occurs: Any newly generated source files are +scanned, and the annotations processed as before. +Any processors called on previous rounds are also called on all +subsequent rounds. +This continues until no new source files are generated. +.PP +After a round occurs where no new source files are generated, the +annotation processors are called one last time, to give them a chance to +complete any remaining work. +Finally, unless the \f[CB]\-proc:only\f[R] option is used, the compiler +compiles the original and all generated source files. +.PP +If you use an annotation processor that generates additional source +files to be included in the compilation, you can specify a default +module to be used for the newly generated files, for use when a module +declaration is not also generated. +In this case, use the \f[CB]\-\-default\-module\-for\-created\-files\f[R] +option. +.SS Compilation Environment and Runtime Environment. +.PP +The declarations in source files and previously compiled class files are +analyzed by \f[CB]javac\f[R] in a \f[I]compilation environment\f[R] that is +distinct from the \f[I]runtime environment\f[R] used to execute +\f[CB]javac\f[R] itself. +Although there is a deliberate similarity between many \f[CB]javac\f[R] +options and like\-named options for the Java \f[B]launcher\f[R], such as +\f[CB]\-\-class\-path\f[R], \f[CB]\-\-module\-path\f[R] and so on, it is +important to understand that in general the \f[CB]javac\f[R] options just +affect the environment in which the source files are compiled, and do +not affect the operation of \f[CB]javac\f[R] itself. +.PP +The distinction between the compilation environment and runtime +environment is significant when it comes to using annotation processors. +Although annotations processors process elements (declarations) that +exist in the compilation environment, the annotation processor itself is +executed in the runtime environment. +If an annotation processor has dependencies on libraries that are not in +modules, the libraries can be placed, along with the annotation +processor itself, on the processor path. +(See the \f[CB]\-\-processor\-path\f[R] option.) If the annotation +processor and its dependencies are in modules, you should use the +processor module path instead. +(See the \f[CB]\-\-processor\-module\-path\f[R] option.) When those are +insufficient, it may be necessary to provide further configuration of +the runtime environment. +This can be done in two ways: +.IP "1." 3 +If \f[CB]javac\f[R] is invoked from the command line, options can be +passed to the underlying runtime by prefixing the option with +\f[CB]\-J\f[R]. +(See the \f[CB]\-J\f[R] option.) +.IP "2." 3 +You can start an instance of a Java Virtual Machine directly and use +command line options and API to configure an environment in which +\f[CB]javac\f[R] can be invoked via one of its \f[B]APIs\f[R]. +.SH COMPILING FOR EARLIER RELEASES OF THE PLATFORM +.PP +\f[CB]javac\f[R] can compile code that is to be used on other releases of +the platform, using either the \f[CB]\-\-release\f[R] option, or the +\f[CB]\-\-source\f[R]/\f[CB]\-source\f[R] and +\f[CB]\-\-target\f[R]/\f[CB]\-target\f[R] options, together with additional +options to specify the platform classes. +.PP +Depending on the desired platform release, there are some restrictions +on some of the options that can be used. +.IP \[bu] 2 +When compiling for JDK 8 and earlier releases, you cannot use any option +that is intended for use with the module system. +This includes all of the following options: +.RS 2 +.IP \[bu] 2 +\f[CB]\-\-module\-source\-path\f[R], \f[CB]\-\-upgrade\-module\-path\f[R], +\f[CB]\-\-system\f[R], \f[CB]\-\-module\-path\f[R], +\f[CB]\-\-add\-modules\f[R], \f[CB]\-\-add\-exports\f[R], +\f[CB]\-\-add\-opens\f[R], \f[CB]\-\-add\-reads\f[R], +\f[CB]\-\-limit\-modules\f[R], \f[CB]\-\-patch\-module\f[R] +.PP +If you use the \f[CB]\-\-source\f[R]/\f[CB]\-source\f[R] or +\f[CB]\-\-target\f[R]/\f[CB]\-target\f[R] options, you should also set the +appropriate platform classes using the boot class path family of +options. +.RE +.IP \[bu] 2 +When compiling for JDK 9 and later releases, you cannot use any option +that is intended to configure the boot class path. +This includes all of the following options: +.RS 2 +.IP \[bu] 2 +\f[CB]\-Xbootclasspath/p:\f[R], \f[CB]\-Xbootclasspath\f[R], +\f[CB]\-Xbootclasspath/a:\f[R], \f[CB]\-endorseddirs\f[R], +\f[CB]\-Djava.endorsed.dirs\f[R], \f[CB]\-extdirs\f[R], +\f[CB]\-Djava.ext.dirs\f[R], \f[CB]\-profile\f[R] +.PP +If you use the \f[CB]\-\-source\f[R]/\f[CB]\-source\f[R] or +\f[CB]\-\-target\f[R]/\f[CB]\-target\f[R] options, you should also set the +appropriate platform classes using the \f[CB]\-\-system\f[R] option to +give the location of an appropriate installed release of JDK. +.RE +.PP +When using the \f[CB]\-\-release\f[R] option, only the supported +documented API for that release may be used; you cannot use any options +to break encapsulation to access any internal classes. +.SH APIS +.PP +The \f[CB]javac\f[R] compiler can be invoked using an API in three +different ways: +.TP +.B The \f[B]Java Compiler API\f[R] +This provides the most flexible way to invoke the compiler, including +the ability to compile source files provided in memory buffers or other +non\-standard file systems. +.RS +.RE +.TP +.B The \f[B]ToolProvider API\f[R] +A \f[CB]ToolProvider\f[R] for \f[CB]javac\f[R] can be obtained by calling +\f[CB]ToolProvider.findFirst("javac")\f[R]. +This returns an object with the equivalent functionality of the +command\-line tool. +.RS +.PP +\f[B]Note\f[R]: This API should not be confused with the like\-named API +in the \f[B]\f[BC]javax.tools\f[B]\f[R] package. +.RE +.TP +.B The \f[CB]javac\f[R] \f[B]Legacy API\f[R] +This API is retained for backward compatibility only. +All new code should use either the Java Compiler API or the ToolProvider +API. +.RS +.RE +.PP +\f[B]Note:\f[R] All other classes and methods found in a package with +names that start with \f[CB]com.sun.tools.javac\f[R] (subpackages of +\f[CB]com.sun.tools.javac\f[R]) are strictly internal and subject to +change at any time. .SH EXAMPLES OF USING \-XLINT KEYS .TP .B \f[CB]cast\f[R] @@ -1074,8 +1938,8 @@ .TP .B \f[CB]dep\-ann\f[R] Warns about items that are documented with the \f[CB]\@deprecated\f[R] -Javadoc comment, but don\[aq]t have the \f[CB]\@Deprecated\f[R] -annotation, for example: +Javadoc comment, but do not have the \f[CB]\@Deprecated\f[R] annotation, +for example: .RS .IP .nf @@ -1117,10 +1981,11 @@ Checks the switch blocks for fall\-through cases and provides a warning message for any that are found. Fall\-through cases are cases in a switch block, other than the last -case in the block, whose code doesn\[aq]t include a break statement, -allowing code execution to fall through from that case to the next case. +case in the block, whose code does not include a \f[CB]break\f[R] +statement, allowing code execution to fall through from that case to the +next case. For example, the code following the case 1 label in this switch block -doesn\[aq]t end with a break statement: +does not end with a \f[CB]break\f[R] statement: .RS .IP .nf @@ -1141,8 +2006,8 @@ .RE .TP .B \f[CB]finally\f[R] -Warns about \f[CB]finally\f[R] clauses that can\[aq]t be completed -normally, for example: +Warns about \f[CB]finally\f[R] clauses that cannot be completed normally, +for example: .RS .IP .nf @@ -1172,7 +2037,7 @@ .TP .B \f[CB]options\f[R] Warns about issues that related to the use of command\-line options. -See \f[B]Cross\-Compilation Options for javac\f[R]. +See \f[B]Compiling for Earlier Releases of the Platform\f[R]. .RS .RE .TP @@ -1218,12 +2083,12 @@ Warns about invalid path elements and nonexistent path directories on the command line (with regard to the class path, the source path, and other paths). -Such warnings can\[aq]t be suppressed with the -\f[CB]\@SuppressWarnings\f[R] annotation. +Such warnings cannot be suppressed with the \f[CB]\@SuppressWarnings\f[R] +annotation. For example: .RS .IP \[bu] 2 -\f[B]Oracle Solaris, Linux, and OS X:\f[R] +\f[B]Oracle Solaris, Linux, and macOS:\f[R] \f[CB]javac\ \-Xlint:path\ \-classpath\ /nonexistentpath\ Example.java\f[R] .IP \[bu] 2 \f[B]Windows:\f[R] @@ -1233,8 +2098,8 @@ .B \f[CB]processing\f[R] Warns about issues related to annotation processing. The compiler generates this warning when you have a class that has an -annotation, and you use an annotation processor that can\[aq]t handle -that type of exception. +annotation, and you use an annotation processor that cannot handle that +type of exception. For example, the following is a simple annotation processor: .RS .PP @@ -1306,7 +2171,7 @@ \f[CB]void\ countElements(List\ l)\ {\ ...\ }\f[R] .RE .PP -The following example doesn\[aq]t generate a \f[CB]rawtypes\f[R] warning: +The following example does not generate a \f[CB]rawtypes\f[R] warning: .RS .PP \f[CB]void\ countElements(List\ l)\ {\ ...\ }\f[R] @@ -1354,7 +2219,7 @@ \f[R] .fi .PP -If a serializable class doesn\[aq]t explicitly declare a field named +If a serializable class does not explicitly declare a field named \f[CB]serialVersionUID\f[R], then the serialization runtime environment calculates a default \f[CB]serialVersionUID\f[R] value for that class based on various aspects of the class, as described in the Java Object @@ -1372,8 +2237,7 @@ .RE .TP .B \f[CB]static\f[R] -Warns about issues relating to the use of statics variables, for -example: +Warns about issues relating to the use of static variables, for example: .RS .IP .nf @@ -1409,8 +2273,7 @@ Warns about issues relating to the use of \f[CB]try\f[R] blocks, including try\-with\-resources statements. For example, a warning is generated for the following statement because -the resource \f[CB]ac\f[R] declared in the \f[CB]try\f[R] block isn\[aq]t -used: +the resource \f[CB]ac\f[R] declared in the \f[CB]try\f[R] block is not used: .RS .IP .nf @@ -1440,10 +2303,9 @@ \f[CB]List\f[R]. When the \f[CB]List\f[R] referenced by \f[CB]l\f[R] is assigned to \f[CB]ls\f[R], the compiler generates an unchecked warning. -At compile time, the compiler and JVM can\[aq]t determine whether +At compile time, the compiler and JVM cannot determine whether \f[CB]l\f[R] refers to a \f[CB]List\f[R] type. -In this case, \f[CB]l\f[R] doesn\[aq]t refer to a \f[CB]List\f[R] -type. +In this case, \f[CB]l\f[R] does not refer to a \f[CB]List\f[R] type. As a result, heap pollution occurs. .PP A heap pollution situation occurs when the \f[CB]List\f[R] object @@ -1452,7 +2314,7 @@ type, \f[CB]List\f[R]. However, the compiler still allows this assignment. It must allow this assignment to preserve backward compatibility with -releases of Java SE that don\[aq]t support generics. +releases of Java SE that do not support generics. Because of type erasure, \f[CB]List\f[R] and \f[CB]List\f[R] both become \f[CB]List\f[R]. Consequently, the compiler allows the assignment of the object @@ -1477,7 +2339,7 @@ \f[R] .fi .PP -A non\-reifiable type is a type whose type information isn\[aq]t fully +A non\-reifiable type is a type whose type information is not fully available at runtime. .PP The compiler generates the following warning for the definition of the @@ -1491,8 +2353,8 @@ .PP When the compiler encounters a varargs method, it translates the \f[CB]varargs\f[R] formal parameter into an array. -However, the Java programming language doesn\[aq]t permit the creation -of arrays of parameterized types. +However, the Java programming language does not permit the creation of +arrays of parameterized types. In the method \f[CB]ArrayBuilder.addToList\f[R], the compiler translates the \f[CB]varargs\f[R] formal parameter \f[CB]T...\f[R] elements to the formal parameter \f[CB]T[]\f[R] elements, an array. @@ -1500,274 +2362,3 @@ \f[CB]varargs\f[R] formal parameter to \f[CB]Object[]\f[R] elements. Consequently, there\[aq]s a possibility of heap pollution. .RE -.SH EXAMPLE OF COMPILING BY PROVIDING COMMAND\-LINE ARGUMENTS -.PP -To compile as though providing command\-line arguments, use the -following syntax: -.RS -.PP -\f[CB]JavaCompiler\ javac\ =\ ToolProvider.getSystemJavaCompiler();\f[R] -.RE -.PP -The example writes diagnostics to the standard output stream and returns -the exit code that \f[CB]javac\f[R] command would give when called from -the command line. -.PP -You can use other methods in the \f[CB]javax.tools.JavaCompiler\f[R] -interface to handle diagnostics, control where files are read from and -written to, and more. -.SH OLD INTERFACE -.PP -\f[B]Note:\f[R] -.PP -This API is retained for backward compatibility only. -All new code should use the Java Compiler API. -.PP -The \f[CB]com.sun.tools.javac.Main\f[R] class provides two static methods -to call the compiler from a program: -.IP -.nf -\f[CB] -public\ static\ int\ compile(String[]\ args); -public\ static\ int\ compile(String[]\ args,\ PrintWriter\ out); -\f[R] -.fi -.PP -The \f[CB]args\f[R] parameter represents any of the command\-line -arguments that would typically be passed to the compiler. -.PP -The \f[CB]out\f[R] parameter indicates where the compiler diagnostic -output is directed. -.PP -The \f[CB]return\f[R] value is equivalent to the \f[CB]exit\f[R] value from -\f[CB]javac\f[R]. -.PP -\f[B]Note:\f[R] -.PP -All other classes and methods found in a package with names that start -with \f[CB]com.sun.tools.javac\f[R] (subpackages of -\f[CB]com.sun.tools.javac\f[R]) are strictly internal and subject to -change at any time. -.SH EXAMPLE OF COMPILING MULTIPLE SOURCE FILES -.PP -This example compiles the \f[CB]Aloha.java\f[R], \f[CB]GutenTag.java\f[R], -\f[CB]Hello.java\f[R], and \f[CB]Hi.java\f[R] source files in the -\f[CB]greetings\f[R] package. -.PP -\f[B]Oracle Solaris, Linux, and OS X:\f[R] -.IP -.nf -\f[CB] -%\ javac\ greetings/*.java -%\ ls\ greetings -Aloha.class\ \ \ \ \ \ \ \ \ GutenTag.class\ \ \ \ \ \ Hello.class\ \ \ \ \ \ \ \ \ Hi.class -Aloha.java\ \ \ \ \ \ \ \ \ \ GutenTag.java\ \ \ \ \ \ \ Hello.java\ \ \ \ \ \ \ \ \ \ Hi.java -\f[R] -.fi -.PP -\f[B]Windows:\f[R] -.IP -.nf -\f[CB] -C:\\>javac\ greetings\\*.java -C:\\>dir\ greetings -Aloha.class\ \ \ \ \ \ \ \ \ GutenTag.class\ \ \ \ \ \ Hello.class\ \ \ \ \ \ \ \ \ Hi.class -Aloha.java\ \ \ \ \ \ \ \ \ \ GutenTag.java\ \ \ \ \ \ \ Hello.java\ \ \ \ \ \ \ \ \ \ Hi.java -\f[R] -.fi -.SH EXAMPLE OF SPECIFYING A USER CLASS PATH -.PP -After changing one of the source files in the previous example, -recompile it: -.PP -\f[B]Oracle Solaris, Linux, and OS X:\f[R] -.IP -.nf -\f[CB] -pwd -/examples -javac\ greetings/Hi.java -\f[R] -.fi -.PP -\f[B]Windows:\f[R] -.IP -.nf -\f[CB] -C:\\>cd -\\examples -C:\\>javac\ greetings\\Hi.java -\f[R] -.fi -.PP -Because \f[CB]greetings.Hi\f[R] refers to other classes in the -\f[CB]greetings\f[R] package, the compiler needs to find these other -classes. -The previous example works because the default user class path is the -directory that contains the package directory. -If you want to recompile this file without concern for which directory -you are in, then add the examples directory to the user class path by -setting \f[CB]CLASSPATH\f[R]. -This example uses the \f[CB]\-classpath\f[R] option. -.PP -\f[B]Oracle Solaris, Linux, and OS X:\f[R] -.RS -.PP -\f[CB]javac\ \-classpath\ /examples\ /examples/greetings/Hi.java\f[R] -.RE -.PP -\f[B]Windows:\f[R] -.RS -.PP -\f[CB]C:\\>javac\ \-classpath\ \\examples\ \\examples\\greetings\\Hi.java\f[R] -.RE -.PP -If you change \f[CB]greetings.Hi\f[R] to use a banner utility, then that -utility also needs to be accessible through the user class path. -.PP -\f[B]Oracle Solaris, Linux, and OS X:\f[R] -.IP -.nf -\f[CB] -javac\ \-classpath\ /examples:/lib/Banners.jar\ \\ -\ \ \ \ \ \ \ \ \ \ \ \ /examples/greetings/Hi.java -\f[R] -.fi -.PP -\f[B]Windows:\f[R] -.IP -.nf -\f[CB] -C:\\>javac\ \-classpath\ \\examples;\\lib\\Banners.jar\ ^ -\ \ \ \ \ \ \ \ \ \ \ \ \\examples\\greetings\\Hi.java -\f[R] -.fi -.PP -To execute a class in the \f[CB]greetings\f[R] package, the program needs -access to the \f[CB]greetings\f[R] package, and to the classes that the -\f[CB]greetings\f[R] classes use. -.PP -\f[B]Oracle Solaris, Linux, and OS X:\f[R] -.RS -.PP -\f[CB]java\ \-classpath\ /examples:/lib/Banners.jar\ greetings.Hi\f[R] -.RE -.PP -\f[B]Windows:\f[R] -.RS -.PP -\f[CB]C:\\>java\ \-classpath\ \\examples;\\lib\\Banners.jar\ greetings.Hi\f[R] -.RE -.PP -The \f[CB]\-source\ 1.7\f[R] option specifies that release 1.7 (or 7) of -the Java programming language must be used to compile OldCode.java. -The \f[CB]\-target\ 1.7\f[R] option ensures that the generated class files -are compatible with JVM 1.7. -.SH ANNOTATION PROCESSING -.PP -The \f[CB]javac\f[R] command provides direct support for annotation -processing, superseding the need for the separate annotation processing -command, \f[CB]apt\f[R]. -.PP -The API for annotation processors is defined in the -\f[CB]javax.annotation.processing\f[R] and \f[CB]javax.lang.model\f[R] -packages and subpackages. -.SS How Annotation Processing Works -.PP -Unless annotation processing is disabled with the \f[CB]\-proc:none\f[R] -option, the compiler searches for any annotation processors that are -available. -The search path can be specified with the \f[CB]\-processorpath\f[R] -option. -If no path is specified, then the user class path is used. -Processors are located by means of service provider\-configuration files -named \f[CB]META\-INF/services/javax.annotation.processing\f[R]. -Processor on the search path. -Such files should contain the names of any annotation processors to be -used, listed one per line. -Alternatively, processors can be specified explicitly, using the -\f[CB]\-processor\f[R] option. -.PP -After scanning the source files and classes on the command line to -determine what annotations are present, the compiler queries the -processors to determine what annotations they process. -When a match is found, the processor is called. -A processor can claim the annotations it processes, in which case no -further attempt is made to find any processors for those annotations. -After all of the annotations are claimed, the compiler does not search -for additional processors. -.PP -If any processors generate new source files, then another round of -annotation processing occurs: Any newly generated source files are -scanned, and the annotations processed as before. -Any processors called on previous rounds are also called on all -subsequent rounds. -This continues until no new source files are generated. -.PP -After a round occurs where no new source files are generated, the -annotation processors are called one last time, to give them a chance to -complete any remaining work. -Finally, unless the \f[CB]\-proc:only\f[R] option is used, the compiler -compiles the original and all generated source files. -.SH SEARCHING FOR TYPES -.PP -To compile a source file, the compiler often needs information about a -type, but the type definition is not in the source files specified on -the command line. -.PP -The compiler needs type information for every class or interface used, -extended, or implemented in the source file. -This includes classes and interfaces not explicitly mentioned in the -source file, but that provide information through inheritance. -.PP -For example, when you create a subclass of \f[CB]java.awt.Window\f[R], you -are also using the ancestor classes of \f[CB]Window\f[R]: -\f[CB]java.awt.Container\f[R], \f[CB]java.awt.Component\f[R], and -\f[CB]java.lang.Object\f[R]. -.PP -When the compiler needs type information, it searches for a source file -or class file that defines the type. -The compiler searches for class files first in the bootstrap and -extension classes, then in the user class path (which by default is the -current directory). -The user class path is defined by setting the \f[CB]CLASSPATH\f[R] -environment variable or by using the \f[CB]\-classpath\f[R] option. -.PP -If you set the \f[CB]\-sourcepath\f[R] option, then the compiler searches -the indicated path for source files. -Otherwise, the compiler searches the user class path for both class -files and source files. -.PP -You can specify different bootstrap or extension classes with the -\f[CB]\-bootclasspath\f[R] and the \f[CB]\-extdirs\f[R] options. -See \f[B]Cross\-Compilation Options for javac\f[R]. -.PP -A successful type search may produce a class file, a source file, or -both. -If both are found, then you can use the \f[CB]\-Xprefer\f[R] option to -instruct the compiler which to use. -If \f[CB]newer\f[R] is specified, then the compiler uses the newer of the -two files. -If \f[CB]source\f[R] is specified, the compiler uses the source file. -The default is \f[CB]newer\f[R]. -.PP -If a type search finds a source file for a required type, either by -itself, or as a result of the setting for the \f[CB]\-Xprefer\f[R] option, -then the compiler reads the source file to get the information it needs. -By default the compiler also compiles the source file. -You can use the \f[CB]\-implicit\f[R] option to specify the behavior. -If \f[CB]none\f[R] is specified, then no class files are generated for the -source file. -If \f[CB]class\f[R] is specified, then class files are generated for the -source file. -.PP -The compiler might not discover the need for some type information until -after annotation processing completes. -When the type information is found in a source file and no -\f[CB]\-implicit\f[R] option is specified, the compiler gives a warning -that the file is being compiled without being subject to annotation -processing. -To disable the warning, either specify the file on the command line (so -that it will be subject to annotation processing) or use the -\f[CB]\-implicit\f[R] option to specify whether or not class files should -be generated for such source files. diff -r a35a210e6c0f -r d755f53becea src/jdk.crypto.ec/share/classes/sun/security/ec/ECDSASignature.java --- a/src/jdk.crypto.ec/share/classes/sun/security/ec/ECDSASignature.java Thu Jul 11 15:58:54 2019 +0000 +++ b/src/jdk.crypto.ec/share/classes/sun/security/ec/ECDSASignature.java Fri Jul 12 02:50:43 2019 -0700 @@ -72,6 +72,9 @@ // public key, if initialized for verifying private ECPublicKey publicKey; + // signature parameters + private ECParameterSpec sigParams = null; + // The format. true for the IEEE P1363 format. false (default) for ASN.1 private final boolean p1363Format; @@ -279,10 +282,14 @@ @Override protected void engineInitVerify(PublicKey publicKey) throws InvalidKeyException { - this.publicKey = (ECPublicKey) ECKeyFactory.toECKey(publicKey); + ECPublicKey key = (ECPublicKey) ECKeyFactory.toECKey(publicKey); + if (!isCompatible(this.sigParams, key.getParams())) { + throw new InvalidKeyException("Key params does not match signature params"); + } // Should check that the supplied key is appropriate for signature // algorithm (e.g. P-256 for SHA256withECDSA) + this.publicKey = key; this.privateKey = null; resetDigest(); } @@ -298,10 +305,14 @@ @Override protected void engineInitSign(PrivateKey privateKey, SecureRandom random) throws InvalidKeyException { - this.privateKey = (ECPrivateKey) ECKeyFactory.toECKey(privateKey); + ECPrivateKey key = (ECPrivateKey) ECKeyFactory.toECKey(privateKey); + if (!isCompatible(this.sigParams, key.getParams())) { + throw new InvalidKeyException("Key params does not match signature params"); + } // Should check that the supplied key is appropriate for signature // algorithm (e.g. P-256 for SHA256withECDSA) + this.privateKey = key; this.publicKey = null; this.random = random; resetDigest(); @@ -354,6 +365,16 @@ needsReset = true; } + private static boolean isCompatible(ECParameterSpec sigParams, + ECParameterSpec keyParams) { + if (sigParams == null) { + // no restriction on key param + return true; + } + return ECUtil.equals(sigParams, keyParams); + } + + private byte[] signDigestImpl(ECDSAOperations ops, int seedBits, byte[] digest, ECPrivateKeyImpl privImpl, SecureRandom random) throws SignatureException { @@ -495,9 +516,16 @@ @Override protected void engineSetParameter(AlgorithmParameterSpec params) throws InvalidAlgorithmParameterException { - if (params != null) { + if (params != null && !(params instanceof ECParameterSpec)) { throw new InvalidAlgorithmParameterException("No parameter accepted"); } + ECKey key = (this.privateKey == null? this.publicKey : this.privateKey); + if ((key != null) && !isCompatible((ECParameterSpec)params, key.getParams())) { + throw new InvalidAlgorithmParameterException + ("Signature params does not match key params"); + } + + sigParams = (ECParameterSpec) params; } // get parameter, not supported. See JCA doc @@ -510,7 +538,17 @@ @Override protected AlgorithmParameters engineGetParameters() { - return null; + if (sigParams == null) { + return null; + } + try { + AlgorithmParameters ap = AlgorithmParameters.getInstance("EC"); + ap.init(sigParams); + return ap; + } catch (Exception e) { + // should never happen + throw new ProviderException("Error retrieving EC parameters", e); + } } /** diff -r a35a210e6c0f -r d755f53becea src/jdk.javadoc/share/man/javadoc.1 --- a/src/jdk.javadoc/share/man/javadoc.1 Thu Jul 11 15:58:54 2019 +0000 +++ b/src/jdk.javadoc/share/man/javadoc.1 Fri Jul 12 02:50:43 2019 -0700 @@ -447,13 +447,13 @@ See \f[I]Extra Options\f[R] in \f[B]javac\f[R] for the detailed descriptions of using these options: .IP \[bu] 2 -\f[CB]\-add\-exports\f[R] +\f[CB]\-\-add\-exports\f[R] .IP \[bu] 2 \f[CB]\-\-add\-reads\f[R] .IP \[bu] 2 \f[CB]\-\-patch\-module\f[R] .IP \[bu] 2 -\f[CB]\-\-Xmaxerrs\f[R] +\f[CB]\-Xmaxerrs\f[R] .IP \[bu] 2 \f[CB]\-Xmaxwarns\f[R] .PP diff -r a35a210e6c0f -r d755f53becea src/jdk.jdeps/share/man/javap.1 --- a/src/jdk.jdeps/share/man/javap.1 Thu Jul 11 15:58:54 2019 +0000 +++ b/src/jdk.jdeps/share/man/javap.1 Fri Jul 12 02:50:43 2019 -0700 @@ -131,8 +131,8 @@ .RE .TP .B \f[CB]\-sysinfo\f[R] -Shows system information (path, size, date, MD5 hash) of the class being -processed. +Shows system information (path, size, date, SHA\-256 hash) of the class +being processed. .RS .RE .TP @@ -169,6 +169,11 @@ .RS .RE .TP +.B \f[CB]\-\-multi\-release\f[R] \f[I]version\f[R] +Specifies the version to select in multi\-release JAR files. +.RS +.RE +.TP .B \f[CB]\-J\f[R]\f[I]option\f[R] Passes the specified option to the JVM. For example: diff -r a35a210e6c0f -r d755f53becea src/jdk.jdeps/share/man/jdeps.1 --- a/src/jdk.jdeps/share/man/jdeps.1 Thu Jul 11 15:58:54 2019 +0000 +++ b/src/jdk.jdeps/share/man/jdeps.1 Fri Jul 12 02:50:43 2019 -0700 @@ -63,6 +63,11 @@ \f[CB]\-dotoutput\f[R] option). .SH POSSIBLE OPTIONS .TP +.B \f[CB]\-?\f[R] or \f[CB]\-h\f[R] or \f[CB]\-\-help\f[R] +Prints the help message. +.RS +.RE +.TP .B \f[CB]\-dotoutput\f[R] \f[I]dir\f[R] or \f[CB]\-\-dot\-output\f[R] \f[I]dir\f[R] Specifies the destination directory for DOT file output. If this option is specified, then the \f[CB]jdeps\f[R]command generates @@ -296,7 +301,7 @@ .RS .RE .TP -.B \f[CB]\-R\f[R] or \f[CB]\-recursive\f[R] +.B \f[CB]\-R\f[R] or \f[CB]\-\-recursive\f[R] Recursively traverses all run\-time dependences. The \f[CB]\-R\f[R] option implies \f[CB]\-filter:none\f[R]. If \f[CB]\-p\f[R], \f[CB]\-e\f[R], or \f[CB]\-f\f[R] options are specified, @@ -309,7 +314,7 @@ .RS .RE .TP -.B \f[CB]\-I\f[R] or \f[CB]\-inverse\f[R] +.B \f[CB]\-I\f[R] or \f[CB]\-\-inverse\f[R] Analyzes the dependences per other given options and then finds all artifacts that directly and indirectly depend on the matching nodes. This is equivalent to the inverse of the compile\-time view analysis and diff -r a35a210e6c0f -r d755f53becea src/jdk.jlink/share/man/jlink.1 --- a/src/jdk.jlink/share/man/jlink.1 Thu Jul 11 15:58:54 2019 +0000 +++ b/src/jdk.jlink/share/man/jlink.1 Fri Jul 12 02:50:43 2019 -0700 @@ -379,9 +379,7 @@ The following command is similar to the one that creates a runtime image named \f[CB]greetingsapp\f[R], except that it will link the modules resolved from root modules with service binding; see the -\f[B]\f[BC]Configuration.resolveAndBind\f[B]\f[R] -[https://docs.oracle.com/javase/10/docs/api/java/lang/module/Configuration.html#resolveAndBind\-java.lang.module.ModuleFinder\-java.util.List\-java.lang.module.ModuleFinder\-java.util.Collection\-] -method. +\f[B]\f[BC]Configuration.resolveAndBind\f[B]\f[R] method. .IP .nf \f[CB] diff -r a35a210e6c0f -r d755f53becea src/jdk.jlink/share/man/jmod.1 --- a/src/jdk.jlink/share/man/jmod.1 Thu Jul 11 15:58:54 2019 +0000 +++ b/src/jdk.jlink/share/man/jmod.1 Fri Jul 12 02:50:43 2019 -0700 @@ -148,13 +148,10 @@ .IP \[bu] 2 \f[CB]regex:\f[R]\f[I]regex\-pattern\f[R] .PP -See the \f[B]\f[BC]FileSystem.getPathMatcher\f[B]\f[R] -[https://docs.oracle.com/javase/10/docs/api/java/nio/file/FileSystem.html#getPathMatcher\-java.lang.String\-] -method for the syntax of \f[I]glob\-pattern\f[R]. -See the \f[B]\f[BC]Pattern\f[B]\f[R] -[https://docs.oracle.com/javase/10/docs/api/java/util/regex/Pattern.html] -class for the syntax of \f[I]regex\-pattern\f[R], which represents a -regular expression. +See the \f[B]\f[BC]FileSystem.getPathMatcher\f[B]\f[R] method for the +syntax of \f[I]glob\-pattern\f[R]. +See the \f[B]\f[BC]Pattern\f[B]\f[R] class for the syntax of +\f[I]regex\-pattern\f[R], which represents a regular expression. .RE .TP .B \f[CB]\-\-hash\-modules\f[R] \f[I]regex\-pattern\f[R] diff -r a35a210e6c0f -r d755f53becea src/jdk.rmic/share/man/rmic.1 --- a/src/jdk.rmic/share/man/rmic.1 Thu Jul 11 15:58:54 2019 +0000 +++ b/src/jdk.rmic/share/man/rmic.1 Fri Jul 12 02:50:43 2019 -0700 @@ -46,12 +46,12 @@ .RE .SH DESCRIPTION .PP -\f[B]Deprecation Note:\f[R] The \f[CB]rmic\f[R] tool has been deprecated and -is subject to removal in a future release. Support for static -generation of Java Remote Method Protocol (JRMP) stubs and skeletons -has been deprecated. Applications should use dynamically generated -JRMP stubs, eliminating the need to use the \f[CB]rmic\f[R] tool for -JRMP-based applications. +\f[B]Deprecation Note:\f[R] The rmic tool has been deprecated and is +subject to removal in a future release. +Support for static generation of Java Remote Method Protocol (JRMP) +stubs and skeletons has been deprecated. +Applications should use dynamically generated JRMP stubs, eliminating +the need to use the rmic tool for JRMP\-based applications. .PP The \f[CB]rmic\f[R] compiler generates stub and skeleton class files using the JRMP. diff -r a35a210e6c0f -r d755f53becea src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/doubleconv/Bignum.java --- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/doubleconv/Bignum.java Thu Jul 11 15:58:54 2019 +0000 +++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/doubleconv/Bignum.java Fri Jul 12 02:50:43 2019 -0700 @@ -76,13 +76,10 @@ // grow. There are no checks if the stack-allocated space is sufficient. static final int kBigitCapacity = kMaxSignificantBits / kBigitSize; - private final int[] bigits_ = new int[kBigitCapacity]; - // A vector backed by bigits_buffer_. This way accesses to the array are - // checked for out-of-bounds errors. - // Vector bigits_; private int used_digits_; // The Bignum's value equals value(bigits_) * 2^(exponent_ * kBigitSize). private int exponent_; + private final int[] bigits_ = new int[kBigitCapacity]; Bignum() {} @@ -124,7 +121,9 @@ void assignUInt16(final char value) { assert (kBigitSize >= 16); zero(); - if (value == 0) return; + if (value == 0) { + return; + } ensureCapacity(1); bigits_[0] = value; @@ -136,7 +135,9 @@ final int kUInt64Size = 64; zero(); - if (value == 0) return; + if (value == 0) { + return; + } final int needed_bigits = kUInt64Size / kBigitSize + 1; ensureCapacity(needed_bigits); @@ -521,26 +522,27 @@ mask >>>= 2; long this_value = base; - boolean delayed_multipliciation = false; + boolean delayed_multiplication = false; final long max_32bits = 0xFFFFFFFFL; while (mask != 0 && this_value <= max_32bits) { this_value = this_value * this_value; // Verify that there is enough space in this_value to perform the // multiplication. The first bit_size bits must be 0. if ((power_exponent & mask) != 0) { + assert bit_size > 0; final long base_bits_mask = ~((1L << (64 - bit_size)) - 1); final boolean high_bits_zero = (this_value & base_bits_mask) == 0; if (high_bits_zero) { this_value *= base; } else { - delayed_multipliciation = true; + delayed_multiplication = true; } } mask >>>= 1; } assignUInt64(this_value); - if (delayed_multipliciation) { + if (delayed_multiplication) { multiplyByUInt32(base); } @@ -681,7 +683,7 @@ } - int bigitAt(final int index) { + int bigitOrZero(final int index) { if (index >= bigitLength()) return 0; if (index < exponent_) return 0; return bigits_[index - exponent_]; @@ -696,8 +698,8 @@ if (bigit_length_a < bigit_length_b) return -1; if (bigit_length_a > bigit_length_b) return +1; for (int i = bigit_length_a - 1; i >= Math.min(a.exponent_, b.exponent_); --i) { - final int bigit_a = a.bigitAt(i); - final int bigit_b = b.bigitAt(i); + final int bigit_a = a.bigitOrZero(i); + final int bigit_b = b.bigitOrZero(i); if (bigit_a < bigit_b) return -1; if (bigit_a > bigit_b) return +1; // Otherwise they are equal up to this digit. Try the next digit. @@ -726,9 +728,9 @@ // Starting at min_exponent all digits are == 0. So no need to compare them. final int min_exponent = Math.min(Math.min(a.exponent_, b.exponent_), c.exponent_); for (int i = c.bigitLength() - 1; i >= min_exponent; --i) { - final int int_a = a.bigitAt(i); - final int int_b = b.bigitAt(i); - final int int_c = c.bigitAt(i); + final int int_a = a.bigitOrZero(i); + final int int_b = b.bigitOrZero(i); + final int int_c = c.bigitOrZero(i); final int sum = int_a + int_b; if (sum > int_c + borrow) { return +1; diff -r a35a210e6c0f -r d755f53becea src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/doubleconv/FixedDtoa.java --- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/doubleconv/FixedDtoa.java Thu Jul 11 15:58:54 2019 +0000 +++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/doubleconv/FixedDtoa.java Fri Jul 12 02:50:43 2019 -0700 @@ -286,7 +286,8 @@ fractionals -= (long) (digit) << point; } // If the first bit after the point is set we have to round up. - if (((fractionals >>> (point - 1)) & 1) == 1) { + assert (fractionals == 0 || point - 1 >= 0); + if ((fractionals != 0) && ((fractionals >>> (point - 1)) & 1) == 1) { roundUp(buffer); } } else { // We need 128 bits. diff -r a35a210e6c0f -r d755f53becea src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/doubleconv/IeeeDouble.java --- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/doubleconv/IeeeDouble.java Thu Jul 11 15:58:54 2019 +0000 +++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/doubleconv/IeeeDouble.java Fri Jul 12 02:50:43 2019 -0700 @@ -115,7 +115,7 @@ } static double previousDouble(final long d64) { - if (d64 == (kInfinity | kSignMask)) return -longToDouble(kInfinity); + if (d64 == (kInfinity | kSignMask)) return -Infinity(); if (sign(d64) < 0) { return longToDouble(d64 + 1); } else { diff -r a35a210e6c0f -r d755f53becea test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/GarbageUtils.java --- a/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/GarbageUtils.java Thu Jul 11 15:58:54 2019 +0000 +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/gc/gp/GarbageUtils.java Fri Jul 12 02:50:43 2019 -0700 @@ -26,6 +26,7 @@ import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; +import java.lang.invoke.*; import java.util.*; import nsk.share.gc.gp.array.*; import nsk.share.gc.gp.string.*; @@ -194,6 +195,36 @@ return eatMemory(stresser, gp, initialFactor, minMemoryChunk, factor, OOM_TYPE.ANY); } + static int numberOfOOMEs = 0; + + /** + * Minimal wrapper of the main implementation. Catches any OOM + * that might be thrown when rematerializing Objects when deoptimizing. + * + * It is Important that the impl is not inlined. + */ + + public static int eatMemory(ExecutionController stresser, GarbageProducer gp, long initialFactor, long minMemoryChunk, long factor, OOM_TYPE type) { + try { + // Using a methodhandle invoke of eatMemoryImpl to prevent inlining of it + MethodHandles.Lookup lookup = MethodHandles.lookup(); + MethodType mt = MethodType.methodType( + int.class, + ExecutionController.class, + GarbageProducer.class, + long.class, + long.class, + long.class, + OOM_TYPE.class); + MethodHandle eat = lookup.findStatic(GarbageUtils.class, "eatMemoryImpl", mt); + return (int) eat.invoke(stresser, gp, initialFactor, minMemoryChunk, factor, type); + } catch (OutOfMemoryError e) { + return numberOfOOMEs++; + } catch (Throwable t) { + throw new RuntimeException(t); + } + } + /** * Eat memory using given garbage producer. * @@ -211,8 +242,9 @@ * @param type of OutOfMemory Exception: Java heap space or Metadata space * @return number of OOME occured */ - public static int eatMemory(ExecutionController stresser, GarbageProducer gp, long initialFactor, long minMemoryChunk, long factor, OOM_TYPE type) { - int numberOfOOMEs = 0; + + public static int eatMemoryImpl(ExecutionController stresser, GarbageProducer gp, long initialFactor, long minMemoryChunk, long factor, OOM_TYPE type) { + numberOfOOMEs = 0; try { byte[] someMemory = new byte[200000]; //200 Kb try { diff -r a35a210e6c0f -r d755f53becea test/jdk/javax/crypto/CipherSpi/CipherByteBufferOverwriteTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/javax/crypto/CipherSpi/CipherByteBufferOverwriteTest.java Fri Jul 12 02:50:43 2019 -0700 @@ -0,0 +1,191 @@ +/* + * Copyright (c) 2019, 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. + */ + +/** + * @test + * @bug 8181386 + * @summary CipherSpi ByteBuffer to byte array conversion fails for + * certain data overlap conditions + * @run main CipherByteBufferOverwriteTest 0 false + * @run main CipherByteBufferOverwriteTest 0 true + * @run main CipherByteBufferOverwriteTest 4 false + * @run main CipherByteBufferOverwriteTest 4 true + */ + +import java.security.spec.AlgorithmParameterSpec; +import javax.crypto.Cipher; +import javax.crypto.SecretKey; +import javax.crypto.spec.IvParameterSpec; +import javax.crypto.spec.SecretKeySpec; +import java.nio.ByteBuffer; +import java.util.Arrays; + +public class CipherByteBufferOverwriteTest { + + private static final boolean DEBUG = false; + + private static final String TRANSFORMATION = "AES/CBC/PKCS5Padding"; + + // must be larger than the temp array size, i.e. 4096, hardcoded in + // javax.crypto.CipherSpi class + private static final int PLAINTEXT_SIZE = 8192; + // leave room for padding + private static final int CIPHERTEXT_BUFFER_SIZE = PLAINTEXT_SIZE + 32; + + private static final SecretKey KEY = new SecretKeySpec(new byte[16], "AES"); + private static final AlgorithmParameterSpec PARAMS = + new IvParameterSpec(new byte[16]); + + private static ByteBuffer inBuf; + private static ByteBuffer outBuf; + + private enum BufferType { + ALLOCATE, DIRECT, WRAP; + } + + public static void main(String[] args) throws Exception { + + int offset = Integer.parseInt(args[0]); + boolean useRO = Boolean.parseBoolean(args[1]); + + // an all-zeros plaintext is the easiest way to demonstrate the issue, + // but it fails with any plaintext, of course + byte[] expectedPT = new byte[PLAINTEXT_SIZE]; + byte[] buf = new byte[offset + CIPHERTEXT_BUFFER_SIZE]; + System.arraycopy(expectedPT, 0, buf, 0, PLAINTEXT_SIZE); + + // generate expected cipher text using byte[] methods + Cipher c = Cipher.getInstance(TRANSFORMATION); + c.init(Cipher.ENCRYPT_MODE, KEY, PARAMS); + byte[] expectedCT = c.doFinal(expectedPT); + + // Test#1: against ByteBuffer generated with allocate(int) call + prepareBuffers(BufferType.ALLOCATE, useRO, buf.length, + buf, 0, PLAINTEXT_SIZE, offset); + + runTest(offset, expectedPT, expectedCT); + System.out.println("\tALLOCATE: passed"); + + // Test#2: against direct ByteBuffer + prepareBuffers(BufferType.DIRECT, useRO, buf.length, + buf, 0, PLAINTEXT_SIZE, offset); + System.out.println("\tDIRECT: passed"); + + runTest(offset, expectedPT, expectedCT); + + // Test#3: against ByteBuffer wrapping existing array + prepareBuffers(BufferType.WRAP, useRO, buf.length, + buf, 0, PLAINTEXT_SIZE, offset); + + runTest(offset, expectedPT, expectedCT); + System.out.println("\tWRAP: passed"); + + System.out.println("All Tests Passed"); + } + + private static void prepareBuffers(BufferType type, + boolean useRO, int bufSz, byte[] in, int inOfs, int inLen, + int outOfs) { + switch (type) { + case ALLOCATE: + outBuf = ByteBuffer.allocate(bufSz); + inBuf = outBuf.slice(); + inBuf.put(in, inOfs, inLen); + inBuf.rewind(); + inBuf.limit(inLen); + outBuf.position(outOfs); + break; + case DIRECT: + outBuf = ByteBuffer.allocateDirect(bufSz); + inBuf = outBuf.slice(); + inBuf.put(in, inOfs, inLen); + inBuf.rewind(); + inBuf.limit(inLen); + outBuf.position(outOfs); + break; + case WRAP: + if (in.length < bufSz) { + throw new RuntimeException("ERROR: Input buffer too small"); + } + outBuf = ByteBuffer.wrap(in); + inBuf = ByteBuffer.wrap(in, inOfs, inLen); + outBuf.position(outOfs); + break; + } + if (useRO) { + inBuf = inBuf.asReadOnlyBuffer(); + } + if (DEBUG) { + System.out.println("inBuf, pos = " + inBuf.position() + + ", capacity = " + inBuf.capacity() + + ", limit = " + inBuf.limit() + + ", remaining = " + inBuf.remaining()); + System.out.println("outBuf, pos = " + outBuf.position() + + ", capacity = " + outBuf.capacity() + + ", limit = " + outBuf.limit() + + ", remaining = " + outBuf.remaining()); + } + } + + private static void runTest(int ofs, byte[] expectedPT, byte[] expectedCT) + throws Exception { + + Cipher c = Cipher.getInstance(TRANSFORMATION); + c.init(Cipher.ENCRYPT_MODE, KEY, PARAMS); + int ciphertextSize = c.doFinal(inBuf, outBuf); + + // read out the encrypted result + outBuf.position(ofs); + byte[] finalCT = new byte[ciphertextSize]; + if (DEBUG) { + System.out.println("runTest, ciphertextSize = " + ciphertextSize); + System.out.println("runTest, ofs = " + ofs + + ", remaining = " + finalCT.length + + ", limit = " + outBuf.limit()); + } + outBuf.get(finalCT); + + if (!Arrays.equals(finalCT, expectedCT)) { + throw new Exception("ERROR: Ciphertext does not match"); + } + + // now do decryption + outBuf.position(ofs); + outBuf.limit(ofs + ciphertextSize); + + c.init(Cipher.DECRYPT_MODE, KEY, PARAMS); + ByteBuffer finalPTBuf = ByteBuffer.allocate( + c.getOutputSize(outBuf.remaining())); + c.doFinal(outBuf, finalPTBuf); + + // read out the decrypted result + finalPTBuf.flip(); + byte[] finalPT = new byte[finalPTBuf.remaining()]; + finalPTBuf.get(finalPT); + + if (!Arrays.equals(finalPT, expectedPT)) { + throw new Exception("ERROR: Plaintext does not match"); + } + } +} + diff -r a35a210e6c0f -r d755f53becea test/jdk/sun/net/www/protocol/file/DirPermissionDenied.java --- a/test/jdk/sun/net/www/protocol/file/DirPermissionDenied.java Thu Jul 11 15:58:54 2019 +0000 +++ b/test/jdk/sun/net/www/protocol/file/DirPermissionDenied.java Fri Jul 12 02:50:43 2019 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2019, 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 @@ -90,8 +90,12 @@ } @AfterTest - public void tearDown() throws IOException { + public void tearDown() throws Throwable { + // add read permission to ensure the dir removable + ProcessTools.executeCommand("chmod", "733", TEST_DIR.toString()) + .outputTo(System.out) + .errorTo(System.out) + .shouldHaveExitValue(0); FileUtils.deleteFileIfExistsWithRetry(TEST_DIR); } } - diff -r a35a210e6c0f -r d755f53becea test/jdk/sun/security/x509/X509CertImpl/ECSigParamsVerifyWithCert.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/sun/security/x509/X509CertImpl/ECSigParamsVerifyWithCert.java Fri Jul 12 02:50:43 2019 -0700 @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2019, 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. + */ + +/* + * @test + * @bug 8225745 + * @summary Ensure ECDSA certificates with signature algorithm parameters + * can be verified successfully + * @run main ECSigParamsVerifyWithCert + */ +import java.io.*; +import java.security.cert.CertificateFactory; +import java.security.cert.X509Certificate; + +public class ECSigParamsVerifyWithCert { + + // ECDSA certificate with non-null signature parameters, i.e. + // Signature Algorithm: SHA256withECDSA, params unparsed, + // OID = 1.2.840.10045.4.3.2 + private static String ecEntityWithSigParamsStr = + "-----BEGIN CERTIFICATE-----\n" + + "MIICXjCCAfmgAwIBAgIIHzREzASpiTowFAYIKoZIzj0EAwIGCCqGSM49AwEHMGAx\n" + + "IzAhBgNVBAMMGkNvcmRhIE5vZGUgSW50ZXJtZWRpYXRlIENBMQswCQYDVQQKDAJS\n" + + "MzEOMAwGA1UECwwFY29yZGExDzANBgNVBAcMBkxvbmRvbjELMAkGA1UEBhMCVUsw\n" + + "HhcNMTgwNjI1MDAwMDAwWhcNMjcwNTIwMDAwMDAwWjAxMQswCQYDVQQGEwJHQjEP\n" + + "MA0GA1UEBwwGTG9uZG9uMREwDwYDVQQKDAhNZWdhQ29ycDBZMBMGByqGSM49AgEG\n" + + "CCqGSM49AwEHA0IABG2VjWPPFnGVka3G9++Sz/GPRkAkht4BDoYTlkRz8hpwr4iu\n" + + "fU6NlReirLOB4LBLZcmp16xm4RYsN5ouTS7Z3wKjgcEwgb4wHQYDVR0OBBYEFBnY\n" + + "sikYpaSL9U8FUygbqN3sIvMOMA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgGG\n" + + "MCMGA1UdJQQcMBoGCCsGAQUFBwMBBggrBgEFBQcDAgYEVR0lADARBgorBgEEAYOK\n" + + "YgEBBAMCAQQwRwYDVR0eAQH/BD0wO6A3MDWkMzAxMQswCQYDVQQGEwJHQjEPMA0G\n" + + "A1UEBwwGTG9uZG9uMREwDwYDVQQKDAhNZWdhQ29ycKEAMBQGCCqGSM49BAMCBggq\n" + + "hkjOPQMBBwNJADBGAiEAos+QzgwwH2hfOtrlLncHnoT2YXXHP4q5h01T2DRmjcMC\n" + + "IQDa3xZz7CkyyNO1+paAthiNVIlGwwnl4UxuYMwkAiWACw==\n" + + "-----END CERTIFICATE-----\n"; + + // ECDSA certificate with only signature algorithm oid, no parameters, i.e. + // Signature Algorithm: SHA256withECDSA, OID = 1.2.840.10045.4.3.2 + private static String ecSigner = + "-----BEGIN CERTIFICATE-----\n" + + "MIICETCCAbigAwIBAgIIaHr3YTnjT8YwCgYIKoZIzj0EAwIwWDEbMBkGA1UEAwwS\n" + + "Q29yZGEgTm9kZSBSb290IENBMQswCQYDVQQKDAJSMzEOMAwGA1UECwwFY29yZGEx\n" + + "DzANBgNVBAcMBkxvbmRvbjELMAkGA1UEBhMCVUswHhcNMTcwNTIyMDAwMDAwWhcN\n" + + "MjcwNTIwMDAwMDAwWjBgMSMwIQYDVQQDDBpDb3JkYSBOb2RlIEludGVybWVkaWF0\n" + + "ZSBDQTELMAkGA1UECgwCUjMxDjAMBgNVBAsMBWNvcmRhMQ8wDQYDVQQHDAZMb25k\n" + + "b24xCzAJBgNVBAYTAlVLMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEA8veoCbh\n" + + "ZmazlyIFWjExBd8ru5OYdFW9Z9ZD5BVg/dswdKC4dlHMHe/sQ4TxFmkYNqf7DTTt\n" + + "ePtdHT7Eb1LGYKNkMGIwHQYDVR0OBBYEFOvuLjAVKUCuGZge2G/jfX8HosITMAsG\n" + + "A1UdDwQEAwIBhjAjBgNVHSUEHDAaBggrBgEFBQcDAQYIKwYBBQUHAwIGBFUdJQAw\n" + + "DwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAgNHADBEAiB6wr47tuC71qi6+FbY\n" + + "XYDTvK+QmAi5ywkFc95I9fPLaQIgIM+nNNQ50NwK610h3bG37XC2tGu+A7Dhtt2Q\n" + + "4nDqu30=\n" + + "-----END CERTIFICATE-----\n"; + + public static void main(String[] args) throws Exception { + CertificateFactory certFactory = CertificateFactory.getInstance("X.509"); + ByteArrayInputStream is + = new ByteArrayInputStream(ecEntityWithSigParamsStr.getBytes()); + X509Certificate ecEntityWithSigParams = (X509Certificate)certFactory.generateCertificate(is); + is = new ByteArrayInputStream(ecSigner.getBytes()); + X509Certificate ecSigner = (X509Certificate)certFactory.generateCertificate(is); + + try { + ecEntityWithSigParams.verify(ecSigner.getPublicKey()); + System.out.println("Test Passed: EC Cert verified"); + } catch (Exception e) { + System.out.println("Failed, cannot verify EC certificate with sig params"); + throw e; + } + } +} diff -r a35a210e6c0f -r d755f53becea test/nashorn/src/jdk/nashorn/internal/runtime/doubleconv/test/BignumDtoaTest.java --- a/test/nashorn/src/jdk/nashorn/internal/runtime/doubleconv/test/BignumDtoaTest.java Thu Jul 11 15:58:54 2019 +0000 +++ b/test/nashorn/src/jdk/nashorn/internal/runtime/doubleconv/test/BignumDtoaTest.java Fri Jul 12 02:50:43 2019 -0700 @@ -69,7 +69,7 @@ import static org.testng.Assert.assertTrue; /** - * FastDtoa tests + * BignumDtoa tests */ @SuppressWarnings("javadoc") public class BignumDtoaTest { @@ -220,6 +220,11 @@ assertEquals(299, buffer.getDecimalPoint()); buffer.reset(); + DoubleConversion.bignumDtoa(1e-23, DtoaMode.SHORTEST, 0, buffer); + assertEquals("1", buffer.getRawDigits()); + assertEquals(-22, buffer.getDecimalPoint()); + buffer.reset(); + final long smallest_normal64 = 0x0010000000000000L; double v = Double.longBitsToDouble(smallest_normal64); DoubleConversion.bignumDtoa(v, DtoaMode.SHORTEST, 0, buffer); diff -r a35a210e6c0f -r d755f53becea test/nashorn/src/jdk/nashorn/internal/runtime/doubleconv/test/FixedDtoaTest.java --- a/test/nashorn/src/jdk/nashorn/internal/runtime/doubleconv/test/FixedDtoaTest.java Thu Jul 11 15:58:54 2019 +0000 +++ b/test/nashorn/src/jdk/nashorn/internal/runtime/doubleconv/test/FixedDtoaTest.java Fri Jul 12 02:50:43 2019 -0700 @@ -624,6 +624,11 @@ assertEquals("1000000000000000128", buffer.getRawDigits()); assertEquals(19, buffer.getDecimalPoint()); buffer.reset(); + + assertTrue(DoubleConversion.fixedDtoa(2.10861548515811875e+15, 17, buffer)); + assertEquals("210861548515811875", buffer.getRawDigits()); + assertEquals(16, buffer.getDecimalPoint()); + buffer.reset(); } diff -r a35a210e6c0f -r d755f53becea test/nashorn/src/jdk/nashorn/internal/runtime/doubleconv/test/IeeeDoubleTest.java --- a/test/nashorn/src/jdk/nashorn/internal/runtime/doubleconv/test/IeeeDoubleTest.java Thu Jul 11 15:58:54 2019 +0000 +++ b/test/nashorn/src/jdk/nashorn/internal/runtime/doubleconv/test/IeeeDoubleTest.java Fri Jul 12 02:50:43 2019 -0700 @@ -41,7 +41,11 @@ import static org.testng.Assert.assertTrue; /** - * Ieee class tests + * IeeeDouble tests + * + * @test + * @modules jdk.scripting.nashorn/jdk.nashorn.internal.runtime.doubleconv:open + * @run testng jdk.nashorn.internal.runtime.doubleconv.test.IeeeDoubleTest */ @SuppressWarnings({"unchecked", "javadoc"}) public class IeeeDoubleTest {