From 9376803a7c001b71598a830826b1d1573342622c Mon Sep 17 00:00:00 2001 From: Poonam Bajaj Date: Mon, 22 Aug 2022 13:45:13 +0000 Subject: [PATCH 01/12] 8175797: (ref) Reference::enqueue method should clear the reference object before enqueuing 8178832: (ref) jdk.lang.ref.disableClearBeforeEnqueue property is ignored 8193780: (ref) Remove the undocumented "jdk.lang.ref.disableClearBeforeEnqueue" system property Reviewed-by: mchung, dholmes, iris, andrew Backport-of: 330d63d2f9e18ba069e11868d4381059c66f480f --- .../classes/java/lang/ref/FinalReference.java | 7 ++- .../classes/java/lang/ref/Reference.java | 8 ++- jdk/test/java/lang/ref/ReferenceEnqueue.java | 52 +++++++++++++++++-- 3 files changed, 58 insertions(+), 9 deletions(-) diff --git a/jdk/src/share/classes/java/lang/ref/FinalReference.java b/jdk/src/share/classes/java/lang/ref/FinalReference.java index d7637943726..bb97d6947a5 100644 --- a/jdk/src/share/classes/java/lang/ref/FinalReference.java +++ b/jdk/src/share/classes/java/lang/ref/FinalReference.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2017, 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 @@ -33,4 +33,9 @@ class FinalReference extends Reference { public FinalReference(T referent, ReferenceQueue q) { super(referent, q); } + + @Override + public boolean enqueue() { + throw new InternalError("should never reach here"); + } } diff --git a/jdk/src/share/classes/java/lang/ref/Reference.java b/jdk/src/share/classes/java/lang/ref/Reference.java index f8fa46f3848..42f14ae6eb7 100644 --- a/jdk/src/share/classes/java/lang/ref/Reference.java +++ b/jdk/src/share/classes/java/lang/ref/Reference.java @@ -265,7 +265,6 @@ public void clear() { this.referent = null; } - /* -- Queue operations -- */ /** @@ -282,8 +281,8 @@ public boolean isEnqueued() { } /** - * Adds this reference object to the queue with which it is registered, - * if any. + * Clears this reference object and adds it to the queue with which + * it is registered, if any. * *

This method is invoked only by Java code; when the garbage collector * enqueues references it does so directly, without invoking this method. @@ -293,10 +292,10 @@ public boolean isEnqueued() { * it was not registered with a queue when it was created */ public boolean enqueue() { + this.referent = null; return this.queue.enqueue(this); } - /* -- Constructors -- */ Reference(T referent) { @@ -307,5 +306,4 @@ public boolean enqueue() { this.referent = referent; this.queue = (queue == null) ? ReferenceQueue.NULL : queue; } - } diff --git a/jdk/test/java/lang/ref/ReferenceEnqueue.java b/jdk/test/java/lang/ref/ReferenceEnqueue.java index 25907a034cc..33f8e27e456 100644 --- a/jdk/test/java/lang/ref/ReferenceEnqueue.java +++ b/jdk/test/java/lang/ref/ReferenceEnqueue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2017, 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 @@ -22,17 +22,22 @@ */ /* @test - * @bug 4268317 + * @bug 4268317 8175797 * @summary Test if Reference.enqueue() works properly with GC + * @run main ReferenceEnqueue */ import java.lang.ref.*; +import java.util.ArrayList; +import java.util.List; public class ReferenceEnqueue { public static void main(String args[]) throws Exception { - for (int i=0; i < 5; i++) + for (int i=0; i < 5; i++) { new WeakRef().run(); + new ExplicitEnqueue().run(); + } System.out.println("Test passed."); } @@ -76,4 +81,45 @@ void run() throws InterruptedException { } } } + + static class ExplicitEnqueue { + final ReferenceQueue queue = new ReferenceQueue<>(); + final List> refs = new ArrayList<>(); + final int iterations = 1000; + + ExplicitEnqueue() { + this.refs.add(new SoftReference<>(new Object(), queue)); + this.refs.add(new WeakReference<>(new Object(), queue)); + // Can't test PhantomReference because get() always returns null. + } + + void run() throws InterruptedException { + for (Reference ref : refs) { + if (ref.enqueue() == false) { + throw new RuntimeException("Error: enqueue failed"); + } + if (ref.get() != null) { + throw new RuntimeException("Error: referent must be cleared"); + } + } + + System.gc(); + for (int i = 0; refs.size() > 0 && i < iterations; i++) { + Reference ref = (Reference)queue.poll(); + if (ref == null) { + System.gc(); + Thread.sleep(100); + continue; + } + + if (refs.remove(ref) == false) { + throw new RuntimeException("Error: unknown reference " + ref); + } + } + + if (!refs.isEmpty()) { + throw new RuntimeException("Error: not all references are removed"); + } + } + } } From 21f65dd1289a58c37e831b47370f7f8c2f1dc92a Mon Sep 17 00:00:00 2001 From: Zdenek Zambersky Date: Mon, 22 Aug 2022 16:10:35 +0000 Subject: [PATCH 02/12] 8183107: PKCS11 regression regarding checkKeySize Changed key size check in PKCS11 provider to only enforce positive return values Reviewed-by: phh, andrew Backport-of: 67ca52873f088a08705baeef3e66319de1600576 --- .../sun/security/pkcs11/P11KeyGenerator.java | 12 ++--- .../security/pkcs11/P11KeyPairGenerator.java | 44 +++++++++---------- .../sun/security/pkcs11/P11Signature.java | 9 ++-- .../pkcs11/wrapper/CK_MECHANISM_INFO.java | 38 +++++++++++++++- 4 files changed, 70 insertions(+), 33 deletions(-) diff --git a/jdk/src/share/classes/sun/security/pkcs11/P11KeyGenerator.java b/jdk/src/share/classes/sun/security/pkcs11/P11KeyGenerator.java index d4e43a577c0..4df62de6db1 100644 --- a/jdk/src/share/classes/sun/security/pkcs11/P11KeyGenerator.java +++ b/jdk/src/share/classes/sun/security/pkcs11/P11KeyGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -119,11 +119,13 @@ static int checkKeySize(long keyGenMech, int keySize, Token token) // RC4 which is in bits. However, some PKCS#11 impls still use // bytes for all mechs, e.g. NSS. We try to detect this // inconsistency if the minKeySize seems unreasonably small. - int minKeySize = (int)info.ulMinKeySize; - int maxKeySize = (int)info.ulMaxKeySize; + int minKeySize = info.iMinKeySize; + int maxKeySize = info.iMaxKeySize; if (keyGenMech != CKM_RC4_KEY_GEN || minKeySize < 8) { - minKeySize = (int)info.ulMinKeySize << 3; - maxKeySize = (int)info.ulMaxKeySize << 3; + minKeySize = Math.multiplyExact(minKeySize, 8); + if (maxKeySize != Integer.MAX_VALUE) { + maxKeySize = Math.multiplyExact(maxKeySize, 8); + } } // Explicitly disallow keys shorter than 40-bits for security if (minKeySize < 40) minKeySize = 40; diff --git a/jdk/src/share/classes/sun/security/pkcs11/P11KeyPairGenerator.java b/jdk/src/share/classes/sun/security/pkcs11/P11KeyPairGenerator.java index 1a71851169d..4c10f3682ca 100644 --- a/jdk/src/share/classes/sun/security/pkcs11/P11KeyPairGenerator.java +++ b/jdk/src/share/classes/sun/security/pkcs11/P11KeyPairGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -73,7 +73,7 @@ final class P11KeyPairGenerator extends KeyPairGeneratorSpi { private BigInteger rsaPublicExponent = RSAKeyGenParameterSpec.F4; // the supported keysize range of the native PKCS11 library - // if the value cannot be retrieved or unspecified, -1 is used. + // if mechanism info is unavailable, 0/Integer.MAX_VALUE is used private final int minKeySize; private final int maxKeySize; @@ -83,13 +83,13 @@ final class P11KeyPairGenerator extends KeyPairGeneratorSpi { P11KeyPairGenerator(Token token, String algorithm, long mechanism) throws PKCS11Exception { super(); - int minKeyLen = -1; - int maxKeyLen = -1; + int minKeyLen = 0; + int maxKeyLen = Integer.MAX_VALUE; try { CK_MECHANISM_INFO mechInfo = token.getMechanismInfo(mechanism); if (mechInfo != null) { - minKeyLen = (int) mechInfo.ulMinKeySize; - maxKeyLen = (int) mechInfo.ulMaxKeySize; + minKeyLen = mechInfo.iMinKeySize; + maxKeyLen = mechInfo.iMaxKeySize; } } catch (PKCS11Exception p11e) { // Should never happen @@ -101,10 +101,10 @@ final class P11KeyPairGenerator extends KeyPairGeneratorSpi { // override upper limit to deter DOS attack if (algorithm.equals("EC")) { keySize = DEF_EC_KEY_SIZE; - if ((minKeyLen == -1) || (minKeyLen < 112)) { + if (minKeyLen < 112) { minKeyLen = 112; } - if ((maxKeyLen == -1) || (maxKeyLen > 2048)) { + if (maxKeyLen > 2048) { maxKeyLen = 2048; } } else { @@ -112,24 +112,22 @@ final class P11KeyPairGenerator extends KeyPairGeneratorSpi { keySize = DEF_DSA_KEY_SIZE; } else if (algorithm.equals("RSA")) { keySize = DEF_RSA_KEY_SIZE; + if (maxKeyLen > 64 * 1024) { + maxKeyLen = 64 * 1024; + } } else { keySize = DEF_DH_KEY_SIZE; } - if ((minKeyLen == -1) || (minKeyLen < 512)) { + if (minKeyLen < 512) { minKeyLen = 512; } - if (algorithm.equals("RSA")) { - if ((maxKeyLen == -1) || (maxKeyLen > 64 * 1024)) { - maxKeyLen = 64 * 1024; - } - } } // auto-adjust default keysize in case it's out-of-range - if ((minKeyLen != -1) && (keySize < minKeyLen)) { + if (keySize < minKeyLen) { keySize = minKeyLen; } - if ((maxKeyLen != -1) && (keySize > maxKeyLen)) { + if (keySize > maxKeyLen) { keySize = maxKeyLen; } this.token = token; @@ -233,13 +231,17 @@ public void initialize(AlgorithmParameterSpec params, SecureRandom random) private void checkKeySize(int keySize, AlgorithmParameterSpec params) throws InvalidAlgorithmParameterException { + if (keySize <= 0) { + throw new InvalidAlgorithmParameterException + ("key size must be positive, got " + keySize); + } // check native range first - if ((minKeySize != -1) && (keySize < minKeySize)) { + if (keySize < minKeySize) { throw new InvalidAlgorithmParameterException(algorithm + " key must be at least " + minKeySize + " bits. " + "The specific key size " + keySize + " is not supported"); } - if ((maxKeySize != -1) && (keySize > maxKeySize)) { + if (keySize > maxKeySize) { throw new InvalidAlgorithmParameterException(algorithm + " key must be at most " + maxKeySize + " bits. " + "The specific key size " + keySize + " is not supported"); @@ -272,12 +274,8 @@ private void checkKeySize(int keySize, AlgorithmParameterSpec params) ((RSAKeyGenParameterSpec)params).getPublicExponent(); } try { - // Reuse the checking in SunRsaSign provider. - // If maxKeySize is -1, then replace it with - // Integer.MAX_VALUE to indicate no limit. RSAKeyFactory.checkKeyLengths(keySize, tmpExponent, - minKeySize, - (maxKeySize==-1? Integer.MAX_VALUE:maxKeySize)); + minKeySize, maxKeySize); } catch (InvalidKeyException e) { throw new InvalidAlgorithmParameterException(e); } diff --git a/jdk/src/share/classes/sun/security/pkcs11/P11Signature.java b/jdk/src/share/classes/sun/security/pkcs11/P11Signature.java index 8eda78a5757..2841ae82eb2 100644 --- a/jdk/src/share/classes/sun/security/pkcs11/P11Signature.java +++ b/jdk/src/share/classes/sun/security/pkcs11/P11Signature.java @@ -370,8 +370,9 @@ private void checkKeySize(String keyAlgo, Key key) // skip the check if no native info available return; } - int minKeySize = (int) mechInfo.ulMinKeySize; - int maxKeySize = (int) mechInfo.ulMaxKeySize; + int minKeySize = mechInfo.iMinKeySize; + int maxKeySize = mechInfo.iMaxKeySize; + // need to override the MAX keysize for SHA1withDSA if (md != null && mechanism == CKM_DSA && maxKeySize > 1024) { maxKeySize = 1024; @@ -395,11 +396,11 @@ private void checkKeySize(String keyAlgo, Key key) " key must be the right type", cce); } } - if ((minKeySize != -1) && (keySize < minKeySize)) { + if (keySize < minKeySize) { throw new InvalidKeyException(keyAlgo + " key must be at least " + minKeySize + " bits"); } - if ((maxKeySize != -1) && (keySize > maxKeySize)) { + if (keySize > maxKeySize) { throw new InvalidKeyException(keyAlgo + " key must be at most " + maxKeySize + " bits"); } diff --git a/jdk/src/share/classes/sun/security/pkcs11/wrapper/CK_MECHANISM_INFO.java b/jdk/src/share/classes/sun/security/pkcs11/wrapper/CK_MECHANISM_INFO.java index 72018721966..5f0f31541a1 100644 --- a/jdk/src/share/classes/sun/security/pkcs11/wrapper/CK_MECHANISM_INFO.java +++ b/jdk/src/share/classes/sun/security/pkcs11/wrapper/CK_MECHANISM_INFO.java @@ -1,3 +1,27 @@ +/* + * 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ /* * reserved comment block * DO NOT REMOVE OR ALTER! @@ -47,7 +71,7 @@ package sun.security.pkcs11.wrapper; - +import java.security.ProviderException; /** * class CK_MECHANISM_INFO provides information about a particular mechanism. @@ -74,6 +98,10 @@ public class CK_MECHANISM_INFO { */ public long ulMinKeySize; + // the integer version of ulMinKeySize for doing the actual range + // check in SunPKCS11 provider, defaults to 0 + public final int iMinKeySize; + /** * PKCS#11: *
@@ -82,6 +110,10 @@ public class CK_MECHANISM_INFO {
      */
     public long ulMaxKeySize;
 
+    // the integer version of ulMaxKeySize for doing the actual range
+    // check in SunPKCS11 provider, defaults to Integer.MAX_VALUE
+    public final int iMaxKeySize;
+
     /**
      * PKCS#11:
      * 
@@ -94,6 +126,10 @@ public CK_MECHANISM_INFO(long minKeySize, long maxKeySize,
                              long flags) {
         this.ulMinKeySize = minKeySize;
         this.ulMaxKeySize = maxKeySize;
+        this.iMinKeySize = ((minKeySize < Integer.MAX_VALUE && minKeySize > 0)?
+                (int)minKeySize : 0);
+        this.iMaxKeySize = ((maxKeySize < Integer.MAX_VALUE && maxKeySize > 0)?
+                (int)maxKeySize : Integer.MAX_VALUE);
         this.flags = flags;
     }
 

From 9436b68a1e73cae8d441686549deb858449dec76 Mon Sep 17 00:00:00 2001
From: Poonam Bajaj 
Date: Mon, 22 Aug 2022 19:53:40 +0000
Subject: [PATCH 03/12] 8201793: (ref) Reference object should not support
 cloning

Reviewed-by: mchung, iris, andrew
Backport-of: 58ec25de2f383144417eb000efacecb78b30395c
---
 .../classes/java/lang/ref/Reference.java      |  17 +++
 jdk/test/java/lang/ref/ReferenceClone.java    | 104 ++++++++++++++++++
 2 files changed, 121 insertions(+)
 create mode 100644 jdk/test/java/lang/ref/ReferenceClone.java

diff --git a/jdk/src/share/classes/java/lang/ref/Reference.java b/jdk/src/share/classes/java/lang/ref/Reference.java
index 42f14ae6eb7..17435fe0b49 100644
--- a/jdk/src/share/classes/java/lang/ref/Reference.java
+++ b/jdk/src/share/classes/java/lang/ref/Reference.java
@@ -296,6 +296,23 @@ public boolean enqueue() {
         return this.queue.enqueue(this);
     }
 
+
+    /**
+     * Throws {@link CloneNotSupportedException}. A {@code Reference} cannot be
+     * meaningfully cloned. Construct a new {@code Reference} instead.
+     *
+     * @apiNote This method is defined in Java SE 8 Maintenance Release 4.
+     *
+     * @return  never returns normally
+     * @throws  CloneNotSupportedException always
+     *
+     * @since 8
+     */
+    @Override
+    protected Object clone() throws CloneNotSupportedException {
+        throw new CloneNotSupportedException();
+    }
+
     /* -- Constructors -- */
 
     Reference(T referent) {
diff --git a/jdk/test/java/lang/ref/ReferenceClone.java b/jdk/test/java/lang/ref/ReferenceClone.java
new file mode 100644
index 00000000000..bd1ead81bec
--- /dev/null
+++ b/jdk/test/java/lang/ref/ReferenceClone.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2018, 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 8201793
+ * @summary Test Reference::clone to throw CloneNotSupportedException
+ */
+
+import java.lang.ref.*;
+
+public class ReferenceClone {
+    private static final ReferenceQueue QUEUE = new ReferenceQueue<>();
+    public static void main(String... args) {
+        ReferenceClone refClone = new ReferenceClone();
+        refClone.test();
+    }
+
+    public void test() {
+        // test Reference::clone that throws CNSE
+        Object o = new Object();
+        assertCloneNotSupported(new SoftRef(o));
+        assertCloneNotSupported(new WeakRef(o));
+        assertCloneNotSupported(new PhantomRef(o));
+
+        // Reference subclass may override the clone method
+        CloneableReference ref = new CloneableReference(o);
+        try {
+            ref.clone();
+        } catch (CloneNotSupportedException e) {}
+    }
+
+    private void assertCloneNotSupported(CloneableRef ref) {
+        try {
+            ref.clone();
+            throw new RuntimeException("Reference::clone should throw CloneNotSupportedException");
+        } catch (CloneNotSupportedException e) {}
+    }
+
+    // override clone to be public that throws CNSE
+    interface CloneableRef extends Cloneable {
+        public Object clone() throws CloneNotSupportedException;
+    }
+
+    class SoftRef extends SoftReference implements CloneableRef {
+        public SoftRef(Object referent) {
+            super(referent, QUEUE);
+        }
+        public Object clone() throws CloneNotSupportedException {
+            return super.clone();
+        }
+    }
+
+    class WeakRef extends WeakReference implements CloneableRef {
+        public WeakRef(Object referent) {
+            super(referent, QUEUE);
+        }
+        public Object clone() throws CloneNotSupportedException {
+            return super.clone();
+        }
+    }
+
+    class PhantomRef extends PhantomReference implements CloneableRef {
+        public PhantomRef(Object referent) {
+            super(referent, QUEUE);
+        }
+
+        public Object clone() throws CloneNotSupportedException {
+            return super.clone();
+        }
+    }
+
+    // override clone to return a new instance
+    class CloneableReference extends WeakReference implements Cloneable {
+        public CloneableReference(Object referent) {
+            super(referent, QUEUE);
+        }
+
+        public Object clone() throws CloneNotSupportedException {
+            return new CloneableReference(this.get());
+        }
+    }
+
+}

From c4ce7060e995b8a82ad21210b74d0eaa22da175b Mon Sep 17 00:00:00 2001
From: Poonam Bajaj 
Date: Mon, 22 Aug 2022 20:06:41 +0000
Subject: [PATCH 04/12] 8285400: Add '@apiNote' to the APIs defined in Java SE
 8 MR 3

Reviewed-by: mchung, iris, andrew
Backport-of: 3740d05c063e1f80a0808a969a2cc136cafa48cb
---
 jdk/src/share/classes/java/security/Signature.java        | 4 +---
 .../share/classes/java/security/interfaces/RSAKey.java    | 3 ++-
 .../classes/java/security/spec/MGF1ParameterSpec.java     | 8 +++++++-
 .../classes/java/security/spec/PSSParameterSpec.java      | 3 ++-
 .../java/security/spec/RSAKeyGenParameterSpec.java        | 4 +++-
 .../security/spec/RSAMultiPrimePrivateCrtKeySpec.java     | 3 ++-
 .../classes/java/security/spec/RSAPrivateCrtKeySpec.java  | 3 ++-
 .../classes/java/security/spec/RSAPrivateKeySpec.java     | 4 +++-
 .../classes/java/security/spec/RSAPublicKeySpec.java      | 4 +++-
 jdk/src/share/classes/javax/net/ssl/SSLEngine.java        | 8 ++++++--
 jdk/src/share/classes/javax/net/ssl/SSLParameters.java    | 4 +++-
 jdk/src/share/classes/javax/net/ssl/SSLSocket.java        | 8 ++++++--
 12 files changed, 40 insertions(+), 16 deletions(-)

diff --git a/jdk/src/share/classes/java/security/Signature.java b/jdk/src/share/classes/java/security/Signature.java
index 8d8408c492b..2edd63a6121 100644
--- a/jdk/src/share/classes/java/security/Signature.java
+++ b/jdk/src/share/classes/java/security/Signature.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -591,8 +591,6 @@ public final void initVerify(Certificate certificate)
      * is not encoded properly or does not include required  parameter
      * information or cannot be used for digital signature purposes.
      * @exception InvalidAlgorithmParameterException if the params is invalid.
-     *
-     * @since 8
      */
     final void initVerify(Certificate certificate,
             AlgorithmParameterSpec params)
diff --git a/jdk/src/share/classes/java/security/interfaces/RSAKey.java b/jdk/src/share/classes/java/security/interfaces/RSAKey.java
index 5703d669d65..6021b189717 100644
--- a/jdk/src/share/classes/java/security/interfaces/RSAKey.java
+++ b/jdk/src/share/classes/java/security/interfaces/RSAKey.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -56,6 +56,7 @@ public interface RSAKey {
      * explicitly specified or implicitly created during
      * key pair generation.
      *
+     * @apiNote This method is defined in Java SE 8 Maintenance Release 3.
      * @implSpec
      * The default implementation returns {@code null}.
      *
diff --git a/jdk/src/share/classes/java/security/spec/MGF1ParameterSpec.java b/jdk/src/share/classes/java/security/spec/MGF1ParameterSpec.java
index 3821b84b5c0..313c36c318e 100644
--- a/jdk/src/share/classes/java/security/spec/MGF1ParameterSpec.java
+++ b/jdk/src/share/classes/java/security/spec/MGF1ParameterSpec.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -98,12 +98,18 @@ public class MGF1ParameterSpec implements AlgorithmParameterSpec {
 
     /**
      * The MGF1ParameterSpec which uses SHA-512/224 message digest
+     *
+     * @apiNote This field is defined in Java SE 8 Maintenance Release 3.
+     * @since 8
      */
     public static final MGF1ParameterSpec SHA512_224 =
         new MGF1ParameterSpec("SHA-512/224");
 
     /**
      * The MGF1ParameterSpec which uses SHA-512/256 message digest
+     *
+     * @apiNote This field is defined in Java SE 8 Maintenance Release 3.
+     * @since 8
      */
     public static final MGF1ParameterSpec SHA512_256 =
         new MGF1ParameterSpec("SHA-512/256");
diff --git a/jdk/src/share/classes/java/security/spec/PSSParameterSpec.java b/jdk/src/share/classes/java/security/spec/PSSParameterSpec.java
index 7e725d75905..e608886b0ac 100644
--- a/jdk/src/share/classes/java/security/spec/PSSParameterSpec.java
+++ b/jdk/src/share/classes/java/security/spec/PSSParameterSpec.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -96,6 +96,7 @@ public class PSSParameterSpec implements AlgorithmParameterSpec {
     /**
      * The {@code TrailerFieldBC} constant as defined in PKCS#1
      *
+     * @apiNote This field is defined in Java SE 8 Maintenance Release 3.
      * @since 8
      */
     public static final int TRAILER_FIELD_BC = 1;
diff --git a/jdk/src/share/classes/java/security/spec/RSAKeyGenParameterSpec.java b/jdk/src/share/classes/java/security/spec/RSAKeyGenParameterSpec.java
index 014af6fe35c..56afac6e8ae 100644
--- a/jdk/src/share/classes/java/security/spec/RSAKeyGenParameterSpec.java
+++ b/jdk/src/share/classes/java/security/spec/RSAKeyGenParameterSpec.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -70,6 +70,7 @@ public RSAKeyGenParameterSpec(int keysize, BigInteger publicExponent) {
      * Constructs a new {@code RSAKeyGenParameterSpec} object from the
      * given keysize, public-exponent value, and key parameters.
      *
+     * @apiNote This method is defined in Java SE 8 Maintenance Release 3.
      * @param keysize the modulus size (specified in number of bits)
      * @param publicExponent the public exponent
      * @param keyParams the key parameters, may be null
@@ -103,6 +104,7 @@ public BigInteger getPublicExponent() {
     /**
      * Returns the parameters to be associated with key.
      *
+     * @apiNote This method is defined in Java SE 8 Maintenance Release 3.
      * @return the associated parameters, may be null if
      *         not present
      * @since 8
diff --git a/jdk/src/share/classes/java/security/spec/RSAMultiPrimePrivateCrtKeySpec.java b/jdk/src/share/classes/java/security/spec/RSAMultiPrimePrivateCrtKeySpec.java
index f7bd8832a98..14ca2aa087f 100644
--- a/jdk/src/share/classes/java/security/spec/RSAMultiPrimePrivateCrtKeySpec.java
+++ b/jdk/src/share/classes/java/security/spec/RSAMultiPrimePrivateCrtKeySpec.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -104,6 +104,7 @@ public RSAMultiPrimePrivateCrtKeySpec(BigInteger modulus,
     * are copied to protect against subsequent modification when
     * constructing this object.
     *
+    * @apiNote This method is defined in Java SE 8 Maintenance Release 3.
     * @param modulus          the modulus n
     * @param publicExponent   the public exponent e
     * @param privateExponent  the private exponent d
diff --git a/jdk/src/share/classes/java/security/spec/RSAPrivateCrtKeySpec.java b/jdk/src/share/classes/java/security/spec/RSAPrivateCrtKeySpec.java
index f4d618b3842..636c41ef02d 100644
--- a/jdk/src/share/classes/java/security/spec/RSAPrivateCrtKeySpec.java
+++ b/jdk/src/share/classes/java/security/spec/RSAPrivateCrtKeySpec.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -81,6 +81,7 @@ public RSAPrivateCrtKeySpec(BigInteger modulus,
     * Creates a new {@code RSAPrivateCrtKeySpec} with additional
     * key parameters.
     *
+    * @apiNote This method is defined in Java SE 8 Maintenance Release 3.
     * @param modulus the modulus n
     * @param publicExponent the public exponent e
     * @param privateExponent the private exponent d
diff --git a/jdk/src/share/classes/java/security/spec/RSAPrivateKeySpec.java b/jdk/src/share/classes/java/security/spec/RSAPrivateKeySpec.java
index 2bb06c58688..f0d76620102 100644
--- a/jdk/src/share/classes/java/security/spec/RSAPrivateKeySpec.java
+++ b/jdk/src/share/classes/java/security/spec/RSAPrivateKeySpec.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -60,6 +60,7 @@ public RSAPrivateKeySpec(BigInteger modulus, BigInteger privateExponent) {
     /**
      * Creates a new RSAPrivateKeySpec with additional key parameters.
      *
+     * @apiNote This method is defined in Java SE 8 Maintenance Release 3.
      * @param modulus the modulus
      * @param privateExponent the private exponent
      * @param params the parameters associated with this key, may be null
@@ -94,6 +95,7 @@ public BigInteger getPrivateExponent() {
      * Returns the parameters associated with this key, may be null if not
      * present.
      *
+     * @apiNote This method is defined in Java SE 8 Maintenance Release 3.
      * @return the parameters associated with this key
      * @since 8
      */
diff --git a/jdk/src/share/classes/java/security/spec/RSAPublicKeySpec.java b/jdk/src/share/classes/java/security/spec/RSAPublicKeySpec.java
index b9ab2246227..7f7bad3c3e4 100644
--- a/jdk/src/share/classes/java/security/spec/RSAPublicKeySpec.java
+++ b/jdk/src/share/classes/java/security/spec/RSAPublicKeySpec.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -60,6 +60,7 @@ public RSAPublicKeySpec(BigInteger modulus, BigInteger publicExponent) {
     /**
      * Creates a new RSAPublicKeySpec with additional key parameters.
      *
+     * @apiNote This method is defined in Java SE 8 Maintenance Release 3.
      * @param modulus the modulus
      * @param publicExponent the public exponent
      * @param params the parameters associated with this key, may be null
@@ -95,6 +96,7 @@ public BigInteger getPublicExponent() {
      * Returns the parameters associated with this key, may be null if not
      * present.
      *
+     * @apiNote This method is defined in Java SE 8 Maintenance Release 3.
      * @return the parameters associated with this key
      * @since 8
      */
diff --git a/jdk/src/share/classes/javax/net/ssl/SSLEngine.java b/jdk/src/share/classes/javax/net/ssl/SSLEngine.java
index c7ae0433832..56961cda9d3 100644
--- a/jdk/src/share/classes/javax/net/ssl/SSLEngine.java
+++ b/jdk/src/share/classes/javax/net/ssl/SSLEngine.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1265,6 +1265,7 @@ public void setSSLParameters(SSLParameters params) {
      * Application-Layer Protocol Negotiation (ALPN), can negotiate
      * application-level values between peers.
      *
+     * @apiNote This method is defined in Java SE 8 Maintenance Release 3.
      * @implSpec
      * The implementation in this class throws
      * {@code UnsupportedOperationException} and performs no other action.
@@ -1290,6 +1291,7 @@ public String getApplicationProtocol() {
      * a connection may be in the middle of a handshake. The
      * application protocol may or may not yet be available.
      *
+     * @apiNote This method is defined in Java SE 8 Maintenance Release 3.
      * @implSpec
      * The implementation in this class throws
      * {@code UnsupportedOperationException} and performs no other action.
@@ -1350,7 +1352,8 @@ public String getHandshakeApplicationProtocol() {
      *         });
      * }
      *
-     * @apiNote
+     * @apiNote This method is defined in Java SE 8 Maintenance Release 3.
+     * 

* This method should be called by TLS server applications before the TLS * handshake begins. Also, this {@code SSLEngine} should be configured with * parameters that are compatible with the application protocol selected by @@ -1380,6 +1383,7 @@ public void setHandshakeApplicationProtocolSelector( * setHandshakeApplicationProtocolSelector} * for the function's type parameters. * + * @apiNote This method is defined in Java SE 8 Maintenance Release 3. * @implSpec * The implementation in this class throws * {@code UnsupportedOperationException} and performs no other action. diff --git a/jdk/src/share/classes/javax/net/ssl/SSLParameters.java b/jdk/src/share/classes/javax/net/ssl/SSLParameters.java index c3244c10108..d213558e8b4 100644 --- a/jdk/src/share/classes/javax/net/ssl/SSLParameters.java +++ b/jdk/src/share/classes/javax/net/ssl/SSLParameters.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -486,6 +486,7 @@ public final boolean getUseCipherSuitesOrder() { *

* This method will return a new array each time it is invoked. * + * @apiNote This method is defined in Java SE 8 Maintenance Release 3. * @return a non-null, possibly zero-length array of application protocol * {@code String}s. The array is ordered based on protocol * preference, with {@code protocols[0]} being the most preferred. @@ -518,6 +519,7 @@ public String[] getApplicationProtocols() { * action to take. (For example, ALPN will send a * {@code "no_application_protocol"} alert and terminate the connection.) * + * @apiNote This method is defined in Java SE 8 Maintenance Release 3. * @implSpec * This method will make a copy of the {@code protocols} array. * diff --git a/jdk/src/share/classes/javax/net/ssl/SSLSocket.java b/jdk/src/share/classes/javax/net/ssl/SSLSocket.java index 7de96c24eac..7ecd47c835d 100644 --- a/jdk/src/share/classes/javax/net/ssl/SSLSocket.java +++ b/jdk/src/share/classes/javax/net/ssl/SSLSocket.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -674,6 +674,7 @@ public void setSSLParameters(SSLParameters params) { * Application-Layer Protocol Negotiation (ALPN), can negotiate * application-level values between peers. * + * @apiNote This method is defined in Java SE 8 Maintenance Release 3. * @implSpec * The implementation in this class throws * {@code UnsupportedOperationException} and performs no other action. @@ -699,6 +700,7 @@ public String getApplicationProtocol() { * a connection may be in the middle of a handshake. The * application protocol may or may not yet be available. * + * @apiNote This method is defined in Java SE 8 Maintenance Release 3. * @implSpec * The implementation in this class throws * {@code UnsupportedOperationException} and performs no other action. @@ -760,7 +762,8 @@ public String getHandshakeApplicationProtocol() { * }); * } * - * @apiNote + * @apiNote This method is defined in Java SE 8 Maintenance Release 3. + *

* This method should be called by TLS server applications before the TLS * handshake begins. Also, this {@code SSLSocket} should be configured with * parameters that are compatible with the application protocol selected by @@ -789,6 +792,7 @@ public void setHandshakeApplicationProtocolSelector( * setHandshakeApplicationProtocolSelector} * for the function's type parameters. * + * @apiNote This method is defined in Java SE 8 Maintenance Release 3. * @implSpec * The implementation in this class throws * {@code UnsupportedOperationException} and performs no other action. From 78e6dc24439956df79246d86f969ae2b676934fa Mon Sep 17 00:00:00 2001 From: Zdenek Zambersky Date: Wed, 24 Aug 2022 17:33:44 +0000 Subject: [PATCH 05/12] 8039955: [TESTBUG] jdk/lambda/LambdaTranslationTest1 - java.lang.AssertionError: expected [d:1234.000000] but found [d:1234,000000] Backport-of: 3555038f51fbf7f908b7346a8329f4da44a7cde5 --- jdk/test/jdk/lambda/LambdaTranslationTest1.java | 4 ++-- jdk/test/jdk/lambda/LambdaTranslationTest2.java | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/jdk/test/jdk/lambda/LambdaTranslationTest1.java b/jdk/test/jdk/lambda/LambdaTranslationTest1.java index 28ad3b6e2ed..4f3c44862f3 100644 --- a/jdk/test/jdk/lambda/LambdaTranslationTest1.java +++ b/jdk/test/jdk/lambda/LambdaTranslationTest1.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, 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 @@ -137,7 +137,7 @@ public void testMethodRefs() { LT1IA da = LambdaTranslationTest1::deye; da.doit(1234); - assertResult("d:1234.000000"); + assertResult(String.format("d:%f", 1234.0)); LT1SA a = LambdaTranslationTest1::count; assertEquals((Integer) 5, a.doit("howdy")); diff --git a/jdk/test/jdk/lambda/LambdaTranslationTest2.java b/jdk/test/jdk/lambda/LambdaTranslationTest2.java index 4b1c8a1f5fa..55f6d5b69c5 100644 --- a/jdk/test/jdk/lambda/LambdaTranslationTest2.java +++ b/jdk/test/jdk/lambda/LambdaTranslationTest2.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, 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 @@ -200,7 +200,7 @@ public void testPrimitiveWidening() { assertEquals("b1 s2", ws1.m((byte) 1, (short) 2)); WidenD wd1 = LambdaTranslationTest2::pwD1; - assertEquals("f1.000000 d2.000000", wd1.m(1.0f, 2.0)); + assertEquals(String.format("f%f d%f", 1.0f, 2.0), wd1.m(1.0f, 2.0)); WidenI wi1 = LambdaTranslationTest2::pwI1; assertEquals("b1 s2 c3 i4", wi1.m((byte) 1, (short) 2, (char) 3, 4)); @@ -221,12 +221,16 @@ static String pu(byte a0, short a1, char a2, int a3, long a4, boolean a5, float public void testUnboxing() { Unbox u = LambdaTranslationTest2::pu; - assertEquals("b1 s2 cA i4 j5 ztrue f6.000000 d7.000000", u.m((byte)1, (short) 2, 'A', 4, 5L, true, 6.0f, 7.0)); + String expected = String.format("b%d s%d c%c i%d j%d z%b f%f d%f", + (byte)1, (short) 2, 'A', 4, 5L, true, 6.0f, 7.0); + assertEquals(expected, u.m((byte)1, (short) 2, 'A', 4, 5L, true, 6.0f, 7.0)); } public void testBoxing() { Box b = LambdaTranslationTest2::pb; - assertEquals("b1 s2 cA i4 j5 ztrue f6.000000 d7.000000", b.m((byte) 1, (short) 2, 'A', 4, 5L, true, 6.0f, 7.0)); + String expected = String.format("b%d s%d c%c i%d j%d z%b f%f d%f", + (byte) 1, (short) 2, 'A', 4, 5L, true, 6.0f, 7.0); + assertEquals(expected, b.m((byte) 1, (short) 2, 'A', 4, 5L, true, 6.0f, 7.0)); } static boolean cc(Object o) { From a87e397aae6c5de199c3c8413015ee57a77ee4cf Mon Sep 17 00:00:00 2001 From: Zdenek Zambersky Date: Wed, 24 Aug 2022 17:44:49 +0000 Subject: [PATCH 06/12] 8232950: SUNPKCS11 Provider incorrectly check key length for PSS Signatures. Fixed to treat the queried key size values as bits instead of bytes Reviewed-by: andrew Backport-of: f14e3a60b26f0488da26abf3ae6c0521d5f616e5 --- .../sun/security/pkcs11/P11PSSSignature.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/jdk/src/share/classes/sun/security/pkcs11/P11PSSSignature.java b/jdk/src/share/classes/sun/security/pkcs11/P11PSSSignature.java index abdbd3bd488..4391adfc737 100644 --- a/jdk/src/share/classes/sun/security/pkcs11/P11PSSSignature.java +++ b/jdk/src/share/classes/sun/security/pkcs11/P11PSSSignature.java @@ -341,9 +341,6 @@ private void checkKeySize(Key key) throws InvalidKeyException { int keySize = 0; // in bytes if (mechInfo != null) { - // check against available native info - int minKeySize = (int) mechInfo.ulMinKeySize; - int maxKeySize = (int) mechInfo.ulMaxKeySize; if (key instanceof P11Key) { keySize = (((P11Key) key).length() + 7) >> 3; } else if (key instanceof RSAKey) { @@ -351,13 +348,16 @@ private void checkKeySize(Key key) throws InvalidKeyException { } else { throw new InvalidKeyException("Unrecognized key type " + key); } - if ((minKeySize != -1) && (keySize < minKeySize)) { + // check against available native info which are in bits + if ((mechInfo.iMinKeySize != 0) && + (keySize < (mechInfo.iMinKeySize >> 3))) { throw new InvalidKeyException(KEY_ALGO + - " key must be at least " + minKeySize + " bytes"); + " key must be at least " + mechInfo.iMinKeySize + " bits"); } - if ((maxKeySize != -1) && (keySize > maxKeySize)) { + if ((mechInfo.iMaxKeySize != Integer.MAX_VALUE) && + (keySize > (mechInfo.iMaxKeySize >> 3))) { throw new InvalidKeyException(KEY_ALGO + - " key must be at most " + maxKeySize + " bytes"); + " key must be at most " + mechInfo.iMaxKeySize + " bits"); } } if (this.sigParams != null) { From df84c26757ec70ef67fd94d1cfacd77f1b4c302f Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Wed, 24 Aug 2022 19:35:29 +0000 Subject: [PATCH 07/12] 8285497: Add system property for Java SE specification maintenance version Reviewed-by: dholmes, iris, mchung, andrew Backport-of: 31a63ba5f255e09349b3842984ac5bb3ad8e6c0b --- jdk/src/share/classes/java/lang/System.java | 16 +++++++++++++++- .../sun/security/provider/PolicyFile.java | 5 ++++- jdk/src/share/lib/security/java.policy | 1 + jdk/src/share/native/java/lang/System.c | 4 +++- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/jdk/src/share/classes/java/lang/System.java b/jdk/src/share/classes/java/lang/System.java index 5b2b3205578..33ee5ab4879 100644 --- a/jdk/src/share/classes/java/lang/System.java +++ b/jdk/src/share/classes/java/lang/System.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -559,6 +559,10 @@ public static native void arraycopy(Object src, int srcPos, * Java installation directory * java.vm.specification.version * Java Virtual Machine specification version + * java.specification.maintenance.version + * Java Runtime Environment specification maintenance + * version, may be interpreted as a positive integer + * (optional, see below) * java.vm.specification.vendor * Java Virtual Machine specification vendor * java.vm.specification.name @@ -610,6 +614,16 @@ public static native void arraycopy(Object src, int srcPos, * User's current working directory * *

+ * The {@code java.specification.maintenance.version} property is + * defined if the specification implemented by this runtime at the + * time of its construction had undergone a maintenance + * release. When defined, its value identifies that + * maintenance release. To indicate the first maintenance release + * this property will have the value {@code "1"}, to indicate the + * second maintenance release this property will have the value + * {@code "2"}, and so on. + *

* Multiple paths in a system property value are separated by the path * separator character of the platform. *

diff --git a/jdk/src/share/classes/sun/security/provider/PolicyFile.java b/jdk/src/share/classes/sun/security/provider/PolicyFile.java index 5ed375c4870..097451da742 100644 --- a/jdk/src/share/classes/sun/security/provider/PolicyFile.java +++ b/jdk/src/share/classes/sun/security/provider/PolicyFile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -686,6 +686,9 @@ public Void run() { pe.add(new PropertyPermission ("java.specification.version", SecurityConstants.PROPERTY_READ_ACTION)); + pe.add(new PropertyPermission + ("java.specification.maintenance.version", + SecurityConstants.PROPERTY_READ_ACTION)); pe.add(new PropertyPermission ("java.specification.vendor", SecurityConstants.PROPERTY_READ_ACTION)); diff --git a/jdk/src/share/lib/security/java.policy b/jdk/src/share/lib/security/java.policy index 59d99a964c4..8b628972008 100644 --- a/jdk/src/share/lib/security/java.policy +++ b/jdk/src/share/lib/security/java.policy @@ -36,6 +36,7 @@ grant { permission java.util.PropertyPermission "line.separator", "read"; permission java.util.PropertyPermission "java.specification.version", "read"; + permission java.util.PropertyPermission "java.specification.maintenance.version", "read"; permission java.util.PropertyPermission "java.specification.vendor", "read"; permission java.util.PropertyPermission "java.specification.name", "read"; diff --git a/jdk/src/share/native/java/lang/System.c b/jdk/src/share/native/java/lang/System.c index ff80b0abdd6..85dbe575cb1 100644 --- a/jdk/src/share/native/java/lang/System.c +++ b/jdk/src/share/native/java/lang/System.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -214,6 +214,8 @@ Java_java_lang_System_initProperties(JNIEnv *env, jclass cla, jobject props) PUTPROP(props, "java.specification.version", JDK_MAJOR_VERSION "." JDK_MINOR_VERSION); + PUTPROP(props, "java.specification.maintenance.version", + "4"); PUTPROP(props, "java.specification.name", "Java Platform API Specification"); PUTPROP(props, "java.specification.vendor", From 96bed26602e025423beaf5510bed2fc22cd111b8 Mon Sep 17 00:00:00 2001 From: Peter Levart Date: Fri, 26 Aug 2022 12:25:37 +0000 Subject: [PATCH 08/12] 8049228: Improve multithreaded scalability of InetAddress cache 7186258: InetAddress$Cache should replace currentTimeMillis with nanoTime for more precise and accurate Reviewed-by: andrew, phh Backport-of: 250fbb065a789a303d692d698c9b69117bf6cd2c --- .../share/classes/java/net/InetAddress.java | 575 ++++++++---------- .../sun/net/InetAddressCachePolicy.java | 25 +- 2 files changed, 249 insertions(+), 351 deletions(-) diff --git a/jdk/src/share/classes/java/net/InetAddress.java b/jdk/src/share/classes/java/net/InetAddress.java index 79a3c4b99ac..eebd8ef4b2b 100644 --- a/jdk/src/share/classes/java/net/InetAddress.java +++ b/jdk/src/share/classes/java/net/InetAddress.java @@ -25,11 +25,8 @@ package java.net; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.Random; +import java.util.NavigableSet; import java.util.Iterator; -import java.util.LinkedList; import java.util.List; import java.util.ArrayList; import java.util.ServiceLoader; @@ -42,6 +39,11 @@ import java.io.ObjectInputStream.GetField; import java.io.ObjectOutputStream; import java.io.ObjectOutputStream.PutField; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.ConcurrentSkipListSet; +import java.util.concurrent.atomic.AtomicLong; + import sun.security.action.*; import sun.net.InetAddressCachePolicy; import sun.net.util.IPAddressUtil; @@ -727,194 +729,129 @@ public String toString() { + "/" + getHostAddress(); } - /* - * Cached addresses - our own litle nis, not! - */ - private static Cache addressCache = new Cache(Cache.Type.Positive); - - private static Cache negativeCache = new Cache(Cache.Type.Negative); - - private static boolean addressCacheInit = false; + // mapping from host name to Addresses - either NameServiceAddresses (while + // still being looked-up by NameService(s)) or CachedAddresses when cached + private static final ConcurrentMap cache = + new ConcurrentHashMap<>(); - static InetAddress[] unknown_array; // put THIS in cache + // CachedAddresses that have to expire are kept ordered in this NavigableSet + // which is scanned on each access + private static final NavigableSet expirySet = + new ConcurrentSkipListSet<>(); - static InetAddressImpl impl; - - private static final HashMap lookupTable = new HashMap<>(); - - /** - * Represents a cache entry - */ - static final class CacheEntry { - - CacheEntry(InetAddress[] addresses, long expiration) { - this.addresses = addresses; - this.expiration = expiration; - } - - InetAddress[] addresses; - long expiration; + // common interface + private interface Addresses { + InetAddress[] get() throws UnknownHostException; } - /** - * A cache that manages entries based on a policy specified - * at creation time. - */ - static final class Cache { - private LinkedHashMap cache; - private Type type; - - enum Type {Positive, Negative}; - - /** - * Create cache - */ - public Cache(Type type) { - this.type = type; - cache = new LinkedHashMap(); + // a holder for cached addresses with required metadata + private static final class CachedAddresses implements Addresses, Comparable { + private static final AtomicLong seq = new AtomicLong(); + final String host; + final InetAddress[] inetAddresses; + final long expiryTime; // time of expiry (in terms of System.nanoTime()) + final long id = seq.incrementAndGet(); // each instance is unique + + CachedAddresses(String host, InetAddress[] inetAddresses, long expiryTime) { + this.host = host; + this.inetAddresses = inetAddresses; + this.expiryTime = expiryTime; } - private int getPolicy() { - if (type == Type.Positive) { - return InetAddressCachePolicy.get(); - } else { - return InetAddressCachePolicy.getNegative(); + @Override + public InetAddress[] get() throws UnknownHostException { + if (inetAddresses == null) { + throw new UnknownHostException(host); } + return inetAddresses; } - /** - * Add an entry to the cache. If there's already an - * entry then for this host then the entry will be - * replaced. - */ - public Cache put(String host, InetAddress[] addresses) { - int policy = getPolicy(); - if (policy == InetAddressCachePolicy.NEVER) { - return this; - } - - // purge any expired entries + @Override + public int compareTo(CachedAddresses other) { + // natural order is expiry time - + // compare difference of expiry times rather than + // expiry times directly, to avoid possible overflow. + // (see System.nanoTime() recommendations...) + long diff = this.expiryTime - other.expiryTime; + if (diff < 0L) return -1; + if (diff > 0L) return 1; + // ties are broken using unique id + return Long.compare(this.id, other.id); + } + } - if (policy != InetAddressCachePolicy.FOREVER) { + // a name service lookup based Addresses implementation which replaces itself + // in cache when the result is obtained + private static final class NameServiceAddresses implements Addresses { + private final String host; + private final InetAddress reqAddr; - // As we iterate in insertion order we can - // terminate when a non-expired entry is found. - LinkedList expired = new LinkedList<>(); - long now = System.currentTimeMillis(); - for (String key : cache.keySet()) { - CacheEntry entry = cache.get(key); + NameServiceAddresses(String host, InetAddress reqAddr) { + this.host = host; + this.reqAddr = reqAddr; + } - if (entry.expiration >= 0 && entry.expiration < now) { - expired.add(key); + @Override + public InetAddress[] get() throws UnknownHostException { + Addresses addresses; + // only one thread is doing lookup to name service + // for particular host at any time. + synchronized (this) { + // re-check that we are still us + re-install us if slot empty + addresses = cache.putIfAbsent(host, this); + if (addresses == null) { + // this can happen when we were replaced by CachedAddresses in + // some other thread, then CachedAddresses expired and were + // removed from cache while we were waiting for lock... + addresses = this; + } + // still us ? + if (addresses == this) { + // lookup name services + InetAddress[] inetAddresses; + UnknownHostException ex; + int cachePolicy; + try { + inetAddresses = getAddressesFromNameService(host, reqAddr); + ex = null; + cachePolicy = InetAddressCachePolicy.get(); + } catch (UnknownHostException uhe) { + inetAddresses = null; + ex = uhe; + cachePolicy = InetAddressCachePolicy.getNegative(); + } + // remove or replace us with cached addresses according to cachePolicy + if (cachePolicy == InetAddressCachePolicy.NEVER) { + cache.remove(host, this); } else { - break; + CachedAddresses cachedAddresses = new CachedAddresses( + host, + inetAddresses, + cachePolicy == InetAddressCachePolicy.FOREVER + ? 0L + // cachePolicy is in [s] - we need [ns] + : System.nanoTime() + 1000_000_000L * cachePolicy + ); + if (cache.replace(host, this, cachedAddresses) && + cachePolicy != InetAddressCachePolicy.FOREVER) { + // schedule expiry + expirySet.add(cachedAddresses); + } } + if (inetAddresses == null) { + throw ex == null ? new UnknownHostException(host) : ex; + } + return inetAddresses; } - - for (String key : expired) { - cache.remove(key); - } - } - - // create new entry and add it to the cache - // -- as a HashMap replaces existing entries we - // don't need to explicitly check if there is - // already an entry for this host. - long expiration; - if (policy == InetAddressCachePolicy.FOREVER) { - expiration = -1; - } else { - expiration = System.currentTimeMillis() + (policy * 1000); - } - CacheEntry entry = new CacheEntry(addresses, expiration); - cache.put(host, entry); - return this; - } - - /** - * Query the cache for the specific host. If found then - * return its CacheEntry, or null if not found. - */ - public CacheEntry get(String host) { - int policy = getPolicy(); - if (policy == InetAddressCachePolicy.NEVER) { - return null; - } - CacheEntry entry = cache.get(host); - - // check if entry has expired - if (entry != null && policy != InetAddressCachePolicy.FOREVER) { - if (entry.expiration >= 0 && - entry.expiration < System.currentTimeMillis()) { - cache.remove(host); - entry = null; - } + // else addresses != this } - - return entry; + // delegate to different addresses when we are already replaced + // but outside of synchronized block to avoid any chance of dead-locking + return addresses.get(); } } - /* - * Initialize cache and insert anyLocalAddress into the - * unknown array with no expiry. - */ - private static void cacheInitIfNeeded() { - assert Thread.holdsLock(addressCache); - if (addressCacheInit) { - return; - } - unknown_array = new InetAddress[1]; - unknown_array[0] = impl.anyLocalAddress(); - - addressCache.put(impl.anyLocalAddress().getHostName(), - unknown_array); - - addressCacheInit = true; - } - - /* - * Cache the given hostname and addresses. - */ - private static void cacheAddresses(String hostname, - InetAddress[] addresses, - boolean success) { - hostname = hostname.toLowerCase(); - synchronized (addressCache) { - cacheInitIfNeeded(); - if (success) { - addressCache.put(hostname, addresses); - } else { - negativeCache.put(hostname, addresses); - } - } - } - - /* - * Lookup hostname in cache (positive & negative cache). If - * found return addresses, null if not found. - */ - private static InetAddress[] getCachedAddresses(String hostname) { - hostname = hostname.toLowerCase(); - - // search both positive & negative caches - - synchronized (addressCache) { - cacheInitIfNeeded(); - - CacheEntry entry = addressCache.get(hostname); - if (entry == null) { - entry = negativeCache.get(hostname); - } - - if (entry != null) { - return entry.addresses; - } - } - - // not found - return null; - } + static InetAddressImpl impl; private static NameService createNSProvider(String provider) { if (provider == null) @@ -1196,7 +1133,7 @@ private static InetAddress[] getAllByName(String host, InetAddress reqAddr) // We were expecting an IPv6 Litteral, but got something else throw new UnknownHostException("["+host+"]"); } - return getAllByName0(host, reqAddr, true); + return getAllByName0(host, reqAddr, true, true); } /** @@ -1257,14 +1194,27 @@ private static InetAddress[] getAllByName0 (String host) */ static InetAddress[] getAllByName0 (String host, boolean check) throws UnknownHostException { - return getAllByName0 (host, null, check); + return getAllByName0 (host, null, check, true); } - private static InetAddress[] getAllByName0 (String host, InetAddress reqAddr, boolean check) + /** + * Designated lookup method. + * + * @param host host name to look up + * @param reqAddr requested address to be the 1st in returned array + * @param check perform security check + * @param useCache use cached value if not expired else always + * perform name service lookup (and cache the result) + * @return array of InetAddress(es) + * @throws UnknownHostException if host name is not found + */ + private static InetAddress[] getAllByName0(String host, + InetAddress reqAddr, + boolean check, + boolean useCache) throws UnknownHostException { /* If it gets here it is presumed to be a hostname */ - /* Cache.get can return: null, unknownAddress, or InetAddress[] */ /* make sure the connection to the host is allowed, before we * give out a hostname @@ -1276,155 +1226,106 @@ private static InetAddress[] getAllByName0 (String host, InetAddress reqAddr, bo } } - InetAddress[] addresses = getCachedAddresses(host); + // remove expired addresses from cache - expirySet keeps them ordered + // by expiry time so we only need to iterate the prefix of the NavigableSet... + long now = System.nanoTime(); + for (CachedAddresses caddrs : expirySet) { + // compare difference of time instants rather than + // time instants directly, to avoid possible overflow. + // (see System.nanoTime() recommendations...) + if ((caddrs.expiryTime - now) < 0L) { + // ConcurrentSkipListSet uses weakly consistent iterator, + // so removing while iterating is OK... + if (expirySet.remove(caddrs)) { + // ... remove from cache + cache.remove(caddrs.host, caddrs); + } + } else { + // we encountered 1st element that expires in future + break; + } + } - /* If no entry in cache, then do the host lookup */ - if (addresses == null) { - addresses = getAddressesFromNameService(host, reqAddr); + // look-up or remove from cache + Addresses addrs; + if (useCache) { + addrs = cache.get(host); + } else { + addrs = cache.remove(host); + if (addrs != null) { + if (addrs instanceof CachedAddresses) { + // try removing from expirySet too if CachedAddresses + expirySet.remove(addrs); + } + addrs = null; + } } - if (addresses == unknown_array) - throw new UnknownHostException(host); + if (addrs == null) { + // create a NameServiceAddresses instance which will look up + // the name service and install it within cache... + Addresses oldAddrs = cache.putIfAbsent( + host, + addrs = new NameServiceAddresses(host, reqAddr) + ); + if (oldAddrs != null) { // lost putIfAbsent race + addrs = oldAddrs; + } + } - return addresses.clone(); + // ask Addresses to get an array of InetAddress(es) and clone it + return addrs.get().clone(); } - private static InetAddress[] getAddressesFromNameService(String host, InetAddress reqAddr) + static InetAddress[] getAddressesFromNameService(String host, InetAddress reqAddr) throws UnknownHostException { InetAddress[] addresses = null; - boolean success = false; UnknownHostException ex = null; - // Check whether the host is in the lookupTable. - // 1) If the host isn't in the lookupTable when - // checkLookupTable() is called, checkLookupTable() - // would add the host in the lookupTable and - // return null. So we will do the lookup. - // 2) If the host is in the lookupTable when - // checkLookupTable() is called, the current thread - // would be blocked until the host is removed - // from the lookupTable. Then this thread - // should try to look up the addressCache. - // i) if it found the addresses in the - // addressCache, checkLookupTable() would - // return the addresses. - // ii) if it didn't find the addresses in the - // addressCache for any reason, - // it should add the host in the - // lookupTable and return null so the - // following code would do a lookup itself. - if ((addresses = checkLookupTable(host)) == null) { + for (NameService nameService : nameServices) { try { - // This is the first thread which looks up the addresses - // this host or the cache entry for this host has been - // expired so this thread should do the lookup. - for (NameService nameService : nameServices) { - try { - /* - * Do not put the call to lookup() inside the - * constructor. if you do you will still be - * allocating space when the lookup fails. - */ - - addresses = nameService.lookupAllHostAddr(host); - success = true; - break; - } catch (UnknownHostException uhe) { - if (host.equalsIgnoreCase("localhost")) { - InetAddress[] local = new InetAddress[] { impl.loopbackAddress() }; - addresses = local; - success = true; - break; - } - else { - addresses = unknown_array; - success = false; - ex = uhe; - } - } + addresses = nameService.lookupAllHostAddr(host); + break; + } catch (UnknownHostException uhe) { + if (host.equalsIgnoreCase("localhost")) { + addresses = new InetAddress[] { impl.loopbackAddress() }; + break; } - - // More to do? - if (reqAddr != null && addresses.length > 1 && !addresses[0].equals(reqAddr)) { - // Find it? - int i = 1; - for (; i < addresses.length; i++) { - if (addresses[i].equals(reqAddr)) { - break; - } - } - // Rotate - if (i < addresses.length) { - InetAddress tmp, tmp2 = reqAddr; - for (int j = 0; j < i; j++) { - tmp = addresses[j]; - addresses[j] = tmp2; - tmp2 = tmp; - } - addresses[i] = tmp2; - } + else { + ex = uhe; } - // Cache the address. - cacheAddresses(host, addresses, success); - - if (!success && ex != null) - throw ex; - - } finally { - // Delete host from the lookupTable and notify - // all threads waiting on the lookupTable monitor. - updateLookupTable(host); } } - return addresses; - } - - - private static InetAddress[] checkLookupTable(String host) { - synchronized (lookupTable) { - // If the host isn't in the lookupTable, add it in the - // lookuptable and return null. The caller should do - // the lookup. - if (lookupTable.containsKey(host) == false) { - lookupTable.put(host, null); - return null; - } + if (addresses == null) { + throw ex == null ? new UnknownHostException(host) : ex; + } - // If the host is in the lookupTable, it means that another - // thread is trying to look up the addresses of this host. - // This thread should wait. - while (lookupTable.containsKey(host)) { - try { - lookupTable.wait(); - } catch (InterruptedException e) { + // More to do? + if (reqAddr != null && addresses.length > 1 && !addresses[0].equals(reqAddr)) { + // Find it? + int i = 1; + for (; i < addresses.length; i++) { + if (addresses[i].equals(reqAddr)) { + break; } } - } - - // The other thread has finished looking up the addresses of - // the host. This thread should retry to get the addresses - // from the addressCache. If it doesn't get the addresses from - // the cache, it will try to look up the addresses itself. - InetAddress[] addresses = getCachedAddresses(host); - if (addresses == null) { - synchronized (lookupTable) { - lookupTable.put(host, null); - return null; + // Rotate + if (i < addresses.length) { + InetAddress tmp, tmp2 = reqAddr; + for (int j = 0; j < i; j++) { + tmp = addresses[j]; + addresses[j] = tmp2; + tmp2 = tmp; + } + addresses[i] = tmp2; } } return addresses; } - private static void updateLookupTable(String host) { - synchronized (lookupTable) { - lookupTable.remove(host); - lookupTable.notifyAll(); - } - } - /** * Returns an {@code InetAddress} object given the raw IP address . * The argument is in network byte order: the highest order @@ -1446,10 +1347,18 @@ public static InetAddress getByAddress(byte[] addr) return getByAddress(null, addr); } - private static InetAddress cachedLocalHost = null; - private static long cacheTime = 0; - private static final long maxCacheTime = 5000L; - private static final Object cacheLock = new Object(); + private static final class CachedLocalHost { + final String host; + final InetAddress addr; + final long expiryTime = System.nanoTime() + 5000_000_000L; // now + 5s; + + CachedLocalHost(String host, InetAddress addr) { + this.host = host; + this.addr = addr; + } + } + + private static volatile CachedLocalHost cachedLocalHost; /** * Returns the address of the local host. This is achieved by retrieving @@ -1478,47 +1387,41 @@ public static InetAddress getLocalHost() throws UnknownHostException { SecurityManager security = System.getSecurityManager(); try { + // is cached data still valid? + CachedLocalHost clh = cachedLocalHost; + if (clh != null && (clh.expiryTime - System.nanoTime()) >= 0L) { + if (security != null) { + security.checkConnect(clh.host, -1); + } + return clh.addr; + } + String local = impl.getLocalHostName(); if (security != null) { security.checkConnect(local, -1); } + InetAddress localAddr; if (local.equals("localhost")) { - return impl.loopbackAddress(); - } - - InetAddress ret = null; - synchronized (cacheLock) { - long now = System.currentTimeMillis(); - if (cachedLocalHost != null) { - if ((now - cacheTime) < maxCacheTime) // Less than 5s old? - ret = cachedLocalHost; - else - cachedLocalHost = null; - } - - // we are calling getAddressesFromNameService directly - // to avoid getting localHost from cache - if (ret == null) { - InetAddress[] localAddrs; - try { - localAddrs = - InetAddress.getAddressesFromNameService(local, null); - } catch (UnknownHostException uhe) { - // Rethrow with a more informative error message. - UnknownHostException uhe2 = - new UnknownHostException(local + ": " + - uhe.getMessage()); - uhe2.initCause(uhe); - throw uhe2; - } - cachedLocalHost = localAddrs[0]; - cacheTime = now; - ret = localAddrs[0]; + // shortcut for "localhost" host name + localAddr = impl.loopbackAddress(); + } else { + // call getAllByName0 without security checks and + // without using cached data + try { + localAddr = getAllByName0(local, null, false, false)[0]; + } catch (UnknownHostException uhe) { + // Rethrow with a more informative error message. + UnknownHostException uhe2 = + new UnknownHostException(local + ": " + + uhe.getMessage()); + uhe2.initCause(uhe); + throw uhe2; } } - return ret; + cachedLocalHost = new CachedLocalHost(local, localAddr); + return localAddr; } catch (java.lang.SecurityException e) { return impl.loopbackAddress(); } diff --git a/jdk/src/share/classes/sun/net/InetAddressCachePolicy.java b/jdk/src/share/classes/sun/net/InetAddressCachePolicy.java index 31578b50d78..f20feec8ae0 100644 --- a/jdk/src/share/classes/sun/net/InetAddressCachePolicy.java +++ b/jdk/src/share/classes/sun/net/InetAddressCachePolicy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2014, 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 @@ -56,7 +56,7 @@ public final class InetAddressCachePolicy { * caching. For security reasons, this caching is made forever when * a security manager is set. */ - private static int cachePolicy = FOREVER; + private static volatile int cachePolicy = FOREVER; /* The Java-level namelookup cache policy for negative lookups: * @@ -66,7 +66,7 @@ public final class InetAddressCachePolicy { * default value is 0. It can be set to some other value for * performance reasons. */ - private static int negativeCachePolicy = NEVER; + private static volatile int negativeCachePolicy = NEVER; /* * Whether or not the cache policy for successful lookups was set @@ -110,10 +110,7 @@ public Integer run() { }); if (tmp != null) { - cachePolicy = tmp.intValue(); - if (cachePolicy < 0) { - cachePolicy = FOREVER; - } + cachePolicy = tmp < 0 ? FOREVER : tmp; propertySet = true; } else { /* No properties defined for positive caching. If there is no @@ -148,19 +145,16 @@ public Integer run() { }); if (tmp != null) { - negativeCachePolicy = tmp.intValue(); - if (negativeCachePolicy < 0) { - negativeCachePolicy = FOREVER; - } + negativeCachePolicy = tmp < 0 ? FOREVER : tmp; propertyNegativeSet = true; } } - public static synchronized int get() { + public static int get() { return cachePolicy; } - public static synchronized int getNegative() { + public static int getNegative() { return negativeCachePolicy; } @@ -190,7 +184,7 @@ public static synchronized void setIfNotSet(int newPolicy) { * @param newPolicy the value in seconds for how long the lookup * should be cached */ - public static synchronized void setNegativeIfNotSet(int newPolicy) { + public static void setNegativeIfNotSet(int newPolicy) { /* * When setting the new value we may want to signal that the * cache should be flushed, though this doesn't seem strictly @@ -200,7 +194,8 @@ public static synchronized void setNegativeIfNotSet(int newPolicy) { // Negative caching does not seem to have any security // implications. // checkValue(newPolicy, negativeCachePolicy); - negativeCachePolicy = newPolicy; + // but we should normalize negative policy + negativeCachePolicy = newPolicy < 0 ? FOREVER : newPolicy; } } From 9760552d66f33071df956f7ba7bc48d1335d1419 Mon Sep 17 00:00:00 2001 From: Andrew John Hughes Date: Fri, 26 Aug 2022 15:22:50 +0000 Subject: [PATCH 09/12] 8139668: Generate README-build.html from markdown Reviewed-by: phh Backport-of: 17c896827dbf1a54ab6539cc2b506f973dbde246 --- README-builds.html | 3878 +++++++++++------------------ README-builds.md | 1266 ++++++++++ common/bin/update-build-readme.sh | 62 + 3 files changed, 2714 insertions(+), 2492 deletions(-) create mode 100644 README-builds.md create mode 100644 common/bin/update-build-readme.sh diff --git a/README-builds.html b/README-builds.html index 14796a27e87..2281650f9e6 100644 --- a/README-builds.html +++ b/README-builds.html @@ -1,2495 +1,1389 @@ - - - OpenJDK Build README - - - - - - - - - - - -
- OpenJDK -
-

OpenJDK Build README

-
- - -


-

Introduction

-
- This README file contains build instructions for the - OpenJDK. - Building the source code for the - OpenJDK - requires - a certain degree of technical expertise. - - -

!!!!!!!!!!!!!!! THIS IS A MAJOR RE-WRITE of this document. !!!!!!!!!!!!!

-
- Some Headlines: -
    -
  • - The build is now a "configure && make" style build -
  • -
  • - Any GNU make 3.81 or newer should work -
  • -
  • - The build should scale, i.e. more processors should - cause the build to be done in less wall-clock time -
  • -
  • - Nested or recursive make invocations have been significantly - reduced, as has the total fork/exec or spawning - of sub processes during the build -
  • -
  • - Windows MKS usage is no longer supported -
  • -
  • - Windows Visual Studio vsvars*.bat and - vcvars*.bat files are run automatically -
  • -
  • - Ant is no longer used when building the OpenJDK -
  • -
  • - Use of ALT_* environment variables for configuring the - build is no longer supported -
  • -
-
-
- - -
-

Contents

-
- -
- -
- - -
-

Use of Mercurial

-
- The OpenJDK sources are maintained with the revision control system - Mercurial. - If you are new to Mercurial, please see the - - Beginner Guides - or refer to the - Mercurial Book. - The first few chapters of the book provide an excellent overview of - Mercurial, what it is and how it works. -
- For using Mercurial with the OpenJDK refer to the - - Developer Guide: Installing and Configuring Mercurial - section for more information. - -

Getting the Source

-
- To get the entire set of OpenJDK Mercurial repositories - use the script get_source.sh located in the - root repository: -
- - hg clone http://hg.openjdk.java.net/jdk8/jdk8 - YourOpenJDK -
- cd YourOpenJDK -
- bash ./get_source.sh -
-
- Once you have all the repositories, keep in mind that each - repository is its own independent repository. - You can also re-run ./get_source.sh anytime to - pull over all the latest changesets in all the repositories. - This set of nested repositories has been given the term - "forest" and there are various ways to apply the same - hg command to each of the repositories. - For example, the script make/scripts/hgforest.sh - can be used to repeat the same hg - command on every repository, e.g. -
- - cd YourOpenJDK -
- bash ./make/scripts/hgforest.sh status -
-
-
- -

Repositories

-
-

The set of repositories and what they contain:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RepositoryContains
- . (root) - - common configure and makefile logic -
- hotspot - - source code and make files for building - the OpenJDK Hotspot Virtual Machine -
- langtools - - source code for the OpenJDK javac and language tools -
- jdk - - source code and make files for building - the OpenJDK runtime libraries and misc files -
- jaxp - - source code for the OpenJDK JAXP functionality -
- jaxws - - source code for the OpenJDK JAX-WS functionality -
- corba - - source code for the OpenJDK Corba functionality -
- nashorn - - source code for the OpenJDK JavaScript implementation -
-
- -

Repository Source Guidelines

-
- There are some very basic guidelines: -
    -
  • - Use of whitespace in source files - (.java, .c, .h, .cpp, and .hpp files) - is restricted. - No TABs, no trailing whitespace on lines, and files - should not terminate in more than one blank line. -
  • -
  • - Files with execute permissions should not be added - to the source repositories. -
  • -
  • - All generated files need to be kept isolated from - the files - maintained or managed by the source control system. - The standard area for generated files is the top level - build/ directory. -
  • -
  • - The default build process should be to build the product - and nothing else, in one form, e.g. a product (optimized), - debug (non-optimized, -g plus assert logic), or - fastdebug (optimized, -g plus assert logic). -
  • -
  • - The .hgignore file in each repository - must exist and should - include ^build/, ^dist/ and - optionally any - nbproject/private directories. - It should NEVER include - anything in the - src/ or test/ - or any managed directory area of a repository. -
  • -
  • - Directory names and file names should never contain - blanks or - non-printing characters. -
  • -
  • - Generated source or binary files should NEVER be added to - the repository (that includes javah output). - There are some exceptions to this rule, in particular - with some of the generated configure scripts. -
  • -
  • - Files not needed for typical building - or testing of the repository - should not be added to the repository. -
  • -
-
- -
- - -
-

Building

-
- The very first step in building the OpenJDK is making sure the - system itself has everything it needs to do OpenJDK builds. - Once a system is setup, it generally doesn't need to be done again. -
- Building the OpenJDK is now done with running a - configure - script which will try and find and verify you have everything - you need, followed by running - make, e.g. -
- - - bash ./configure
- make all -
-
-
- Where possible the configure script will attempt to located the - various components in the default locations or via component - specific variable settings. - When the normal defaults fail or components cannot be found, - additional configure options may be necessary to help configure - find the necessary tools for the build, or you may need to - re-visit the setup of your system due to missing software - packages. -
- NOTE: The configure script - file does not have - execute permissions and will need to be explicitly run with - bash, - see the source guidelines. - - -
-

System Setup

-
- Before even attempting to use a system to build the OpenJDK - there are some very basic system setups needed. - For all systems: -
    -
  • - Be sure the GNU make utility is version 3.81 or newer, - e.g. run "make -version" -
  • -
  • - Install a - Bootstrap JDK. - All OpenJDK builds require access to a previously released - JDK called the bootstrap JDK or boot JDK. - The general rule is that the bootstrap JDK - must be an instance of the previous major - release of the JDK. In addition, there may be - a requirement to use a release at or beyond a - particular update level. -
     
    - - Building JDK 8 requires use of a version - of JDK 7 that is at Update 7 or newer. JDK 8 - developers should not use JDK 8 as the boot - JDK, to ensure that JDK 8 dependencies are - not introduced into the parts of the system - that are built with JDK 7. - -
     
    - The JDK 7 binaries can be downloaded from Oracle's - JDK 7 download site. - For build performance reasons - is very important that this bootstrap JDK be made available - on the local disk of the machine doing the build. - You should add its bin directory - to the PATH environment variable. - If configure has any issues finding this JDK, you may - need to use the configure option - --with-boot-jdk. -
  • -
  • - Ensure that GNU make, the Bootstrap JDK, - and the compilers are all - in your PATH environment variable -
  • -
- And for specific systems: - - - - - - - - - - - - - - - - - -
LinuxSolarisWindowsMac OS X
- Install all the software development - packages needed including - alsa, - freetype, - cups, and - xrender. -
- See - specific system packages. -
- Install all the software development - packages needed including - Studio Compilers, - freetype, - cups, and - xrender. -
- See - specific system packages. -
- - - Install - XCode 4.5.2 - and also install the "Command line tools" found under the - preferences pane "Downloads" -
- -

Linux

-
- With Linux, try and favor the system packages over - building your own - or getting packages from other areas. - Most Linux builds should be possible with the system's - available packages. -
- Note that some Linux systems have a habit of pre-populating - your environment variables for you, for example JAVA_HOME - might get pre-defined for you to refer to the JDK installed on - your Linux system. - You will need to unset JAVA_HOME. - It's a good idea to run env and verify the - environment variables you are getting from the default system - settings make sense for building the OpenJDK. - -
- -

Solaris

-
-
Studio Compilers
-
- At a minimum, the - - Studio 12 Update 1 Compilers - (containing version 5.10 of the C and C++ compilers) is required, - including specific patches. -

- The Solaris SPARC patch list is: -

    -
  • - 118683-05: SunOS 5.10: Patch for profiling libraries and assembler -
  • -
  • - 119963-21: SunOS 5.10: Shared library patch for C++ -
  • -
  • - 120753-08: SunOS 5.10: Microtasking libraries (libmtsk) patch -
  • -
  • - 128228-09: Sun Studio 12 Update 1: Patch for Sun C++ Compiler -
  • -
  • - 141860-03: Sun Studio 12 Update 1: Patch for Compiler Common patch for Sun C C++ F77 F95 -
  • -
  • - 141861-05: Sun Studio 12 Update 1: Patch for Sun C Compiler -
  • -
  • - 142371-01: Sun Studio 12.1 Update 1: Patch for dbx -
  • -
  • - 143384-02: Sun Studio 12 Update 1: Patch for debuginfo handling -
  • -
  • - 143385-02: Sun Studio 12 Update 1: Patch for Compiler Common patch for Sun C C++ F77 F95 -
  • -
  • - 142369-01: Sun Studio 12.1: Patch for Performance Analyzer Tools -
  • -
-

- The Solaris X86 patch list is: -

    -
  • - 119961-07: SunOS 5.10_x86, x64, Patch for profiling libraries and assembler -
  • -
  • - 119964-21: SunOS 5.10_x86: Shared library patch for C++_x86 -
  • -
  • - 120754-08: SunOS 5.10_x86: Microtasking libraries (libmtsk) patch -
  • -
  • - 141858-06: Sun Studio 12 Update 1_x86: Sun Compiler Common patch for x86 backend -
  • -
  • - 128229-09: Sun Studio 12 Update 1_x86: Patch for C++ Compiler -
  • -
  • - 142363-05: Sun Studio 12 Update 1_x86: Patch for C Compiler -
  • -
  • - 142368-01: Sun Studio 12.1_x86: Patch for Performance Analyzer Tools -
  • -
-

- Place the bin directory in PATH. -

- The Oracle Solaris Studio Express compilers at: - - Oracle Solaris Studio Express Download site - are also an option, although these compilers have not - been extensively used yet. -

- -
- -

Windows

-
- -
Windows Unix Toolkit
-
- Building on Windows requires a Unix-like environment, notably a - Unix-like shell. - There are several such environments available of which - Cygwin and - MinGW/MSYS are - currently supported for - the OpenJDK build. One of the differences of these - systems from standard Windows tools is the way - they handle Windows path names, particularly path names which contain - spaces, backslashes as path separators and possibly drive letters. - Depending - on the use case and the specifics of each environment these path - problems can - be solved by a combination of quoting whole paths, translating - backslashes to - forward slashes, escaping backslashes with additional backslashes and - translating the path names to their - - "8.3" version. - -
CYGWIN
-
- CYGWIN is an open source, Linux-like environment which tries to emulate - a complete POSIX layer on Windows. It tries to be smart about path names - and can usually handle all kinds of paths if they are correctly quoted - or escaped although internally it maps drive letters <drive>: - to a virtual directory /cygdrive/<drive>. -

- You can always use the cygpath utility to map pathnames with spaces - or the backslash character into the C:/ style of pathname - (called 'mixed'), e.g. cygpath -s -m "path". -

-

- Note that the use of CYGWIN creates a unique problem with regards to - setting PATH. Normally on Windows - the PATH variable contains directories - separated with the ";" character (Solaris and Linux use ":"). - With CYGWIN, it uses ":", but that means that paths like "C:/path" - cannot be placed in the CYGWIN version of PATH and - instead CYGWIN uses something like /cygdrive/c/path - which CYGWIN understands, but only CYGWIN understands. -

-

- The OpenJDK build requires CYGWIN version 1.7.16 or newer. - Information about CYGWIN can - be obtained from the CYGWIN website at - www.cygwin.com. -

-

- By default CYGWIN doesn't install all the tools required for building - the OpenJDK. - Along with the default installation, you need to install - the following tools. -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Binary NameCategoryPackageDescription
ar.exeDevelbinutils - The GNU assembler, linker and binary utilities -
make.exeDevelmake - The GNU version of the 'make' utility built for CYGWIN -
m4.exeInterpretersm4 - GNU implementation of the traditional Unix macro - processor -
cpio.exeUtilscpio - A program to manage archives of files -
gawk.exeUtilsawk - Pattern-directed scanning and processing language -
file.exeUtilsfile - Determines file type using 'magic' numbers -
zip.exeArchivezip - Package and compress (archive) files -
unzip.exeArchiveunzip - Extract compressed files in a ZIP archive -
free.exeSystemprocps - Display amount of free and used memory in the system -
-
- Note that the CYGWIN software can conflict with other non-CYGWIN - software on your Windows system. - CYGWIN provides a - FAQ for - known issues and problems, of particular interest is the - section on - - BLODA (applications that interfere with CYGWIN). -
- -
MinGW/MSYS
-
- MinGW ("Minimalist GNU for Windows") is a collection of free Windows - specific header files and import libraries combined with GNU toolsets that - allow one to produce native Windows programs that do not rely on any - 3rd-party C runtime DLLs. MSYS is a supplement to MinGW which allows building - applications and programs which rely on traditional UNIX tools to - be present. Among others this includes tools like bash - and make. - See MinGW/MSYS - for more information. -

- Like Cygwin, MinGW/MSYS can handle different types of path formats. They - are internally converted to paths with forward slashes and drive letters - <drive>: replaced by a virtual - directory /<drive>. Additionally, MSYS automatically - detects binaries compiled for the MSYS environment and feeds them with the - internal, Unix-style path names. If native Windows applications are called - from within MSYS programs their path arguments are automatically converted - back to Windows style path names with drive letters and backslashes as - path separators. This may cause problems for Windows applications which - use forward slashes as parameter separator (e.g. cl /nologo /I) - because MSYS may wrongly - replace such parameters by drive letters. -

-

- In addition to the tools which will be installed - by default, you have - to manually install the - msys-zip and - msys-unzip packages. - This can be easily done with the MinGW command line installer: -

- mingw-get.exe install msys-zip -
- mingw-get.exe install msys-unzip -
-
- -
- -
Visual Studio 2010 Compilers
-
-

- The 32-bit and 64-bit OpenJDK Windows build requires - Microsoft Visual Studio C++ 2010 (VS2010) Professional - Edition or Express compiler. - The compiler and other tools are expected to reside - in the location defined by the variable - VS100COMNTOOLS which - is set by the Microsoft Visual Studio installer. -

-

- Only the C++ part of VS2010 is needed. - Try to let the installation go to the default - install directory. - Always reboot your system after installing VS2010. - The system environment variable VS100COMNTOOLS - should be - set in your environment. -

-

- Make sure that TMP and TEMP are also set - in the environment - and refer to Windows paths that exist, - like C:\temp, - not /tmp, not /cygdrive/c/temp, - and not C:/temp. - C:\temp is just an example, - it is assumed that this area is - private to the user, so by default - after installs you should - see a unique user path in these variables. -

-
- - -
- -

Mac OS X

-
- Make sure you get the right XCode version. -
- -
- - -
-

Configure

-
- The basic invocation of the configure script - looks like: -
- bash ./configure [options] -
- This will create an output directory containing the - "configuration" and setup an area for the build result. - This directory typically looks like: -
- build/linux-x64-normal-server-release -
- configure will try to figure out what system you are running on - and where all necessary build components are. - If you have all prerequisites for building installed, - it should find everything. - If it fails to detect any component automatically, - it will exit and inform you about the problem. - When this happens, read more below in - the configure options. -

- Some examples: -

- - - - - - - - - - - - - - - - - -
DescriptionConfigure Command Line
Windows 32bit build with freetype specified - bash ./configure --with-freetype=/cygdrive/c/freetype-i586 --with-target-bits=32 -
Debug 64bit Build - bash ./configure --enable-debug --with-target-bits=64 -
- - -

Configure Options

-
- Complete details on all the OpenJDK configure options can - be seen with: -
- bash ./configure --help=short -
- Use -help to see all the configure options - available. - - You can generate any number of different configurations, - e.g. debug, release, 32, 64, etc. - - Some of the more commonly used configure options are: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OpenJDK Configure OptionDescription
--enable-debug - set the debug level to fastdebug (this is a shorthand for - --with-debug-level=fastdebug) -
--with-alsa=path - select the location of the - Advanced Linux Sound Architecture (ALSA) -
- Version 0.9.1 or newer of the ALSA files are - required for building the OpenJDK on Linux. - These Linux files are usually available from an "alsa" - of "libasound" - development package, - and it's highly recommended that you try and use - the package provided by the particular version of Linux that - you are using. -
--with-boot-jdk=path - select the Bootstrap JDK -
--with-boot-jdk-jvmargs="args" - provide the JVM options to be used to run the - Bootstrap JDK -
--with-cacerts=path - select the path to the cacerts file. -
- See - http://en.wikipedia.org/wiki/Certificate_Authority - for a better understanding of the Certificate Authority (CA). - A certificates file named "cacerts" - represents a system-wide keystore with CA certificates. - In JDK and JRE - binary bundles, the "cacerts" file contains root CA certificates from - several public CAs (e.g., VeriSign, Thawte, and Baltimore). - The source contain a cacerts file - without CA root certificates. - Formal JDK builders will need to secure - permission from each public CA and include the certificates into their - own custom cacerts file. - Failure to provide a populated cacerts file - will result in verification errors of a certificate chain during runtime. - By default an empty cacerts file is provided and that should be - fine for most JDK developers. -
--with-cups=path - select the CUPS install location -
- The - Common UNIX Printing System (CUPS) Headers - are required for building the - OpenJDK on Solaris and Linux. - The Solaris header files can be obtained by installing - the package SFWcups from the Solaris Software - Companion CD/DVD, these often will be installed into the - directory /opt/sfw/cups. -
- The CUPS header files can always be downloaded from - www.cups.org. -
--with-cups-include=path - select the CUPS include directory location -
--with-debug-level=level - select the debug information level of release, - fastdebug, or slowdebug -
--with-dev-kit=path - select location of the compiler install or - developer install location -
--with-freetype=path - select the freetype files to use. -
- Expecting the - freetype libraries under - lib/ and the - headers under include/. -
- Version 2.3 or newer of FreeType is required. - On Unix systems required files can be available as part of your - distribution (while you still may need to upgrade them). - Note that you need development version of package that - includes both the FreeType library and header files. -
- You can always download latest FreeType version from the - FreeType website. -
- Building the freetype 2 libraries from scratch is also possible, - however on Windows refer to the - - Windows FreeType DLL build instructions. -
- Note that by default FreeType is built with byte code hinting - support disabled due to licensing restrictions. - In this case, text appearance and metrics are expected to - differ from Sun's official JDK build. - See - - the SourceForge FreeType2 Home Page - - for more information. -
--with-import-hotspot=path - select the location to find hotspot - binaries from a previous build to avoid building - hotspot -
--with-target-bits=arg - select 32 or 64 bit build -
--with-jvm-variants=variants - select the JVM variants to build from, comma - separated list that can include: - server, client, kernel, zero and zeroshark -
--with-memory-size=size - select the RAM size that GNU make will think - this system has -
--with-msvcr-dll=path - select the msvcr100.dll - file to include in the - Windows builds (C/C++ runtime library for - Visual Studio). -
- This is usually picked up automatically - from the redist - directories of Visual Studio 2010. -
--with-num-cores=cores - select the number of cores to use (processor - count or CPU count) -
--with-x=path - select the location of the X11 and xrender files. -
- The - XRender Extension Headers - are required for building the - OpenJDK on Solaris and Linux. -
- The Linux header files are usually available from a "Xrender" - development package, it's recommended that you try and use - the package provided by the particular distribution of Linux that - you are using. -
- The Solaris XRender header files is - included with the other X11 header files - in the package SFWxwinc - on new enough versions of - Solaris and will be installed in - /usr/X11/include/X11/extensions/Xrender.h or - /usr/openwin/share/include/X11/extensions/Xrender.h -
-
- -
- - -
-

Make

-
- The basic invocation of the make utility - looks like: -
- make all -
- This will start the build to the output directory containing the - "configuration" that was created by the configure - script. Run make help for more information on - the available targets. -
- There are some of the make targets that - are of general interest: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Make TargetDescription
emptybuild everything but no images
allbuild everything including images
all-confbuild all configurations
imagescreate complete j2sdk and j2re images
installinstall the generated images locally, - typically in /usr/local
cleanremove all files generated by make, - but not those generated by configure
dist-cleanremove all files generated by both - and configure (basically killing the configuration)
helpgive some help on using make, - including some interesting make targets
-
-
- - -
-

Testing

-
- When the build is completed, you should see the generated - binaries and associated files in the j2sdk-image - directory in the output directory. - In particular, the - build/*/images/j2sdk-image/bin - directory should contain executables for the - OpenJDK tools and utilities for that configuration. - The testing tool jtreg will be needed - and can be found at: - - the jtreg site. - The provided regression tests in the repositories - can be run with the command: -
- cd test && make PRODUCT_HOME=`pwd`/../build/*/images/j2sdk-image all -
-
- - - - - - - - - - - - -
-

Appendix A: Hints and Tips

-
- -

FAQ

-
- -

- Q: The generated-configure.sh file looks horrible! - How are you going to edit it? -
- A: The generated-configure.sh file is generated (think - "compiled") by the autoconf tools. The source code is - in configure.ac and various .m4 files in common/autoconf, - which are much more readable. -

- -

- Q: - Why is the generated-configure.sh file checked in, - if it is generated? -
- A: - If it was not generated, every user would need to have the autoconf - tools installed, and re-generate the configure file - as the first step. - Our goal is to minimize the work needed to be done by the user - to start building OpenJDK, and to minimize - the number of external dependencies required. -

- -

- Q: - Do you require a specific version of autoconf for regenerating - generated-configure.sh? -
- A: - Yes, version 2.69 is required and should be easy - enough to aquire on all supported operating - systems. The reason for this is to avoid - large spurious changes in generated-configure.sh. -

- -

- Q: - How do you regenerate generated-configure.sh - after making changes to the input files? -
- A: - Regnerating generated-configure.sh - should always be done using the - script common/autoconf/autogen.sh to - ensure that the correct files get updated. This - script should also be run after mercurial tries to - merge generated-configure.sh as a - merge of the generated file is not guaranteed to - be correct. -

- -

- Q: - What are the files in common/makefiles/support/* for? - They look like gibberish. -
- A: - They are a somewhat ugly hack to compensate for command line length - limitations on certain platforms (Windows, Solaris). - Due to a combination of limitations in make and the shell, - command lines containing too many files will not work properly. - These - helper files are part of an elaborate hack that will compress the - command line in the makefile and then uncompress it safely. - We're - not proud of it, but it does fix the problem. - If you have any better suggestions, we're all ears! :-) -

- -

- Q: - I want to see the output of the commands that make runs, - like in the old build. How do I do that? -
- A: - You specify the LOG variable to make. There are - several log levels: -

-
-
    -
  • - warn — Default and very quiet. -
  • -
  • - info — Shows more progress information - than warn. -
  • -
  • - debug — Echos all command lines and - prints all macro calls for compilation definitions. -
  • -
  • - trace — Echos all $(shell) command - lines as well. -
  • -
-
- -

- Q: - When do I have to re-run configure? -
- A: - Normally you will run configure only once for creating a - configuration. - You need to re-run configuration only if you want to change any - configuration options, - or if you pull down changes to the configure script. -

- -

- Q: - I have added a new source file. Do I need to modify the makefiles? -
- A: - Normally, no. If you want to create e.g. a new native - library, - you will need to modify the makefiles. But for normal file - additions or removals, no changes are needed. There are certan - exceptions for some native libraries where the source files are spread - over many directories which also contain sources for other - libraries. In these cases it was simply easier to create include lists - rather than excludes. -

- -

- Q: - When I run configure --help, I see many strange options, - like --dvidir. What is this? -
- A: - Configure provides a slew of options by default, to all projects - that use autoconf. Most of them are not used in OpenJDK, - so you can safely ignore them. To list only OpenJDK specific features, - use configure --help=short instead. -

- -

- Q: - configure provides OpenJDK-specific features such as - --with-builddeps-server that are not - described in this document. What about those? -
- A: - Try them out if you like! But be aware that most of these are - experimental features. - Many of them don't do anything at all at the moment; the option - is just a placeholder. Others depend on - pieces of code or infrastructure that is currently - not ready for prime time. -

- -

- Q: - How will you make sure you don't break anything? -
- A: - We have a script that compares the result of the new build system - with the result of the old. For most part, we aim for (and achieve) - byte-by-byte identical output. There are however technical issues - with e.g. native binaries, which might differ in a byte-by-byte - comparison, even - when building twice with the old build system. - For these, we compare relevant aspects - (e.g. the symbol table and file size). - Note that we still don't have 100% - equivalence, but we're close. -

- -

- Q: - I noticed this thing X in the build that looks very broken by design. - Why don't you fix it? -
- A: - Our goal is to produce a build output that is as close as - technically possible to the old build output. - If things were weird in the old build, - they will be weird in the new build. - Often, things were weird before due to obscurity, - but in the new build system the weird stuff comes up to the surface. - The plan is to attack these things at a later stage, - after the new build system is established. -

- -

- Q: - The code in the new build system is not that well-structured. - Will you fix this? -
- A: - Yes! The new build system has grown bit by bit as we converted - the old system. When all of the old build system is converted, - we can take a step back and clean up the structure of the new build - system. Some of this we plan to do before replacing the old build - system and some will need to wait until after. -

- -

- Q: - Is anything able to use the results of the new build's default make target? -
- A: - Yes, this is the minimal (or roughly minimal) - set of compiled output needed for a developer to actually - execute the newly built JDK. The idea is that in an incremental - development fashion, when doing a normal make, - you should only spend time recompiling what's changed - (making it purely incremental) and only do the work that's - needed to actually run and test your code. - The packaging stuff that is part of the images - target is not needed for a normal developer who wants to - test his new code. Even if it's quite fast, it's still unnecessary. - We're targeting sub-second incremental rebuilds! ;-) - (Or, well, at least single-digit seconds...) -

- -

- Q: - I usually set a specific environment variable when building, - but I can't find the equivalent in the new build. - What should I do? -
- A: - It might very well be that we have neglected to add support for - an option that was actually used from outside the build system. - Email us and we will add support for it! -

- -
- -

Build Performance Tips

-
- -

Building OpenJDK requires a lot of horsepower. - Some of the build tools can be adjusted to utilize more or less - of resources such as - parallel threads and memory. - The configure script analyzes your system and selects reasonable - values for such options based on your hardware. - If you encounter resource problems, such as out of memory conditions, - you can modify the detected values with:

- -
    -
  • - --with-num-cores - — - number of cores in the build system, - e.g. --with-num-cores=8 -
  • -
  • - --with-memory-size - — memory (in MB) available in the build system, - e.g. --with-memory-size=1024 -
  • -
- -

It might also be necessary to specify the JVM arguments passed - to the Bootstrap JDK, using e.g. - --with-boot-jdk-jvmargs="-Xmx8G -enableassertions". - Doing this will override the default JVM arguments - passed to the Bootstrap JDK.

- - -

One of the top goals of the new build system is to improve the - build performance and decrease the time needed to build. This will - soon also apply to the java compilation when the Smart Javac wrapper - is making its way into jdk8. It can be tried in the build-infra - repository already. You are likely to find that the new build system - is faster than the old one even without this feature.

- -

At the end of a successful execution of configure, - you will get a performance summary, - indicating how well the build will perform. Here you will - also get performance hints. - If you want to build fast, pay attention to those!

- -

Building with ccache

- -

A simple way to radically speed up compilation of native code - (typically hotspot and native libraries in JDK) is to install - ccache. This will cache and reuse prior compilation results, if the - source code is unchanged. However, ccache versions prior to 3.1.4 - does not work correctly with the precompiled headers used in - OpenJDK. So if your platform supports ccache at 3.1.4 or later, we - highly recommend installing it. This is currently only supported on - linux.

- -

Building on local disk

- -

If you are using network shares, e.g. via NFS, for your source code, - make sure the build directory is situated on local disk. - The performance - penalty is extremely high for building on a network share, - close to unusable.

- -

Building only one JVM

- -

The old build builds multiple JVMs on 32-bit systems (client and - server; and on Windows kernel as well). In the new build we have - changed this default to only build server when it's available. This - improves build times for those not interested in multiple JVMs. To - mimic the old behavior on platforms that support it, - use --with-jvm-variants=client,server.

- -

Selecting the number of cores to build on

- -

By default, configure will analyze your machine and run the make - process in parallel with as many threads as you have cores. This - behavior can be overridden, either "permanently" (on a configure - basis) using --with-num-cores=N or for a single build - only (on a make basis), using make JOBS=N.

- -

If you want to make a slower build just this time, to save some CPU - power for other processes, you can run - e.g. make JOBS=2. This will force the makefiles - to only run 2 parallel processes, or even make JOBS=1 - which will disable parallelism.

- -

If you want to have it the other way round, namely having slow - builds default and override with fast if you're - impatient, you should call configure with - --with-num-cores=2, making 2 the default. - If you want to run with more - cores, run make JOBS=8

- -
- -

Troubleshooting

-
- -

Solving build problems

- -
- If the build fails (and it's not due to a compilation error in - a source file you've changed), the first thing you should do - is to re-run the build with more verbosity. - Do this by adding LOG=debug to your make command line. -
- The build log (with both stdout and stderr intermingled, - basically the same as you see on your console) can be found as - build.log in your build directory. -
- You can ask for help on build problems with the new build system - on either the - - build-dev - or the - - build-infra-dev - mailing lists. Please include the relevant parts - of the build log. -
- A build can fail for any number of reasons. - Most failures - are a result of trying to build in an environment in which all the - pre-build requirements have not been met. - The first step in - troubleshooting a build failure is to recheck that you have satisfied - all the pre-build requirements for your platform. - Scanning the configure log is a good first step, making - sure that what it found makes sense for your system. - Look for strange error messages or any difficulties that - configure had in finding things. -
- Some of the more common problems with builds are briefly - described - below, with suggestions for remedies. -
    -
  • - Corrupted Bundles on Windows: -
    - Some virus scanning software has been known to - corrupt the - downloading of zip bundles. - It may be necessary to disable the 'on access' or - 'real time' - virus scanning features to prevent this corruption. - This type of "real time" virus scanning can also - slow down the - build process significantly. - Temporarily disabling the feature, or excluding the build - output directory may be necessary to get correct and - faster builds. -
    -
  • -
  • - Slow Builds: -
    - If your build machine seems to be overloaded from too many - simultaneous C++ compiles, try setting the - JOBS=1 on the make command line. - Then try increasing the count slowly to an acceptable - level for your system. Also: -
    - Creating the javadocs can be very slow, - if you are running - javadoc, consider skipping that step. -
    - Faster CPUs, more RAM, and a faster DISK usually helps. - The VM build tends to be CPU intensive - (many C++ compiles), - and the rest of the JDK will often be disk intensive. -
    - Faster compiles are possible using a tool called - ccache. -
    -
    -
  • -
  • - File time issues: -
    - If you see warnings that refer to file time stamps, e.g. -
    - Warning message: - File `xxx' has modification time in - the future. -
    - Warning message: Clock skew detected. - Your build may - be incomplete. -
    - These warnings can occur when the clock on the build - machine is out of - sync with the timestamps on the source files. - Other errors, apparently - unrelated but in fact caused by the clock skew, - can occur along with - the clock skew warnings. - These secondary errors may tend to obscure the - fact that the true root cause of the problem - is an out-of-sync clock. -

    - If you see these warnings, reset the clock on the - build - machine, run "gmake clobber" - or delete the directory - containing the build output, and restart the - build from the beginning. -

    -
  • -
  • - Error message: - Trouble writing out table to disk -
    - Increase the amount of swap space on your build machine. - This could be caused by overloading the system and - it may be necessary to use: -
    - make JOBS=1 -
    - to reduce the load on the system. -
    -
  • -
  • - Error Message: - libstdc++ not found: -
    - This is caused by a missing libstdc++.a library. - This is installed as part of a specific package - (e.g. libstdc++.so.devel.386). - By default some 64-bit Linux versions (e.g. Fedora) - only install the 64-bit version of the libstdc++ package. - Various parts of the JDK build require a static - link of the C++ runtime libraries to allow for maximum - portability of the built images. -
    -
  • -
  • - Linux Error Message: - cannot restore segment prot after reloc -
    - This is probably an issue with SELinux (See - - http://en.wikipedia.org/wiki/SELinux). - Parts of the VM is built without the -fPIC for - performance reasons. -

    - To completely disable SELinux: -

      -
    1. $ su root
    2. -
    3. # system-config-securitylevel
    4. -
    5. In the window that appears, select the SELinux tab
    6. -
    7. Disable SELinux
    8. -
    -

    - Alternatively, instead of completely disabling it you could - disable just this one check. -

      -
    1. Select System->Administration->SELinux Management
    2. -
    3. In the SELinux Management Tool which appears, - select "Boolean" from the menu on the left
    4. -
    5. Expand the "Memory Protection" group
    6. -
    7. Check the first item, labeled - "Allow all unconfined executables to use - libraries requiring text relocation ..."
    8. -
    -
    -
  • -
  • - Windows Error Messages: -
    - *** fatal error - couldn't allocate heap, ... -
    - rm fails with "Directory not empty" -
    - unzip fails with "cannot create ... Permission denied" -
    - unzip fails with "cannot create ... Error 50" -
    -
    - The CYGWIN software can conflict with other non-CYGWIN - software. See the CYGWIN FAQ section on - - BLODA (applications that interfere with CYGWIN). -
    -
  • -
  • - Windows Error Message: spawn failed -
    - Try rebooting the system, or there could be some kind of - issue with the disk or disk partition being used. - Sometimes it comes with a "Permission Denied" message. -
    -
  • -
-
- -
- -
- - -
-

Appendix B: GNU make

-
- - The Makefiles in the OpenJDK are only valid when used with the - GNU version of the utility command make - (usually called gmake on Solaris). - A few notes about using GNU make: -
    -
  • - You need GNU make version 3.81 or newer. - If the GNU make utility on your systems is not - 3.81 or newer, - see "Building GNU make". -
  • -
  • - Place the location of the GNU make binary in the - PATH. -
  • -
  • - Solaris: - Do NOT use /usr/bin/make on Solaris. - If your Solaris system has the software - from the Solaris Developer Companion CD installed, - you should try and use gmake - which will be located in either the - /usr/bin, /opt/sfw/bin or - /usr/sfw/bin directory. -
  • -
  • - Windows: - Make sure you start your build inside a bash shell. -
  • -
  • - Mac OS X: - The XCode "command line tools" must be installed on your Mac. -
  • -
-

- Information on GNU make, and access to ftp download sites, are - available on the - - GNU make web site - . - The latest source to GNU make is available at - - ftp.gnu.org/pub/gnu/make/. -

- -

Building GNU make

-
- First step is to get the GNU make 3.81 or newer source from - - ftp.gnu.org/pub/gnu/make/. - Building is a little different depending on the OS but is - basically done with: -
- bash ./configure -
- make -
-
- -
- - -
-

Appendix C: Build Environments

-
- -

Minimum Build Environments

-
- This file often describes specific requirements for what we - call the - "minimum build environments" (MBE) for this - specific release of the JDK. - What is listed below is what the Oracle Release - Engineering Team will use to build the Oracle JDK product. - Building with the MBE will hopefully generate the most compatible - bits that install on, and run correctly on, the most variations - of the same base OS and hardware architecture. - In some cases, these represent what is often called the - least common denominator, but each Operating System has different - aspects to it. -

- In all cases, the Bootstrap JDK version minimum is critical, - we cannot guarantee builds will work with older Bootstrap JDK's. - Also in all cases, more RAM and more processors is better, - the minimums listed below are simply recommendations. -

- With Solaris and Mac OS X, the version listed below is the - oldest release we can guarantee builds and works, and the - specific version of the compilers used could be critical. -

- With Windows the critical aspect is the Visual Studio compiler - used, which due to it's runtime, generally dictates what Windows - systems can do the builds and where the resulting bits can - be used.
- NOTE: We expect a change here off these older Windows OS releases - and to a 'less older' one, probably Windows 2008R2 X64. -

- With Linux, it was just a matter of picking a - stable distribution that is a good representative for Linux - in general.
- NOTE: We expect a change here from Fedora 9 to something else, - but it has not been completely determined yet, possibly - Ubuntu 12.04 X64, unbiased community feedback would be welcome on - what a good choice would be here. -

- It is understood that most developers will NOT be using these - specific versions, and in fact creating these specific versions - may be difficult due to the age of some of this software. - It is expected that developers are more often using the more - recent releases and distributions of these operating systems. -

- Compilation problems with newer or different C/C++ compilers is a - common problem. - Similarly, compilation problems related to changes to the - /usr/include or system header files is also a - common problem with older, newer, or unreleased OS versions. - Please report these types of problems as bugs so that they - can be dealt with accordingly. -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Base OS and ArchitectureOSC/C++ CompilerBootstrap JDKProcessorsRAM MinimumDISK Needs
Linux X86 (32-bit) and X64 (64-bit)Fedora 9gcc 4.3 JDK 7u72 or more1 GB6 GB
Solaris SPARC (32-bit) and SPARCV9 (64-bit)Solaris 10 Update 6Studio 12 Update 1 + patchesJDK 7u74 or more4 GB8 GB
Solaris X86 (32-bit) and X64 (64-bit)Solaris 10 Update 6Studio 12 Update 1 + patchesJDK 7u74 or more4 GB8 GB
Windows X86 (32-bit)Windows XPMicrosoft Visual Studio C++ 2010 Professional EditionJDK 7u72 or more2 GB6 GB
Windows X64 (64-bit)Windows Server 2003 - Enterprise x64 EditionMicrosoft Visual Studio C++ 2010 Professional EditionJDK 7u72 or more2 GB6 GB
Mac OS X X64 (64-bit)Mac OS X 10.7 "Lion"XCode 4.5.2 or newerJDK 7u72 or more4 GB6 GB
-
- - -
-

Specific Developer Build Environments

-
- We won't be listing all the possible environments, but - we will try to provide what information we have available to us. -

- NOTE: The community can help out by updating - this part of the document. - - -

Fedora

-
- After installing the latest - Fedora - you need to install several build dependencies. - The simplest way to do it is to execute the - following commands as user root: -
- yum-builddep java-1.7.0-openjdk -
- yum install gcc gcc-c++ -
-

- In addition, it's necessary to set a few environment - variables for the build: -

- export LANG=C -
- export PATH="/usr/lib/jvm/java-openjdk/bin:${PATH}" -
-
- - -

CentOS 5.5

-
- After installing - CentOS 5.5 - you need to make sure you have - the following Development bundles installed: -
-
    -
  • Development Libraries
  • -
  • Development Tools
  • -
  • Java Development
  • -
  • X Software Development (Including XFree86-devel)
  • -
-
-

- Plus the following packages: -

-
    -
  • cups devel: Cups Development Package
  • -
  • alsa devel: Alsa Development Package
  • -
  • Xi devel: libXi.so Development Package
  • -
-
-

- The freetype 2.3 packages don't seem to be available, - but the freetype 2.3 sources can be downloaded, built, - and installed easily enough from - - the freetype site. - Build and install with something like: -

- bash ./configure -
- make -
- sudo -u root make install -
-

- Mercurial packages could not be found easily, but a Google - search should find ones, and they usually include Python if - it's needed. -

- -

Debian 5.0 (Lenny)

-
- After installing Debian 5 - you need to install several build dependencies. - The simplest way to install the build dependencies is to - execute the following commands as user root: -
- aptitude build-dep openjdk-7 -
- aptitude install openjdk-7-jdk libmotif-dev -
-

- In addition, it's necessary to set a few environment - variables for the build: -

- export LANG=C -
- export PATH="/usr/lib/jvm/java-7-openjdk/bin:${PATH}" -
-
- -

Ubuntu 12.04

-
- After installing Ubuntu 12.04 - you need to install several build dependencies. The simplest - way to do it is to execute the following commands: -
- sudo aptitude build-dep openjdk-7 -
- sudo aptitude install openjdk-7-jdk -
-

- In addition, it's necessary to set a few environment - variables for the build: -

- export LANG=C -
- export PATH="/usr/lib/jvm/java-7-openjdk/bin:${PATH}" -
-
- -

OpenSUSE 11.1

-
- After installing OpenSUSE 11.1 - you need to install several build dependencies. - The simplest way to install the build dependencies is to - execute the following commands: -
- sudo zypper source-install -d java-1_7_0-openjdk -
- sudo zypper install make -
-

- In addition, it is necessary to set a few environment - variables for the build: -

- export LANG=C -
- export PATH="/usr/lib/jvm/java-1.7.0-openjdk/bin:$[PATH}" -
-

- Finally, you need to unset the JAVA_HOME - environment variable: -

- export -n JAVA_HOME -
-
- -

Mandriva Linux One 2009 Spring

-
- After installing Mandriva - Linux One 2009 Spring - you need to install several build dependencies. - The simplest way to install the build dependencies is to - execute the following commands as user root: -
- urpmi java-1.7.0-openjdk-devel make gcc gcc-c++ - freetype-devel zip unzip libcups2-devel libxrender1-devel - libalsa2-devel libstc++-static-devel libxtst6-devel - libxi-devel -
-

- In addition, it is necessary to set a few environment - variables for the build: -

- export LANG=C -
- export PATH="/usr/lib/jvm/java-1.7.0-openjdk/bin:${PATH}" -
-
- -

OpenSolaris 2009.06

-
- After installing OpenSolaris 2009.06 - you need to install several build dependencies. - The simplest way to install the build dependencies is to - execute the following commands: -
- pfexec pkg install SUNWgmake SUNWj7dev - sunstudioexpress SUNWcups SUNWzip SUNWunzip SUNWxwhl - SUNWxorg-headers SUNWaudh SUNWfreetype2 -
-

- In addition, it is necessary to set a few environment - variables for the build: -

- export LANG=C -
- export PATH="/opt/SunStudioExpress/bin:${PATH}" -
-
- -
- -
- - - - - - -
-

End of OpenJDK README-builds.html document.
Please come again! -


- - +

--with-x=path
+ select the location of the X11 and xrender files.

+ +

The XRender Extension Headers are required for building the OpenJDK on + Solaris and Linux. The Linux header files are usually available from a + "Xrender" development package, it's recommended that you try and use the + package provided by the particular distribution of Linux that you are using. + The Solaris XRender header files is included with the other X11 header files + in the package SFWxwinc on new enough versions of Solaris and will be + installed in /usr/X11/include/X11/extensions/Xrender.h or + /usr/openwin/share/include/X11/extensions/Xrender.h

+ + +
+ +

+ +

Make

+ +

The basic invocation of the make utility looks like:

+ +
+

make all

+
+ +

This will start the build to the output directory containing the +"configuration" that was created by the configure script. Run make help for +more information on the available targets.

+ +

There are some of the make targets that are of general interest:

+ +
+

empty
+ build everything but no images

+ +

all
+ build everything including images

+ +

all-conf
+ build all configurations

+ +

images
+ create complete j2sdk and j2re images

+ +

install
+ install the generated images locally, typically in /usr/local

+ +

clean
+ remove all files generated by make, but not those generated by configure

+ +

dist-clean
+ remove all files generated by both and configure (basically killing the + configuration)

+ +

help
+ give some help on using make, including some interesting make targets

+
+ +
+ +

+ +

Testing

+ +

When the build is completed, you should see the generated binaries and +associated files in the j2sdk-image directory in the output directory. In +particular, the build/*/images/j2sdk-image/bin directory should contain +executables for the OpenJDK tools and utilities for that configuration. The +testing tool jtreg will be needed and can be found at: the jtreg +site. The provided regression tests in the +repositories can be run with the command:

+ +
+

cd test && make PRODUCT_HOME=`pwd`/../build/*/images/j2sdk-image all

+
+ +
+ +

+ +

Appendix A: Hints and Tips

+ +

+ +

FAQ

+ +

Q: The generated-configure.sh file looks horrible! How are you going to +edit it?
+A: The generated-configure.sh file is generated (think "compiled") by the +autoconf tools. The source code is in configure.ac and various .m4 files in +common/autoconf, which are much more readable.

+ +

Q: Why is the generated-configure.sh file checked in, if it is +generated?
+A: If it was not generated, every user would need to have the autoconf +tools installed, and re-generate the configure file as the first step. Our +goal is to minimize the work needed to be done by the user to start building +OpenJDK, and to minimize the number of external dependencies required.

+ +

Q: Do you require a specific version of autoconf for regenerating +generated-configure.sh?
+A: Yes, version 2.69 is required and should be easy enough to aquire on all +supported operating systems. The reason for this is to avoid large spurious +changes in generated-configure.sh.

+ +

Q: How do you regenerate generated-configure.sh after making changes to +the input files?
+A: Regnerating generated-configure.sh should always be done using the +script common/autoconf/autogen.sh to ensure that the correct files get +updated. This script should also be run after mercurial tries to merge +generated-configure.sh as a merge of the generated file is not guaranteed to +be correct.

+ +

Q: What are the files in common/makefiles/support/* for? They look like +gibberish.
+A: They are a somewhat ugly hack to compensate for command line length +limitations on certain platforms (Windows, Solaris). Due to a combination of +limitations in make and the shell, command lines containing too many files will +not work properly. These helper files are part of an elaborate hack that will +compress the command line in the makefile and then uncompress it safely. We're +not proud of it, but it does fix the problem. If you have any better +suggestions, we're all ears! :-)

+ +

Q: I want to see the output of the commands that make runs, like in the old +build. How do I do that?
+A: You specify the LOG variable to make. There are several log levels:

+ +
    +
  • warn -- Default and very quiet.
  • +
  • info -- Shows more progress information than warn.
  • +
  • debug -- Echos all command lines and prints all macro calls for +compilation definitions.
  • +
  • trace -- Echos all $(shell) command lines as well.
  • +
+ +

Q: When do I have to re-run configure?
+A: Normally you will run configure only once for creating a +configuration. You need to re-run configuration only if you want to change any +configuration options, or if you pull down changes to the configure script.

+ +

Q: I have added a new source file. Do I need to modify the makefiles?
+A: Normally, no. If you want to create e.g. a new native library, you will +need to modify the makefiles. But for normal file additions or removals, no +changes are needed. There are certan exceptions for some native libraries where +the source files are spread over many directories which also contain sources +for other libraries. In these cases it was simply easier to create include +lists rather than excludes.

+ +

Q: When I run configure --help, I see many strange options, like +--dvidir. What is this?
+A: Configure provides a slew of options by default, to all projects that +use autoconf. Most of them are not used in OpenJDK, so you can safely ignore +them. To list only OpenJDK specific features, use configure --help=short +instead.

+ +

Q: configure provides OpenJDK-specific features such as --with- +builddeps-server that are not described in this document. What about those?
+A: Try them out if you like! But be aware that most of these are +experimental features. Many of them don't do anything at all at the moment; the +option is just a placeholder. Others depend on pieces of code or infrastructure +that is currently not ready for prime time.

+ +

Q: How will you make sure you don't break anything?
+A: We have a script that compares the result of the new build system with +the result of the old. For most part, we aim for (and achieve) byte-by-byte +identical output. There are however technical issues with e.g. native binaries, +which might differ in a byte-by-byte comparison, even when building twice with +the old build system. For these, we compare relevant aspects (e.g. the symbol +table and file size). Note that we still don't have 100% equivalence, but we're +close.

+ +

Q: I noticed this thing X in the build that looks very broken by design. +Why don't you fix it?
+A: Our goal is to produce a build output that is as close as technically +possible to the old build output. If things were weird in the old build, they +will be weird in the new build. Often, things were weird before due to +obscurity, but in the new build system the weird stuff comes up to the surface. +The plan is to attack these things at a later stage, after the new build system +is established.

+ +

Q: The code in the new build system is not that well-structured. Will you +fix this?
+A: Yes! The new build system has grown bit by bit as we converted the old +system. When all of the old build system is converted, we can take a step back +and clean up the structure of the new build system. Some of this we plan to do +before replacing the old build system and some will need to wait until after.

+ +

Q: Is anything able to use the results of the new build's default make +target?
+A: Yes, this is the minimal (or roughly minimal) set of compiled output +needed for a developer to actually execute the newly built JDK. The idea is +that in an incremental development fashion, when doing a normal make, you +should only spend time recompiling what's changed (making it purely +incremental) and only do the work that's needed to actually run and test your +code. The packaging stuff that is part of the images target is not needed for +a normal developer who wants to test his new code. Even if it's quite fast, +it's still unnecessary. We're targeting sub-second incremental rebuilds! ;-) +(Or, well, at least single-digit seconds...)

+ +

Q: I usually set a specific environment variable when building, but I can't +find the equivalent in the new build. What should I do?
+A: It might very well be that we have neglected to add support for an +option that was actually used from outside the build system. Email us and we +will add support for it!

+ +

+ +

Build Performance Tips

+ +

Building OpenJDK requires a lot of horsepower. Some of the build tools can be +adjusted to utilize more or less of resources such as parallel threads and +memory. The configure script analyzes your system and selects reasonable +values for such options based on your hardware. If you encounter resource +problems, such as out of memory conditions, you can modify the detected values +with:

+ +
    +
  • --with-num-cores -- number of cores in the build system, e.g. +--with-num-cores=8
  • +
  • --with-memory-size -- memory (in MB) available in the build system, +e.g. --with-memory-size=1024
  • +
+ +

It might also be necessary to specify the JVM arguments passed to the Bootstrap +JDK, using e.g. --with-boot-jdk-jvmargs="-Xmx8G -enableassertions". Doing +this will override the default JVM arguments passed to the Bootstrap JDK.

+ +

One of the top goals of the new build system is to improve the build +performance and decrease the time needed to build. This will soon also apply to +the java compilation when the Smart Javac wrapper is making its way into jdk8. +It can be tried in the build-infra repository already. You are likely to find +that the new build system is faster than the old one even without this feature.

+ +

At the end of a successful execution of configure, you will get a performance +summary, indicating how well the build will perform. Here you will also get +performance hints. If you want to build fast, pay attention to those!

+ +

Building with ccache

+ +

A simple way to radically speed up compilation of native code +(typically hotspot and native libraries in JDK) is to install +ccache. This will cache and reuse prior compilation results, if the +source code is unchanged. However, ccache versions prior to 3.1.4 does +not work correctly with the precompiled headers used in OpenJDK. So if +your platform supports ccache at 3.1.4 or later, we highly recommend +installing it. This is currently only supported on linux.

+ +

Building on local disk

+ +

If you are using network shares, e.g. via NFS, for your source code, make sure +the build directory is situated on local disk. The performance penalty is +extremely high for building on a network share, close to unusable.

+ +

Building only one JVM

+ +

The old build builds multiple JVMs on 32-bit systems (client and server; and on +Windows kernel as well). In the new build we have changed this default to only +build server when it's available. This improves build times for those not +interested in multiple JVMs. To mimic the old behavior on platforms that +support it, use --with-jvm-variants=client,server.

+ +

Selecting the number of cores to build on

+ +

By default, configure will analyze your machine and run the make process in +parallel with as many threads as you have cores. This behavior can be +overridden, either "permanently" (on a configure basis) using +--with-num-cores=N or for a single build only (on a make basis), using +make JOBS=N.

+ +

If you want to make a slower build just this time, to save some CPU power for +other processes, you can run e.g. make JOBS=2. This will force the makefiles +to only run 2 parallel processes, or even make JOBS=1 which will disable +parallelism.

+ +

If you want to have it the other way round, namely having slow builds default +and override with fast if you're impatient, you should call configure with +--with-num-cores=2, making 2 the default. If you want to run with more cores, +run make JOBS=8

+ +

+ +

Troubleshooting

+ +

Solving build problems

+ +

If the build fails (and it's not due to a compilation error in a source file +you've changed), the first thing you should do is to re-run the build with more +verbosity. Do this by adding LOG=debug to your make command line.

+ +

The build log (with both stdout and stderr intermingled, basically the same as +you see on your console) can be found as build.log in your build directory.

+ +

You can ask for help on build problems with the new build system on either the +build-dev or the +build-infra-dev +mailing lists. Please include the relevant parts of the build log.

+ +

A build can fail for any number of reasons. Most failures are a result of +trying to build in an environment in which all the pre-build requirements have +not been met. The first step in troubleshooting a build failure is to recheck +that you have satisfied all the pre-build requirements for your platform. +Scanning the configure log is a good first step, making sure that what it +found makes sense for your system. Look for strange error messages or any +difficulties that configure had in finding things.

+ +

Some of the more common problems with builds are briefly described below, with +suggestions for remedies.

+ +
    +
  • Corrupted Bundles on Windows:
    +Some virus scanning software has been known to corrupt the downloading of +zip bundles. It may be necessary to disable the 'on access' or 'real time' +virus scanning features to prevent this corruption. This type of 'real time' +virus scanning can also slow down the build process significantly. +Temporarily disabling the feature, or excluding the build output directory +may be necessary to get correct and faster builds.

  • +
  • Slow Builds:
    +If your build machine seems to be overloaded from too many simultaneous C++ +compiles, try setting the JOBS=1 on the make command line. Then try +increasing the count slowly to an acceptable level for your system. Also:

    + +

    Creating the javadocs can be very slow, if you are running javadoc, consider +skipping that step.

    + +

    Faster CPUs, more RAM, and a faster DISK usually helps. The VM build tends +to be CPU intensive (many C++ compiles), and the rest of the JDK will often +be disk intensive.

    + +

    Faster compiles are possible using a tool called +ccache.

  • +
  • File time issues:
    +If you see warnings that refer to file time stamps, e.g.

    + +
    +

    Warning message: File 'xxx' has modification time in the future.
    +Warning message: Clock skew detected. Your build may be incomplete.

    +
    + +

    These warnings can occur when the clock on the build machine is out of sync +with the timestamps on the source files. Other errors, apparently unrelated +but in fact caused by the clock skew, can occur along with the clock skew +warnings. These secondary errors may tend to obscure the fact that the true +root cause of the problem is an out-of-sync clock.

    + +

    If you see these warnings, reset the clock on the build machine, run +"gmake clobber" or delete the directory containing the build output, and +restart the build from the beginning.

  • +
  • Error message: Trouble writing out table to disk
    +Increase the amount of swap space on your build machine. This could be +caused by overloading the system and it may be necessary to use:

    + +
    +

    make JOBS=1

    +
    + +

    to reduce the load on the system.

  • +
  • Error Message: libstdc++ not found:
    +This is caused by a missing libstdc++.a library. This is installed as part +of a specific package (e.g. libstdc++.so.devel.386). By default some 64-bit +Linux versions (e.g. Fedora) only install the 64-bit version of the +libstdc++ package. Various parts of the JDK build require a static link of +the C++ runtime libraries to allow for maximum portability of the built +images.

  • +
  • Linux Error Message: cannot restore segment prot after reloc
    +This is probably an issue with SELinux (See SELinux on +Wikipedia). Parts of the VM is built +without the -fPIC for performance reasons.

    + +

    To completely disable SELinux:

    + +
      +
    1. $ su root
    2. +
    3. # system-config-securitylevel
    4. +
    5. In the window that appears, select the SELinux tab
    6. +
    7. Disable SELinux
    8. +
    + +

    Alternatively, instead of completely disabling it you could disable just +this one check.

    + +
      +
    1. Select System->Administration->SELinux Management
    2. +
    3. In the SELinux Management Tool which appears, select "Boolean" from the +menu on the left
    4. +
    5. Expand the "Memory Protection" group
    6. +
    7. Check the first item, labeled "Allow all unconfined executables to use +libraries requiring text relocation ..."
    8. +
  • +
  • Windows Error Messages:
    +*** fatal error - couldn't allocate heap, ...
    +rm fails with "Directory not empty"
    +unzip fails with "cannot create ... Permission denied"
    +unzip fails with "cannot create ... Error 50"

    + +

    The CYGWIN software can conflict with other non-CYGWIN software. See the +CYGWIN FAQ section on BLODA (applications that interfere with +CYGWIN).

  • +
  • Windows Error Message: spawn failed
    +Try rebooting the system, or there could be some kind of issue with the disk +or disk partition being used. Sometimes it comes with a "Permission Denied" +message.

  • +
+ +
+ +

+ +

Appendix B: GNU make

+ +

The Makefiles in the OpenJDK are only valid when used with the GNU version of +the utility command make (usually called gmake on Solaris). A few notes +about using GNU make:

+ +
    +
  • You need GNU make version 3.81 or newer. If the GNU make utility on your +systems is not 3.81 or newer, see "Building GNU make".
  • +
  • Place the location of the GNU make binary in the PATH.
  • +
  • Solaris: Do NOT use /usr/bin/make on Solaris. If your Solaris system +has the software from the Solaris Developer Companion CD installed, you +should try and use gmake which will be located in either the /usr/bin, +/opt/sfw/bin or /usr/sfw/bin directory.
  • +
  • Windows: Make sure you start your build inside a bash shell.
  • +
  • Mac OS X: The XCode "command line tools" must be installed on your Mac.
  • +
+ +

Information on GNU make, and access to ftp download sites, are available on the +GNU make web site . The latest +source to GNU make is available at +ftp.gnu.org/pub/gnu/make/.

+ +

+ +

Building GNU make

+ +

First step is to get the GNU make 3.81 or newer source from +ftp.gnu.org/pub/gnu/make/. Building is a +little different depending on the OS but is basically done with:

+ +
  bash ./configure
+  make
+
+ +
+ +

+ +

Appendix C: Build Environments

+ +

Minimum Build Environments

+ +

This file often describes specific requirements for what we call the "minimum +build environments" (MBE) for this specific release of the JDK. What is listed +below is what the Oracle Release Engineering Team will use to build the Oracle +JDK product. Building with the MBE will hopefully generate the most compatible +bits that install on, and run correctly on, the most variations of the same +base OS and hardware architecture. In some cases, these represent what is often +called the least common denominator, but each Operating System has different +aspects to it.

+ +

In all cases, the Bootstrap JDK version minimum is critical, we cannot +guarantee builds will work with older Bootstrap JDK's. Also in all cases, more +RAM and more processors is better, the minimums listed below are simply +recommendations.

+ +

With Solaris and Mac OS X, the version listed below is the oldest release we +can guarantee builds and works, and the specific version of the compilers used +could be critical.

+ +

With Windows the critical aspect is the Visual Studio compiler used, which due +to it's runtime, generally dictates what Windows systems can do the builds and +where the resulting bits can be used.

+ +

NOTE: We expect a change here off these older Windows OS releases and to a +'less older' one, probably Windows 2008R2 X64.

+ +

With Linux, it was just a matter of picking a stable distribution that is a +good representative for Linux in general.

+ +

NOTE: We expect a change here from Fedora 9 to something else, but it has not +been completely determined yet, possibly Ubuntu 12.04 X64, unbiased community +feedback would be welcome on what a good choice would be here.

+ +

It is understood that most developers will NOT be using these specific +versions, and in fact creating these specific versions may be difficult due to +the age of some of this software. It is expected that developers are more often +using the more recent releases and distributions of these operating systems.

+ +

Compilation problems with newer or different C/C++ compilers is a common +problem. Similarly, compilation problems related to changes to the +/usr/include or system header files is also a common problem with older, +newer, or unreleased OS versions. Please report these types of problems as bugs +so that they can be dealt with accordingly.

+ +
+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Base OS and ArchitectureOSC/C++ CompilerBootstrap JDKProcessorsRAM MinimumDISK Needs
Linux X86 (32-bit) and X64 (64-bit)Fedora 9gcc 4.3 JDK 7u72 or more1 GB6 GB
Solaris SPARC (32-bit) and SPARCV9 (64-bit)Solaris 10 Update 6Studio 12 Update 1 + patchesJDK 7u74 or more4 GB8 GB
Solaris X86 (32-bit) and X64 (64-bit)Solaris 10 Update 6Studio 12 Update 1 + patchesJDK 7u74 or more4 GB8 GB
Windows X86 (32-bit)Windows XPMicrosoft Visual Studio C++ 2010 Professional EditionJDK 7u72 or more2 GB6 GB
Windows X64 (64-bit)Windows Server 2003 - Enterprise x64 EditionMicrosoft Visual Studio C++ 2010 Professional EditionJDK 7u72 or more2 GB6 GB
Mac OS X X64 (64-bit)Mac OS X 10.7 "Lion"XCode 4.5.2 or newerJDK 7u72 or more4 GB6 GB

+
+ +
+ +

+ +

Specific Developer Build Environments

+ +

We won't be listing all the possible environments, but we will try to provide +what information we have available to us.

+ +

NOTE: The community can help out by updating this part of the document.

+ +

Fedora

+ +

After installing the latest Fedora you need to +install several build dependencies. The simplest way to do it is to execute the +following commands as user root:

+ +
  yum-builddep java-1.7.0-openjdk
+  yum install gcc gcc-c++
+
+ +

In addition, it's necessary to set a few environment variables for the build:

+ +
  export LANG=C
+  export PATH="/usr/lib/jvm/java-openjdk/bin:${PATH}"
+
+ +

CentOS 5.5

+ +

After installing CentOS 5.5 you need to make sure you +have the following Development bundles installed:

+ +
    +
  • Development Libraries
  • +
  • Development Tools
  • +
  • Java Development
  • +
  • X Software Development (Including XFree86-devel)
  • +
+ +

Plus the following packages:

+ +
    +
  • cups devel: Cups Development Package
  • +
  • alsa devel: Alsa Development Package
  • +
  • Xi devel: libXi.so Development Package
  • +
+ +

The freetype 2.3 packages don't seem to be available, but the freetype 2.3 +sources can be downloaded, built, and installed easily enough from the +freetype site. Build and install +with something like:

+ +
  bash ./configure
+  make
+  sudo -u root make install
+
+ +

Mercurial packages could not be found easily, but a Google search should find +ones, and they usually include Python if it's needed.

+ +

Debian 5.0 (Lenny)

+ +

After installing Debian 5 you need to install several +build dependencies. The simplest way to install the build dependencies is to +execute the following commands as user root:

+ +
  aptitude build-dep openjdk-7
+  aptitude install openjdk-7-jdk libmotif-dev
+
+ +

In addition, it's necessary to set a few environment variables for the build:

+ +
  export LANG=C
+  export PATH="/usr/lib/jvm/java-7-openjdk/bin:${PATH}"
+
+ +

Ubuntu 12.04

+ +

After installing Ubuntu 12.04 you need to install several +build dependencies. The simplest way to do it is to execute the following +commands:

+ +
  sudo aptitude build-dep openjdk-7
+  sudo aptitude install openjdk-7-jdk
+
+ +

In addition, it's necessary to set a few environment variables for the build:

+ +
  export LANG=C
+  export PATH="/usr/lib/jvm/java-7-openjdk/bin:${PATH}"
+
+ +

OpenSUSE 11.1

+ +

After installing OpenSUSE 11.1 you need to install +several build dependencies. The simplest way to install the build dependencies +is to execute the following commands:

+ +
  sudo zypper source-install -d java-1_7_0-openjdk
+  sudo zypper install make
+
+ +

In addition, it is necessary to set a few environment variables for the build:

+ +
  export LANG=C
+  export PATH="/usr/lib/jvm/java-1.7.0-openjdk/bin:$[PATH}"
+
+ +

Finally, you need to unset the JAVA_HOME environment variable:

+ +
  export -n JAVA_HOME`
+
+ +

Mandriva Linux One 2009 Spring

+ +

After installing Mandriva Linux One 2009 Spring you need +to install several build dependencies. The simplest way to install the build +dependencies is to execute the following commands as user root:

+ +
  urpmi java-1.7.0-openjdk-devel make gcc gcc-c++ freetype-devel zip unzip
+    libcups2-devel libxrender1-devel libalsa2-devel libstc++-static-devel
+    libxtst6-devel libxi-devel
+
+ +

In addition, it is necessary to set a few environment variables for the build:

+ +
  export LANG=C
+  export PATH="/usr/lib/jvm/java-1.7.0-openjdk/bin:${PATH}"
+
+ +

OpenSolaris 2009.06

+ +

After installing OpenSolaris 2009.06 you need to +install several build dependencies. The simplest way to install the build +dependencies is to execute the following commands:

+ +
  pfexec pkg install SUNWgmake SUNWj7dev sunstudioexpress SUNWcups SUNWzip
+    SUNWunzip SUNWxwhl SUNWxorg-headers SUNWaudh SUNWfreetype2
+
+ +

In addition, it is necessary to set a few environment variables for the build:

+ +
  export LANG=C
+  export PATH="/opt/SunStudioExpress/bin:${PATH}"
+
+ +
+ +

End of the OpenJDK build README document.

+ +

Please come again!

+ diff --git a/README-builds.md b/README-builds.md new file mode 100644 index 00000000000..364fd661e3c --- /dev/null +++ b/README-builds.md @@ -0,0 +1,1266 @@ +![OpenJDK](http://openjdk.java.net/images/openjdk.png) +# OpenJDK Build README + +***** + + +## Introduction + +This README file contains build instructions for the +[OpenJDK](http://openjdk.java.net). Building the source code for the OpenJDK +requires a certain degree of technical expertise. + +### !!!!!!!!!!!!!!! THIS IS A MAJOR RE-WRITE of this document. !!!!!!!!!!!!! + +Some Headlines: + + * The build is now a "`configure && make`" style build + * Any GNU make 3.81 or newer should work + * The build should scale, i.e. more processors should cause the build to be + done in less wall-clock time + * Nested or recursive make invocations have been significantly reduced, + as has the total fork/exec or spawning of sub processes during the build + * Windows MKS usage is no longer supported + * Windows Visual Studio `vsvars*.bat` and `vcvars*.bat` files are run + automatically + * Ant is no longer used when building the OpenJDK + * Use of ALT_* environment variables for configuring the build is no longer + supported + +***** + +## Contents + + * [Introduction](#introduction) + * [Use of Mercurial](#hg) + * [Getting the Source](#get_source) + * [Repositories](#repositories) + * [Building](#building) + * [System Setup](#setup) + * [Linux](#linux) + * [Solaris](#solaris) + * [Mac OS X](#macosx) + * [Windows](#windows) + * [Configure](#configure) + * [Make](#make) + * [Testing](#testing) + +***** + + * [Appendix A: Hints and Tips](#hints) + * [FAQ](#faq) + * [Build Performance Tips](#performance) + * [Troubleshooting](#troubleshooting) + * [Appendix B: GNU Make Information](#gmake) + * [Appendix C: Build Environments](#buildenvironments) + +***** + + +## Use of Mercurial + +The OpenJDK sources are maintained with the revision control system +[Mercurial](http://mercurial.selenic.com/wiki/Mercurial). If you are new to +Mercurial, please see the [Beginner Guides](http://mercurial.selenic.com/wiki/ +BeginnersGuides) or refer to the [Mercurial Book](http://hgbook.red-bean.com/). +The first few chapters of the book provide an excellent overview of Mercurial, +what it is and how it works. + +For using Mercurial with the OpenJDK refer to the [Developer Guide: Installing +and Configuring Mercurial](http://openjdk.java.net/guide/ +repositories.html#installConfig) section for more information. + + +### Getting the Source + +To get the entire set of OpenJDK Mercurial repositories use the script +`get_source.sh` located in the root repository: + + hg clone http://hg.openjdk.java.net/jdk8/jdk8 YourOpenJDK + cd YourOpenJDK + bash ./get_source.sh + +Once you have all the repositories, keep in mind that each repository is its +own independent repository. You can also re-run `./get_source.sh` anytime to +pull over all the latest changesets in all the repositories. This set of +nested repositories has been given the term "forest" and there are various +ways to apply the same `hg` command to each of the repositories. For +example, the script `make/scripts/hgforest.sh` can be used to repeat the +same `hg` command on every repository, e.g. + + cd YourOpenJDK + bash ./make/scripts/hgforest.sh status + + +### Repositories + +The set of repositories and what they contain: + + * **. (root)** contains common configure and makefile logic + * **hotspot** contains source code and make files for building the OpenJDK + Hotspot Virtual Machine + * **langtools** contains source code for the OpenJDK javac and language tools + * **jdk** contains source code and make files for building the OpenJDK runtime + libraries and misc files + * **jaxp** contains source code for the OpenJDK JAXP functionality + * **jaxws** contains source code for the OpenJDK JAX-WS functionality + * **corba** contains source code for the OpenJDK Corba functionality + * **nashorn** contains source code for the OpenJDK JavaScript implementation + +### Repository Source Guidelines + +There are some very basic guidelines: + + * Use of whitespace in source files (.java, .c, .h, .cpp, and .hpp files) is + restricted. No TABs, no trailing whitespace on lines, and files should not + terminate in more than one blank line. + * Files with execute permissions should not be added to the source + repositories. + * All generated files need to be kept isolated from the files maintained or + managed by the source control system. The standard area for generated files + is the top level `build/` directory. + * The default build process should be to build the product and nothing else, + in one form, e.g. a product (optimized), debug (non-optimized, -g plus + assert logic), or fastdebug (optimized, -g plus assert logic). + * The `.hgignore` file in each repository must exist and should include + `^build/`, `^dist/` and optionally any `nbproject/private` directories. **It + should NEVER** include anything in the `src/` or `test/` or any managed + directory area of a repository. + * Directory names and file names should never contain blanks or non-printing + characters. + * Generated source or binary files should NEVER be added to the repository + (that includes `javah` output). There are some exceptions to this rule, in + particular with some of the generated configure scripts. + * Files not needed for typical building or testing of the repository should + not be added to the repository. + +***** + + +## Building + +The very first step in building the OpenJDK is making sure the system itself +has everything it needs to do OpenJDK builds. Once a system is setup, it +generally doesn't need to be done again. + +Building the OpenJDK is now done with running a `configure` script which will +try and find and verify you have everything you need, followed by running +`make`, e.g. + +> **`bash ./configure`** +> **`make all`** + +Where possible the `configure` script will attempt to located the various +components in the default locations or via component specific variable +settings. When the normal defaults fail or components cannot be found, +additional `configure` options may be necessary to help `configure` find the +necessary tools for the build, or you may need to re-visit the setup of your +system due to missing software packages. + +**NOTE:** The `configure` script file does not have execute permissions and +will need to be explicitly run with `bash`, see the source guidelines. + +***** + + +### System Setup + +Before even attempting to use a system to build the OpenJDK there are some very +basic system setups needed. For all systems: + + * Be sure the GNU make utility is version 3.81 or newer, e.g. + run "`make -version`" + + + * Install a Bootstrap JDK. All OpenJDK builds require access to a previously + released JDK called the _bootstrap JDK_ or _boot JDK._ The general rule is + that the bootstrap JDK must be an instance of the previous major release of + the JDK. In addition, there may be a requirement to use a release at or + beyond a particular update level. + + **_Building JDK 8 requires use of a version of JDK 7 this is at Update 7 + or newer. JDK 8 developers should not use JDK 8 as the boot JDK, to ensure + that JDK 8 dependencies are not introduced into the parts of the system + that are built with JDK 7._** + + The JDK 7 binaries can be downloaded from Oracle's [JDK 7 download + site](http://www.oracle.com/technetwork/java/javase/downloads/index.html). + For build performance reasons it is very important that this bootstrap JDK + be made available on the local disk of the machine doing the build. You + should add its `bin` directory to the `PATH` environment variable. If + `configure` has any issues finding this JDK, you may need to use the + `configure` option `--with-boot-jdk`. + + * Ensure that GNU make, the Bootstrap JDK, and the compilers are all in your + PATH environment variable. + +And for specific systems: + + * **Linux** + + Install all the software development packages needed including + [alsa](#alsa), [freetype](#freetype), [cups](#cups), and + [xrender](#xrender). See [specific system packages](#SDBE). + + * **Solaris** + + Install all the software development packages needed including [Studio + Compilers](#studio), [freetype](#freetype), [cups](#cups), and + [xrender](#xrender). See [specific system packages](#SDBE). + + * **Windows** + + * Install one of [CYGWIN](#cygwin) or [MinGW/MSYS](#msys) + * Install [Visual Studio 2010](#vs2010) + + * **Mac OS X** + + Install [XCode 4.5.2](https://developer.apple.com/xcode/) and also + install the "Command line tools" found under the preferences pane + "Downloads" + + +#### Linux + +With Linux, try and favor the system packages over building your own or getting +packages from other areas. Most Linux builds should be possible with the +system's available packages. + +Note that some Linux systems have a habit of pre-populating your environment +variables for you, for example `JAVA_HOME` might get pre-defined for you to +refer to the JDK installed on your Linux system. You will need to unset +`JAVA_HOME`. It's a good idea to run `env` and verify the environment variables +you are getting from the default system settings make sense for building the +OpenJDK. + + +#### Solaris + + +##### Studio Compilers + +At a minimum, the [Studio 12 Update 1 Compilers](http://www.oracle.com/ +technetwork/server-storage/solarisstudio/downloads/index.htm) (containing +version 5.10 of the C and C++ compilers) is required, including specific +patches. + +The Solaris SPARC patch list is: + + * 118683-05: SunOS 5.10: Patch for profiling libraries and assembler + * 119963-21: SunOS 5.10: Shared library patch for C++ + * 120753-08: SunOS 5.10: Microtasking libraries (libmtsk) patch + * 128228-09: Sun Studio 12 Update 1: Patch for Sun C++ Compiler + * 141860-03: Sun Studio 12 Update 1: Patch for Compiler Common patch for Sun C + C++ F77 F95 + * 141861-05: Sun Studio 12 Update 1: Patch for Sun C Compiler + * 142371-01: Sun Studio 12.1 Update 1: Patch for dbx + * 143384-02: Sun Studio 12 Update 1: Patch for debuginfo handling + * 143385-02: Sun Studio 12 Update 1: Patch for Compiler Common patch for Sun C + C++ F77 F95 + * 142369-01: Sun Studio 12.1: Patch for Performance Analyzer Tools + +The Solaris X86 patch list is: + + * 119961-07: SunOS 5.10_x86, x64, Patch for profiling libraries and assembler + * 119964-21: SunOS 5.10_x86: Shared library patch for C++\_x86 + * 120754-08: SunOS 5.10_x86: Microtasking libraries (libmtsk) patch + * 141858-06: Sun Studio 12 Update 1_x86: Sun Compiler Common patch for x86 + backend + * 128229-09: Sun Studio 12 Update 1_x86: Patch for C++ Compiler + * 142363-05: Sun Studio 12 Update 1_x86: Patch for C Compiler + * 142368-01: Sun Studio 12.1_x86: Patch for Performance Analyzer Tools + +Place the `bin` directory in `PATH`. + +The Oracle Solaris Studio Express compilers at: [Oracle Solaris Studio Express +Download site](http://www.oracle.com/technetwork/server-storage/solarisstudio/ +downloads/index-jsp-142582.html) are also an option, although these compilers +have not been extensively used yet. + + +#### Windows + +##### Windows Unix Toolkit + +Building on Windows requires a Unix-like environment, notably a Unix-like +shell. There are several such environments available of which +[Cygwin](http://www.cygwin.com/) and +[MinGW/MSYS](http://www.mingw.org/wiki/MSYS) are currently supported for the +OpenJDK build. One of the differences of these systems from standard Windows +tools is the way they handle Windows path names, particularly path names which +contain spaces, backslashes as path separators and possibly drive letters. +Depending on the use case and the specifics of each environment these path +problems can be solved by a combination of quoting whole paths, translating +backslashes to forward slashes, escaping backslashes with additional +backslashes and translating the path names to their ["8.3" +version](http://en.wikipedia.org/wiki/8.3_filename). + + +###### CYGWIN + +CYGWIN is an open source, Linux-like environment which tries to emulate a +complete POSIX layer on Windows. It tries to be smart about path names and can +usually handle all kinds of paths if they are correctly quoted or escaped +although internally it maps drive letters `:` to a virtual directory +`/cygdrive/`. + +You can always use the `cygpath` utility to map pathnames with spaces or the +backslash character into the `C:/` style of pathname (called 'mixed'), e.g. +`cygpath -s -m ""`. + +Note that the use of CYGWIN creates a unique problem with regards to setting +[`PATH`](#path). Normally on Windows the `PATH` variable contains directories +separated with the ";" character (Solaris and Linux use ":"). With CYGWIN, it +uses ":", but that means that paths like "C:/path" cannot be placed in the +CYGWIN version of `PATH` and instead CYGWIN uses something like +`/cygdrive/c/path` which CYGWIN understands, but only CYGWIN understands. + +The OpenJDK build requires CYGWIN version 1.7.16 or newer. Information about +CYGWIN can be obtained from the CYGWIN website at +[www.cygwin.com](http://www.cygwin.com). + +By default CYGWIN doesn't install all the tools required for building the +OpenJDK. Along with the default installation, you need to install the following +tools. + +> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Binary NameCategoryPackageDescription
ar.exeDevelbinutilsThe GNU assembler, linker and binary utilities
make.exeDevelmakeThe GNU version of the 'make' utility built for CYGWIN
m4.exeInterpretersm4GNU implementation of the traditional Unix macro processor
cpio.exeUtilscpioA program to manage archives of files
gawk.exeUtilsawkPattern-directed scanning and processing language
file.exeUtilsfileDetermines file type using 'magic' numbers
zip.exeArchivezipPackage and compress (archive) files
unzip.exeArchiveunzipExtract compressed files in a ZIP archive
free.exeSystemprocpsDisplay amount of free and used memory in the system
+ +Note that the CYGWIN software can conflict with other non-CYGWIN software on +your Windows system. CYGWIN provides a [FAQ](http://cygwin.com/faq/ +faq.using.html) for known issues and problems, of particular interest is the +section on [BLODA (applications that interfere with +CYGWIN)](http://cygwin.com/faq/faq.using.html#faq.using.bloda). + + +###### MinGW/MSYS + +MinGW ("Minimalist GNU for Windows") is a collection of free Windows specific +header files and import libraries combined with GNU toolsets that allow one to +produce native Windows programs that do not rely on any 3rd-party C runtime +DLLs. MSYS is a supplement to MinGW which allows building applications and +programs which rely on traditional UNIX tools to be present. Among others this +includes tools like `bash` and `make`. See [MinGW/MSYS](http://www.mingw.org/ +wiki/MSYS) for more information. + +Like Cygwin, MinGW/MSYS can handle different types of path formats. They are +internally converted to paths with forward slashes and drive letters +`:` replaced by a virtual directory `/`. Additionally, MSYS +automatically detects binaries compiled for the MSYS environment and feeds them +with the internal, Unix-style path names. If native Windows applications are +called from within MSYS programs their path arguments are automatically +converted back to Windows style path names with drive letters and backslashes +as path separators. This may cause problems for Windows applications which use +forward slashes as parameter separator (e.g. `cl /nologo /I`) because MSYS may +wrongly [replace such parameters by drive letters](http://mingw.org/wiki/ +Posix_path_conversion). + +In addition to the tools which will be installed by default, you have to +manually install the `msys-zip` and `msys-unzip` packages. This can be easily +done with the MinGW command line installer: + + mingw-get.exe install msys-zip + mingw-get.exe install msys-unzip + + +##### Visual Studio 2010 Compilers + +The 32-bit and 64-bit OpenJDK Windows build requires Microsoft Visual Studio +C++ 2010 (VS2010) Professional Edition or Express compiler. The compiler and +other tools are expected to reside in the location defined by the variable +`VS100COMNTOOLS` which is set by the Microsoft Visual Studio installer. + +Only the C++ part of VS2010 is needed. Try to let the installation go to the +default install directory. Always reboot your system after installing VS2010. +The system environment variable VS100COMNTOOLS should be set in your +environment. + +Make sure that TMP and TEMP are also set in the environment and refer to +Windows paths that exist, like `C:\temp`, not `/tmp`, not `/cygdrive/c/temp`, +and not `C:/temp`. `C:\temp` is just an example, it is assumed that this area +is private to the user, so by default after installs you should see a unique +user path in these variables. + + +#### Mac OS X + +Make sure you get the right XCode version. + +***** + + +### Configure + +The basic invocation of the `configure` script looks like: + +> **`bash ./configure [options]`** + +This will create an output directory containing the "configuration" and setup +an area for the build result. This directory typically looks like: + +> **`build/linux-x64-normal-server-release`** + +`configure` will try to figure out what system you are running on and where all +necessary build components are. If you have all prerequisites for building +installed, it should find everything. If it fails to detect any component +automatically, it will exit and inform you about the problem. When this +happens, read more below in [the `configure` options](#configureoptions). + +Some examples: + +> **Windows 32bit build with freetype specified:** +> `bash ./configure --with-freetype=/cygdrive/c/freetype-i586 --with-target- +bits=32` + +> **Debug 64bit Build:** +> `bash ./configure --enable-debug --with-target-bits=64` + + +#### Configure Options + +Complete details on all the OpenJDK `configure` options can be seen with: + +> **`bash ./configure --help=short`** + +Use `-help` to see all the `configure` options available. You can generate any +number of different configurations, e.g. debug, release, 32, 64, etc. + +Some of the more commonly used `configure` options are: + +> **`--enable-debug`** +> set the debug level to fastdebug (this is a shorthand for `--with-debug- + level=fastdebug`) + + +> **`--with-alsa=`**_path_ +> select the location of the Advanced Linux Sound Architecture (ALSA) + +> Version 0.9.1 or newer of the ALSA files are required for building the + OpenJDK on Linux. These Linux files are usually available from an "alsa" of + "libasound" development package, and it's highly recommended that you try + and use the package provided by the particular version of Linux that you are + using. + +> **`--with-boot-jdk=`**_path_ +> select the [Bootstrap JDK](#bootjdk) + +> **`--with-boot-jdk-jvmargs=`**"_args_" +> provide the JVM options to be used to run the [Bootstrap JDK](#bootjdk) + +> **`--with-cacerts=`**_path_ +> select the path to the cacerts file. + +> See [Certificate Authority on Wikipedia](http://en.wikipedia.org/wiki/ + Certificate_Authority) for a better understanding of the Certificate + Authority (CA). A certificates file named "cacerts" represents a system-wide + keystore with CA certificates. In JDK and JRE binary bundles, the "cacerts" + file contains root CA certificates from several public CAs (e.g., VeriSign, + Thawte, and Baltimore). The source contain a cacerts file without CA root + certificates. Formal JDK builders will need to secure permission from each + public CA and include the certificates into their own custom cacerts file. + Failure to provide a populated cacerts file will result in verification + errors of a certificate chain during runtime. By default an empty cacerts + file is provided and that should be fine for most JDK developers. + + +> **`--with-cups=`**_path_ +> select the CUPS install location + +> The Common UNIX Printing System (CUPS) Headers are required for building the + OpenJDK on Solaris and Linux. The Solaris header files can be obtained by + installing the package **SFWcups** from the Solaris Software Companion + CD/DVD, these often will be installed into the directory `/opt/sfw/cups`. + +> The CUPS header files can always be downloaded from + [www.cups.org](http://www.cups.org). + +> **`--with-cups-include=`**_path_ +> select the CUPS include directory location + +> **`--with-debug-level=`**_level_ +> select the debug information level of release, fastdebug, or slowdebug + +> **`--with-dev-kit=`**_path_ +> select location of the compiler install or developer install location + + +> **`--with-freetype=`**_path_ +> select the freetype files to use. + +> Expecting the freetype libraries under `lib/` and the headers under + `include/`. + +> Version 2.3 or newer of FreeType is required. On Unix systems required files + can be available as part of your distribution (while you still may need to + upgrade them). Note that you need development version of package that + includes both the FreeType library and header files. + +> You can always download latest FreeType version from the [FreeType + website](http://www.freetype.org). Building the freetype 2 libraries from + scratch is also possible, however on Windows refer to the [Windows FreeType + DLL build instructions](http://freetype.freedesktop.org/wiki/FreeType_DLL). + +> Note that by default FreeType is built with byte code hinting support + disabled due to licensing restrictions. In this case, text appearance and + metrics are expected to differ from Sun's official JDK build. See the + [SourceForge FreeType2 Home Page](http://freetype.sourceforge.net/freetype2) + for more information. + +> **`--with-import-hotspot=`**_path_ +> select the location to find hotspot binaries from a previous build to avoid + building hotspot + +> **`--with-target-bits=`**_arg_ +> select 32 or 64 bit build + +> **`--with-jvm-variants=`**_variants_ +> select the JVM variants to build from, comma separated list that can + include: server, client, kernel, zero and zeroshark + +> **`--with-memory-size=`**_size_ +> select the RAM size that GNU make will think this system has + +> **`--with-msvcr-dll=`**_path_ +> select the `msvcr100.dll` file to include in the Windows builds (C/C++ + runtime library for Visual Studio). + +> This is usually picked up automatically from the redist directories of + Visual Studio 2010. + +> **`--with-num-cores=`**_cores_ +> select the number of cores to use (processor count or CPU count) + + +> **`--with-x=`**_path_ +> select the location of the X11 and xrender files. + +> The XRender Extension Headers are required for building the OpenJDK on + Solaris and Linux. The Linux header files are usually available from a + "Xrender" development package, it's recommended that you try and use the + package provided by the particular distribution of Linux that you are using. + The Solaris XRender header files is included with the other X11 header files + in the package **SFWxwinc** on new enough versions of Solaris and will be + installed in `/usr/X11/include/X11/extensions/Xrender.h` or + `/usr/openwin/share/include/X11/extensions/Xrender.h` + +***** + + +### Make + +The basic invocation of the `make` utility looks like: + +> **`make all`** + +This will start the build to the output directory containing the +"configuration" that was created by the `configure` script. Run `make help` for +more information on the available targets. + +There are some of the make targets that are of general interest: + +> _empty_ +> build everything but no images + +> **`all`** +> build everything including images + +> **`all-conf`** +> build all configurations + +> **`images`** +> create complete j2sdk and j2re images + +> **`install`** +> install the generated images locally, typically in `/usr/local` + +> **`clean`** +> remove all files generated by make, but not those generated by `configure` + +> **`dist-clean`** +> remove all files generated by both and `configure` (basically killing the + configuration) + +> **`help`** +> give some help on using `make`, including some interesting make targets + +***** + + +## Testing + +When the build is completed, you should see the generated binaries and +associated files in the `j2sdk-image` directory in the output directory. In +particular, the `build/*/images/j2sdk-image/bin` directory should contain +executables for the OpenJDK tools and utilities for that configuration. The +testing tool `jtreg` will be needed and can be found at: [the jtreg +site](http://openjdk.java.net/jtreg/). The provided regression tests in the +repositories can be run with the command: + +> **``cd test && make PRODUCT_HOME=`pwd`/../build/*/images/j2sdk-image all``** + +***** + + +## Appendix A: Hints and Tips + + +### FAQ + +**Q:** The `generated-configure.sh` file looks horrible! How are you going to +edit it? +**A:** The `generated-configure.sh` file is generated (think "compiled") by the +autoconf tools. The source code is in `configure.ac` and various .m4 files in +common/autoconf, which are much more readable. + +**Q:** Why is the `generated-configure.sh` file checked in, if it is +generated? +**A:** If it was not generated, every user would need to have the autoconf +tools installed, and re-generate the `configure` file as the first step. Our +goal is to minimize the work needed to be done by the user to start building +OpenJDK, and to minimize the number of external dependencies required. + +**Q:** Do you require a specific version of autoconf for regenerating +`generated-configure.sh`? +**A:** Yes, version 2.69 is required and should be easy enough to aquire on all +supported operating systems. The reason for this is to avoid large spurious +changes in `generated-configure.sh`. + +**Q:** How do you regenerate `generated-configure.sh` after making changes to +the input files? +**A:** Regnerating `generated-configure.sh` should always be done using the +script `common/autoconf/autogen.sh` to ensure that the correct files get +updated. This script should also be run after mercurial tries to merge +`generated-configure.sh` as a merge of the generated file is not guaranteed to +be correct. + +**Q:** What are the files in `common/makefiles/support/*` for? They look like +gibberish. +**A:** They are a somewhat ugly hack to compensate for command line length +limitations on certain platforms (Windows, Solaris). Due to a combination of +limitations in make and the shell, command lines containing too many files will +not work properly. These helper files are part of an elaborate hack that will +compress the command line in the makefile and then uncompress it safely. We're +not proud of it, but it does fix the problem. If you have any better +suggestions, we're all ears! :-) + +**Q:** I want to see the output of the commands that make runs, like in the old +build. How do I do that? +**A:** You specify the `LOG` variable to make. There are several log levels: + + * **`warn`** -- Default and very quiet. + * **`info`** -- Shows more progress information than warn. + * **`debug`** -- Echos all command lines and prints all macro calls for + compilation definitions. + * **`trace`** -- Echos all $(shell) command lines as well. + +**Q:** When do I have to re-run `configure`? +**A:** Normally you will run `configure` only once for creating a +configuration. You need to re-run configuration only if you want to change any +configuration options, or if you pull down changes to the `configure` script. + +**Q:** I have added a new source file. Do I need to modify the makefiles? +**A:** Normally, no. If you want to create e.g. a new native library, you will +need to modify the makefiles. But for normal file additions or removals, no +changes are needed. There are certan exceptions for some native libraries where +the source files are spread over many directories which also contain sources +for other libraries. In these cases it was simply easier to create include +lists rather than excludes. + +**Q:** When I run `configure --help`, I see many strange options, like +`--dvidir`. What is this? +**A:** Configure provides a slew of options by default, to all projects that +use autoconf. Most of them are not used in OpenJDK, so you can safely ignore +them. To list only OpenJDK specific features, use `configure --help=short` +instead. + +**Q:** `configure` provides OpenJDK-specific features such as `--with- +builddeps-server` that are not described in this document. What about those? +**A:** Try them out if you like! But be aware that most of these are +experimental features. Many of them don't do anything at all at the moment; the +option is just a placeholder. Others depend on pieces of code or infrastructure +that is currently not ready for prime time. + +**Q:** How will you make sure you don't break anything? +**A:** We have a script that compares the result of the new build system with +the result of the old. For most part, we aim for (and achieve) byte-by-byte +identical output. There are however technical issues with e.g. native binaries, +which might differ in a byte-by-byte comparison, even when building twice with +the old build system. For these, we compare relevant aspects (e.g. the symbol +table and file size). Note that we still don't have 100% equivalence, but we're +close. + +**Q:** I noticed this thing X in the build that looks very broken by design. +Why don't you fix it? +**A:** Our goal is to produce a build output that is as close as technically +possible to the old build output. If things were weird in the old build, they +will be weird in the new build. Often, things were weird before due to +obscurity, but in the new build system the weird stuff comes up to the surface. +The plan is to attack these things at a later stage, after the new build system +is established. + +**Q:** The code in the new build system is not that well-structured. Will you +fix this? +**A:** Yes! The new build system has grown bit by bit as we converted the old +system. When all of the old build system is converted, we can take a step back +and clean up the structure of the new build system. Some of this we plan to do +before replacing the old build system and some will need to wait until after. + +**Q:** Is anything able to use the results of the new build's default make +target? +**A:** Yes, this is the minimal (or roughly minimal) set of compiled output +needed for a developer to actually execute the newly built JDK. The idea is +that in an incremental development fashion, when doing a normal make, you +should only spend time recompiling what's changed (making it purely +incremental) and only do the work that's needed to actually run and test your +code. The packaging stuff that is part of the `images` target is not needed for +a normal developer who wants to test his new code. Even if it's quite fast, +it's still unnecessary. We're targeting sub-second incremental rebuilds! ;-) +(Or, well, at least single-digit seconds...) + +**Q:** I usually set a specific environment variable when building, but I can't +find the equivalent in the new build. What should I do? +**A:** It might very well be that we have neglected to add support for an +option that was actually used from outside the build system. Email us and we +will add support for it! + + +### Build Performance Tips + +Building OpenJDK requires a lot of horsepower. Some of the build tools can be +adjusted to utilize more or less of resources such as parallel threads and +memory. The `configure` script analyzes your system and selects reasonable +values for such options based on your hardware. If you encounter resource +problems, such as out of memory conditions, you can modify the detected values +with: + + * **`--with-num-cores`** -- number of cores in the build system, e.g. + `--with-num-cores=8` + * **`--with-memory-size`** -- memory (in MB) available in the build system, + e.g. `--with-memory-size=1024` + +It might also be necessary to specify the JVM arguments passed to the Bootstrap +JDK, using e.g. `--with-boot-jdk-jvmargs="-Xmx8G -enableassertions"`. Doing +this will override the default JVM arguments passed to the Bootstrap JDK. + +One of the top goals of the new build system is to improve the build +performance and decrease the time needed to build. This will soon also apply to +the java compilation when the Smart Javac wrapper is making its way into jdk8. +It can be tried in the build-infra repository already. You are likely to find +that the new build system is faster than the old one even without this feature. + +At the end of a successful execution of `configure`, you will get a performance +summary, indicating how well the build will perform. Here you will also get +performance hints. If you want to build fast, pay attention to those! + +#### Building with ccache + +A simple way to radically speed up compilation of native code +(typically hotspot and native libraries in JDK) is to install +ccache. This will cache and reuse prior compilation results, if the +source code is unchanged. However, ccache versions prior to 3.1.4 does +not work correctly with the precompiled headers used in OpenJDK. So if +your platform supports ccache at 3.1.4 or later, we highly recommend +installing it. This is currently only supported on linux. + +#### Building on local disk + +If you are using network shares, e.g. via NFS, for your source code, make sure +the build directory is situated on local disk. The performance penalty is +extremely high for building on a network share, close to unusable. + +#### Building only one JVM + +The old build builds multiple JVMs on 32-bit systems (client and server; and on +Windows kernel as well). In the new build we have changed this default to only +build server when it's available. This improves build times for those not +interested in multiple JVMs. To mimic the old behavior on platforms that +support it, use `--with-jvm-variants=client,server`. + +#### Selecting the number of cores to build on + +By default, `configure` will analyze your machine and run the make process in +parallel with as many threads as you have cores. This behavior can be +overridden, either "permanently" (on a `configure` basis) using +`--with-num-cores=N` or for a single build only (on a make basis), using +`make JOBS=N`. + +If you want to make a slower build just this time, to save some CPU power for +other processes, you can run e.g. `make JOBS=2`. This will force the makefiles +to only run 2 parallel processes, or even `make JOBS=1` which will disable +parallelism. + +If you want to have it the other way round, namely having slow builds default +and override with fast if you're impatient, you should call `configure` with +`--with-num-cores=2`, making 2 the default. If you want to run with more cores, +run `make JOBS=8` + + +### Troubleshooting + +#### Solving build problems + +If the build fails (and it's not due to a compilation error in a source file +you've changed), the first thing you should do is to re-run the build with more +verbosity. Do this by adding `LOG=debug` to your make command line. + +The build log (with both stdout and stderr intermingled, basically the same as +you see on your console) can be found as `build.log` in your build directory. + +You can ask for help on build problems with the new build system on either the +[build-dev](http://mail.openjdk.java.net/mailman/listinfo/build-dev) or the +[build-infra-dev](http://mail.openjdk.java.net/mailman/listinfo/build-infra-dev) +mailing lists. Please include the relevant parts of the build log. + +A build can fail for any number of reasons. Most failures are a result of +trying to build in an environment in which all the pre-build requirements have +not been met. The first step in troubleshooting a build failure is to recheck +that you have satisfied all the pre-build requirements for your platform. +Scanning the `configure` log is a good first step, making sure that what it +found makes sense for your system. Look for strange error messages or any +difficulties that `configure` had in finding things. + +Some of the more common problems with builds are briefly described below, with +suggestions for remedies. + + * **Corrupted Bundles on Windows:** + Some virus scanning software has been known to corrupt the downloading of + zip bundles. It may be necessary to disable the 'on access' or 'real time' + virus scanning features to prevent this corruption. This type of 'real time' + virus scanning can also slow down the build process significantly. + Temporarily disabling the feature, or excluding the build output directory + may be necessary to get correct and faster builds. + + * **Slow Builds:** + If your build machine seems to be overloaded from too many simultaneous C++ + compiles, try setting the `JOBS=1` on the `make` command line. Then try + increasing the count slowly to an acceptable level for your system. Also: + + Creating the javadocs can be very slow, if you are running javadoc, consider + skipping that step. + + Faster CPUs, more RAM, and a faster DISK usually helps. The VM build tends + to be CPU intensive (many C++ compiles), and the rest of the JDK will often + be disk intensive. + + Faster compiles are possible using a tool called + [ccache](http://ccache.samba.org/). + + * **File time issues:** + If you see warnings that refer to file time stamps, e.g. + + > _Warning message:_ ` File 'xxx' has modification time in the future.` + > _Warning message:_ ` Clock skew detected. Your build may be incomplete.` + + These warnings can occur when the clock on the build machine is out of sync + with the timestamps on the source files. Other errors, apparently unrelated + but in fact caused by the clock skew, can occur along with the clock skew + warnings. These secondary errors may tend to obscure the fact that the true + root cause of the problem is an out-of-sync clock. + + If you see these warnings, reset the clock on the build machine, run + "`gmake clobber`" or delete the directory containing the build output, and + restart the build from the beginning. + + * **Error message: `Trouble writing out table to disk`** + Increase the amount of swap space on your build machine. This could be + caused by overloading the system and it may be necessary to use: + + > `make JOBS=1` + + to reduce the load on the system. + + * **Error Message: `libstdc++ not found`:** + This is caused by a missing libstdc++.a library. This is installed as part + of a specific package (e.g. libstdc++.so.devel.386). By default some 64-bit + Linux versions (e.g. Fedora) only install the 64-bit version of the + libstdc++ package. Various parts of the JDK build require a static link of + the C++ runtime libraries to allow for maximum portability of the built + images. + + * **Linux Error Message: `cannot restore segment prot after reloc`** + This is probably an issue with SELinux (See [SELinux on + Wikipedia](http://en.wikipedia.org/wiki/SELinux)). Parts of the VM is built + without the `-fPIC` for performance reasons. + + To completely disable SELinux: + + 1. `$ su root` + 2. `# system-config-securitylevel` + 3. `In the window that appears, select the SELinux tab` + 4. `Disable SELinux` + + Alternatively, instead of completely disabling it you could disable just + this one check. + + 1. Select System->Administration->SELinux Management + 2. In the SELinux Management Tool which appears, select "Boolean" from the + menu on the left + 3. Expand the "Memory Protection" group + 4. Check the first item, labeled "Allow all unconfined executables to use + libraries requiring text relocation ..." + + * **Windows Error Messages:** + `*** fatal error - couldn't allocate heap, ... ` + `rm fails with "Directory not empty"` + `unzip fails with "cannot create ... Permission denied"` + `unzip fails with "cannot create ... Error 50"` + + The CYGWIN software can conflict with other non-CYGWIN software. See the + CYGWIN FAQ section on [BLODA (applications that interfere with + CYGWIN)](http://cygwin.com/faq/faq.using.html#faq.using.bloda). + + * **Windows Error Message: `spawn failed`** + Try rebooting the system, or there could be some kind of issue with the disk + or disk partition being used. Sometimes it comes with a "Permission Denied" + message. + +***** + + +## Appendix B: GNU make + +The Makefiles in the OpenJDK are only valid when used with the GNU version of +the utility command `make` (usually called `gmake` on Solaris). A few notes +about using GNU make: + + * You need GNU make version 3.81 or newer. If the GNU make utility on your + systems is not 3.81 or newer, see "[Building GNU make](#buildgmake)". + * Place the location of the GNU make binary in the `PATH`. + * **Solaris:** Do NOT use `/usr/bin/make` on Solaris. If your Solaris system + has the software from the Solaris Developer Companion CD installed, you + should try and use `gmake` which will be located in either the `/usr/bin`, + `/opt/sfw/bin` or `/usr/sfw/bin` directory. + * **Windows:** Make sure you start your build inside a bash shell. + * **Mac OS X:** The XCode "command line tools" must be installed on your Mac. + +Information on GNU make, and access to ftp download sites, are available on the +[GNU make web site ](http://www.gnu.org/software/make/make.html). The latest +source to GNU make is available at +[ftp.gnu.org/pub/gnu/make/](http://ftp.gnu.org/pub/gnu/make/). + + +### Building GNU make + +First step is to get the GNU make 3.81 or newer source from +[ftp.gnu.org/pub/gnu/make/](http://ftp.gnu.org/pub/gnu/make/). Building is a +little different depending on the OS but is basically done with: + + bash ./configure + make + +***** + + +## Appendix C: Build Environments + +### Minimum Build Environments + +This file often describes specific requirements for what we call the "minimum +build environments" (MBE) for this specific release of the JDK. What is listed +below is what the Oracle Release Engineering Team will use to build the Oracle +JDK product. Building with the MBE will hopefully generate the most compatible +bits that install on, and run correctly on, the most variations of the same +base OS and hardware architecture. In some cases, these represent what is often +called the least common denominator, but each Operating System has different +aspects to it. + +In all cases, the Bootstrap JDK version minimum is critical, we cannot +guarantee builds will work with older Bootstrap JDK's. Also in all cases, more +RAM and more processors is better, the minimums listed below are simply +recommendations. + +With Solaris and Mac OS X, the version listed below is the oldest release we +can guarantee builds and works, and the specific version of the compilers used +could be critical. + +With Windows the critical aspect is the Visual Studio compiler used, which due +to it's runtime, generally dictates what Windows systems can do the builds and +where the resulting bits can be used. + +**NOTE: We expect a change here off these older Windows OS releases and to a +'less older' one, probably Windows 2008R2 X64.** + +With Linux, it was just a matter of picking a stable distribution that is a +good representative for Linux in general. + +**NOTE: We expect a change here from Fedora 9 to something else, but it has not +been completely determined yet, possibly Ubuntu 12.04 X64, unbiased community +feedback would be welcome on what a good choice would be here.** + +It is understood that most developers will NOT be using these specific +versions, and in fact creating these specific versions may be difficult due to +the age of some of this software. It is expected that developers are more often +using the more recent releases and distributions of these operating systems. + +Compilation problems with newer or different C/C++ compilers is a common +problem. Similarly, compilation problems related to changes to the +`/usr/include` or system header files is also a common problem with older, +newer, or unreleased OS versions. Please report these types of problems as bugs +so that they can be dealt with accordingly. + +> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Base OS and ArchitectureOSC/C++ CompilerBootstrap JDKProcessorsRAM MinimumDISK Needs
Linux X86 (32-bit) and X64 (64-bit)Fedora 9gcc 4.3 JDK 7u72 or more1 GB6 GB
Solaris SPARC (32-bit) and SPARCV9 (64-bit)Solaris 10 Update 6Studio 12 Update 1 + patchesJDK 7u74 or more4 GB8 GB
Solaris X86 (32-bit) and X64 (64-bit)Solaris 10 Update 6Studio 12 Update 1 + patchesJDK 7u74 or more4 GB8 GB
Windows X86 (32-bit)Windows XPMicrosoft Visual Studio C++ 2010 Professional EditionJDK 7u72 or more2 GB6 GB
Windows X64 (64-bit)Windows Server 2003 - Enterprise x64 EditionMicrosoft Visual Studio C++ 2010 Professional EditionJDK 7u72 or more2 GB6 GB
Mac OS X X64 (64-bit)Mac OS X 10.7 "Lion"XCode 4.5.2 or newerJDK 7u72 or more4 GB6 GB
+ +***** + + +### Specific Developer Build Environments + +We won't be listing all the possible environments, but we will try to provide +what information we have available to us. + +**NOTE: The community can help out by updating this part of the document.** + +#### Fedora + +After installing the latest [Fedora](http://fedoraproject.org) you need to +install several build dependencies. The simplest way to do it is to execute the +following commands as user `root`: + + yum-builddep java-1.7.0-openjdk + yum install gcc gcc-c++ + +In addition, it's necessary to set a few environment variables for the build: + + export LANG=C + export PATH="/usr/lib/jvm/java-openjdk/bin:${PATH}" + +#### CentOS 5.5 + +After installing [CentOS 5.5](http://www.centos.org/) you need to make sure you +have the following Development bundles installed: + + * Development Libraries + * Development Tools + * Java Development + * X Software Development (Including XFree86-devel) + +Plus the following packages: + + * cups devel: Cups Development Package + * alsa devel: Alsa Development Package + * Xi devel: libXi.so Development Package + +The freetype 2.3 packages don't seem to be available, but the freetype 2.3 +sources can be downloaded, built, and installed easily enough from [the +freetype site](http://downloads.sourceforge.net/freetype). Build and install +with something like: + + bash ./configure + make + sudo -u root make install + +Mercurial packages could not be found easily, but a Google search should find +ones, and they usually include Python if it's needed. + +#### Debian 5.0 (Lenny) + +After installing [Debian](http://debian.org) 5 you need to install several +build dependencies. The simplest way to install the build dependencies is to +execute the following commands as user `root`: + + aptitude build-dep openjdk-7 + aptitude install openjdk-7-jdk libmotif-dev + +In addition, it's necessary to set a few environment variables for the build: + + export LANG=C + export PATH="/usr/lib/jvm/java-7-openjdk/bin:${PATH}" + +#### Ubuntu 12.04 + +After installing [Ubuntu](http://ubuntu.org) 12.04 you need to install several +build dependencies. The simplest way to do it is to execute the following +commands: + + sudo aptitude build-dep openjdk-7 + sudo aptitude install openjdk-7-jdk + +In addition, it's necessary to set a few environment variables for the build: + + export LANG=C + export PATH="/usr/lib/jvm/java-7-openjdk/bin:${PATH}" + +#### OpenSUSE 11.1 + +After installing [OpenSUSE](http://opensuse.org) 11.1 you need to install +several build dependencies. The simplest way to install the build dependencies +is to execute the following commands: + + sudo zypper source-install -d java-1_7_0-openjdk + sudo zypper install make + +In addition, it is necessary to set a few environment variables for the build: + + export LANG=C + export PATH="/usr/lib/jvm/java-1.7.0-openjdk/bin:$[PATH}" + +Finally, you need to unset the `JAVA_HOME` environment variable: + + export -n JAVA_HOME` + +#### Mandriva Linux One 2009 Spring + +After installing [Mandriva](http://mandriva.org) Linux One 2009 Spring you need +to install several build dependencies. The simplest way to install the build +dependencies is to execute the following commands as user `root`: + + urpmi java-1.7.0-openjdk-devel make gcc gcc-c++ freetype-devel zip unzip + libcups2-devel libxrender1-devel libalsa2-devel libstc++-static-devel + libxtst6-devel libxi-devel + +In addition, it is necessary to set a few environment variables for the build: + + export LANG=C + export PATH="/usr/lib/jvm/java-1.7.0-openjdk/bin:${PATH}" + +#### OpenSolaris 2009.06 + +After installing [OpenSolaris](http://opensolaris.org) 2009.06 you need to +install several build dependencies. The simplest way to install the build +dependencies is to execute the following commands: + + pfexec pkg install SUNWgmake SUNWj7dev sunstudioexpress SUNWcups SUNWzip + SUNWunzip SUNWxwhl SUNWxorg-headers SUNWaudh SUNWfreetype2 + +In addition, it is necessary to set a few environment variables for the build: + + export LANG=C + export PATH="/opt/SunStudioExpress/bin:${PATH}" + +***** + +End of the OpenJDK build README document. + +Please come again! diff --git a/common/bin/update-build-readme.sh b/common/bin/update-build-readme.sh new file mode 100644 index 00000000000..f16e289b32a --- /dev/null +++ b/common/bin/update-build-readme.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +# Get an absolute path to this script, since that determines the top-level +# directory. +this_script_dir=`dirname $0` +TOPDIR=`cd $this_script_dir/../.. > /dev/null && pwd` + +GREP=grep +MD_FILE=$TOPDIR/README-builds.md +HTML_FILE=$TOPDIR/README-builds.html + +# Locate the markdown processor tool and check that it is the correct version. +locate_markdown_processor() { + if [ -z "$MARKDOWN" ]; then + MARKDOWN=`which markdown 2> /dev/null` + if [ -z "$MARKDOWN" ]; then + echo "Error: Cannot locate markdown processor" 1>&2 + exit 1 + fi + fi + + # Test version + MARKDOWN_VERSION=`$MARKDOWN -version | $GREP version` + if [ "x$MARKDOWN_VERSION" != "xThis is Markdown, version 1.0.1." ]; then + echo "Error: Expected markdown version 1.0.1." 1>&2 + echo "Actual version found: $MARKDOWN_VERSION" 1>&2 + echo "Download markdown here: https://daringfireball.net/projects/markdown/" 1>&2 + exit 1 + fi + +} + +# Verify that the source markdown file looks sound. +verify_source_code() { + TOO_LONG_LINES=`$GREP -E -e '^.{80}.+$' $MD_FILE` + if [ "x$TOO_LONG_LINES" != x ]; then + echo "Warning: The following lines are longer than 80 characters:" + $GREP -E -e '^.{80}.+$' $MD_FILE + fi +} + +# Convert the markdown file to html format. +process_source() { + echo "Generating html file from markdown" + cat > $HTML_FILE << END + + + OpenJDK Build README + + +END + ${MARKDOWN} $MD_FILE >> $HTML_FILE + cat >> $HTML_FILE < + +END + echo "Done" +} + +locate_markdown_processor +verify_source_code +process_source From 298420ef567cd7a68572a8893a6966101a05dce4 Mon Sep 17 00:00:00 2001 From: Dan Lutker Date: Fri, 26 Aug 2022 17:41:08 +0000 Subject: [PATCH 10/12] 7131823: bug in GIFImageReader Reviewed-by: phh Backport-of: a31130fd4056907edcb420761722c629a33273eb --- .../imageio/plugins/gif/GIFImageReader.java | 33 ++-- .../plugins/gif/GIFLargeTableIndexTest.java | 155 ++++++++++++++++++ 2 files changed, 171 insertions(+), 17 deletions(-) create mode 100644 jdk/test/javax/imageio/plugins/gif/GIFLargeTableIndexTest.java diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java b/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java index 3510f067362..093c1f87d91 100644 --- a/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java +++ b/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java @@ -937,7 +937,8 @@ public BufferedImage read(int imageIndex, ImageReadParam param) this.clearCode = 1 << initCodeSize; this.eofCode = clearCode + 1; - int code, oldCode = 0; + final int NULL_CODE = -1; + int code, oldCode = NULL_CODE; int[] prefix = new int[4096]; byte[] suffix = new byte[4096]; @@ -960,6 +961,7 @@ public BufferedImage read(int imageIndex, ImageReadParam param) codeMask = (1 << codeSize) - 1; code = getCode(codeSize, codeMask); + oldCode = NULL_CODE; if (code == eofCode) { // Inform IIOReadProgressListeners of end of image processImageComplete(); @@ -982,24 +984,21 @@ public BufferedImage read(int imageIndex, ImageReadParam param) } } - if (tableIndex >= prefix.length) { - throw new IIOException("Code buffer limit reached," - + " no End of Image tag present, possibly data is corrupted. "); - } - - int ti = tableIndex; - int oc = oldCode; + if (NULL_CODE != oldCode && tableIndex < 4096) { + int ti = tableIndex; + int oc = oldCode; - prefix[ti] = oc; - suffix[ti] = initial[newSuffixIndex]; - initial[ti] = initial[oc]; - length[ti] = length[oc] + 1; + prefix[ti] = oc; + suffix[ti] = initial[newSuffixIndex]; + initial[ti] = initial[oc]; + length[ti] = length[oc] + 1; - ++tableIndex; - if ((tableIndex == (1 << codeSize)) && - (tableIndex < 4096)) { - ++codeSize; - codeMask = (1 << codeSize) - 1; + ++tableIndex; + if ((tableIndex == (1 << codeSize)) && + (tableIndex < 4096)) { + ++codeSize; + codeMask = (1 << codeSize) - 1; + } } } diff --git a/jdk/test/javax/imageio/plugins/gif/GIFLargeTableIndexTest.java b/jdk/test/javax/imageio/plugins/gif/GIFLargeTableIndexTest.java new file mode 100644 index 00000000000..99ded8f7d47 --- /dev/null +++ b/jdk/test/javax/imageio/plugins/gif/GIFLargeTableIndexTest.java @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2021, 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 7131823 + * @summary Test tableIndex > 4096 decodes correctly + */ + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Base64; +import java.util.zip.GZIPInputStream; +import javax.imageio.ImageIO; +import javax.imageio.ImageReader; +import javax.imageio.stream.ImageInputStream; + +public class GIFLargeTableIndexTest { + + public void testLargeTableGIF() throws IOException { + ImageInputStream stream = ImageIO.createImageInputStream(new GZIPInputStream(new ByteArrayInputStream( + Base64.getDecoder().decode( + "H4sIAAAAAAAAAO3W+VcTBrbA8TrWZ/bUsY5j1TKOdQSSkFp1rEVlHOsICZBxrONYtdSqFbKKgMga" + + "EZDsEQER2ffsYd8hIiDZIwKyE9mzh32HvL73H7xf3/Hz0z333J/v+V7w+se3J29+8tknn01/8j8c" + + "Dgfyf4ffNn/7nSOOy1dZ4fkZFf3M8uGGNfiTUc/nk/Qik7LKBm6f9e5ZZE+tapc24RBQQmveDM3b" + + "NVVdNAdkY4q7BAsMDb56ULIEhjHbx8tWWL7CHkvVGpSrmpqv2+DozEvrTQ74H52/9fyP/0PaC16N" + + "vNewDNjjctLrakAYPY1fq+gzrgC/cP0O8yM+nPFSUKfsN62C9iLcsdcIEcx0Yb1qwLwG3oc85X2d" + + "GMnKEDWoBy3rkP2o0z43SFHsTHGjZsi6Af3S7YzvT+RoTpakSTts24Q5oT1wfhQqN1sq0+ntDvjX" + + "Oa9iPgV/cYr2de7reMje7yIBR/Ja6Z8jfmygHcl/w3bscw9fB3xTIE/8CvvyFP2bQmUK8lpdJPBo" + + "kTrtGKG/gX60WJt5KmJ1HXiM9zb3e+YXpxnH+O8KvdO/iwIdF3TxfxD+2Mg4Lnwvvl4fvgH6q6i3" + + "9Lbq5WnmX8X9lcSBuijwCclgbbC5v5F5QjrcGLm2ugH+tuRDcxx47xnWt6Wjbay97tGQk2XjimTE" + + "tSbWyfJJTYZ7xCbkuwpDRwE2/Qz7u0pTt+hafTTUvcrSV0EYaGK7V9uGGiLWNqGnaqZHWpl7PTin" + + "amcn1OnuVNjpunljl/CajHO6ftE6WB/hgJ1pWJ4ZV6V7cM80ri5YBuqpcI+m9ZV584CM6yHb3Fhf" + + "W3M44D8/+h3M8+eY//qS9vNjkJv851jYGcDNuN/7et6M/8NPtJtPviDLbyZ8GQ34hfZnjucv9L9k" + + "0X5huErkvzDdmgC3WN9oPW+x/zpMu8X5zia/xT2zCbj99O8wr9uJ//iSfvsZxk1xO8n3DPBO8r98" + + "ve6k/Psn+p3nP5IVd1J/igb++uIXjtevab9m0X99iZcofk0nNwHvZtzXet3NfDBMv5sVblPczY7e" + + "BPrnPIZh/HOffMnwz2O4Kf3zOWdAAQXPfDEBhc9/YgQUvSQrA4qzokF4Xh4Hg+cXZTHwAoFEiRdK" + + "mkAEUZkWQxBXDTMIkjqbkiBt2gQRS17DsMTSN18yiWVKh5uKWK49AyZVvPPFkirf/8QkVfWTVaTq" + + "4WgwuWaUgyXXTmYxyXUmiYpcb2sCUxpmtVhK4+Iwk9K0alNRZJub4Huvfgf3vtf8X06se69BaPW9" + + "FpgHJLD19zjvwLY/+LEC33xBUQe2f0mF3Jf/met9X/GXbNZ9patUfV/lJoMEqb/ReQdp/qpnBWm/" + + "s6uDdGcckOC3f4f7BHf8w4kd/A6D1gR3+npAQ7r+hfMJ6f63Hzvk/Y8UTUjPT1Tog95fuD4P+n7N" + + "Zj/ox0s1DwbIMmjo4H2dT+jQAz07dDjcrgnVRzugDz88hvs+HHnixHk4ykBrH45xPGBh489wvmET" + + "zx1+nLDJlxRt2FQWFRZuyOP6hhuLsjnhJoFUG26WyGARljKdb4S1Ss+JsNXZtRH2Jgcscvo1HBc5" + + "88aJGzmrROsi57Qe8Kj5dzhc1MJ7P27UYj9FF7U0TIVHL49ycdErk9nc6FWTVBe9ZpPBqeuzOhx1" + + "Y1HPpW6u2nVUx6YD/uoT0L1HnyJztsBprz51vRcDIeZsdQI0AzD3Hn8uytmGpjVD8Pdi91lytnsA" + + "Xn/GuBf3FTIXiKO9/lxwLx5JzAX7AVr+qLz35JgoF0qhtewz3Us4ZcmFUwGtfwIF0r5H5u3g0lq/" + + "cg2kexPzdmYD2pwxgYwfRHm7pLQ2pAMfyLxuydstA7z5mhHIuo3M36OjvTkmCGQTifl79YD2b5WB" + + "nGBR/n47rf2UKZAbacl3cgDkfwPdfxqHLDgAp8u/d72fyCIWHHQCKjwx958liwoOoekKb/z9pAxL" + + "wWEPoPKfjPvJBchCFxxd+YPgfoqIWIjwA6r+o7z/vEJUiKLQVddN91MbLIVoKlD9MyjoRSuy6AiX" + + "rr7tGpSmJhYdzQZq/DFBL7tERceldA0RH5Q+aCk6IQNq7zGCMsaRxSd1dG2wICjTQix21wN1D5VB" + + "WfOi4tN2ui7SFJS9bin2cADfPgIF53yK4p2FM97GuQbnQki8c06gDhom2JH3uZh3Hs3oYOGD8/dZ" + + "eRc8QO+eMoILvkLxvXCMd8mC4EIkiY/1A3W+UAYXHRPzfSiMzgxTcPEpKx9HBXXlgEJ436MEF7mM" + + "rgLXEL43SXApG9TNw4QIfhALLksZ3SJ8iPC6VXBFBnpfwggR3UYJr+oY7ysEIWIiSXhND+qpUYZI" + + "gsXCG3ZGT4MpRBppFfo5QL2vQA9K4lCim3Bmb6vrg1IWSXTLCdwnxzwoSxaL7qCZfWr8g/IMq+iu" + + "B7j/LeNBRQFKHIBj9ncJHlSKSGKCH3igV/mgqkIsJlGYA4OmB9UNVjGFCh78AAqtaUVJArnMwXHX" + + "0Fq1gyQJygYPGTChdV1iSYiUOWTBh9YPWiWhMvDwNCO0YRwlDdMxh+cFoY0WkjRCD9YvK0Ob5sXS" + + "KDtTv24Kla1bpVQH+MMn4IevPnUriYGzPnyKeNgMIZfEOkFGANiHrz+XlMSjWSMQwsOWfbaSBA/I" + + "6GfMh61fuZXScazRz4UP25DkUqYfZOyPqodvjklK2RTW2D7zw/ZTtlIuFTL+J3CY/Hu3skQua/wr" + + "RJjCm1yWlA2ZcMaGKX+QlKVIWRNIQpjquq0sVQaZ/JoZpr7tVp6mY00eE4ZpiOTydD1k6ltVmDZY" + + "Up5pZ02dMofpIm3l2Q6I4W/g8LdxbhWOXDjb8D0ivINFrsh3gho9seHvkiUVhWi20ZsQ3plhqyj2" + + "gJr+yQzvKnCr5OPYph+E4d0icqXQD2r+jyr8fYWkUkxhm6+bw3sabJVSKtTyMziit9WtqpTLttxG" + + "RPSpyVXl2VCrPzaiv0tSVSllW4mEiIFBW1W1DGq7x4wYHHerrtWxbcHCiCELubpeD7U/VEUMz0uq" + + "G+1se6Q5Qr9uq5Y5oNOPwJEfPkXXNMM503GIyBEIpabFCTZDw0aOfi6taUNzZliEyLF99pp2D9js" + + "U2bk+FfoWgWOM5ssjJxAUmpVfrC5F6rIyWPSWg2FM5dhjpw6Za/97f3A5nPAUYbv0XUdXM58ASLK" + + "6E2p68yGLfCwUaYfpHXdUs6CiBBlvm6v65HBFkuYUZbb6Po+HWexQhhlJVLqB/SwpRpVlC1YWj9k" + + "5yw1mKPskfZ6vQO2/AocPR2HbhiBc5dbEdEzLErDmBN8RY6Nnk2WNkyguStqQvRchr1hygO++pYZ" + + "PV+AbjTiuKtdwugFEaXR7Adf61VFL1ZIG60U7tqgOXqpwd5op8LXP4Cpy63ophkud30cQV1RU5rm" + + "suEbBix1tUvatCDlblgI1LVBe9OSDL45zaSuj6NlKzru5ryQumGhyNb0cMeyiro5L5Vt2LkOx7qZ" + + "6li3y37rgEdbnB9t9Xy0zf/RdtojIO8RWP4IangEB8TscI7Z6Rmzyz9mNy1mDy9mrzxmvyHGCfD4" + + "gPPjg56PD/k/Pkx77MJ7jJA/RhkeowGxR5xjj3rGHvePPUGLPcmLdZfHnjbEegDizjrHnfOMO+8f" + + "d4EW58WLw8rjfAxxOED8Ref4S57xl/3jr9Dir/Lir8njbxji/QBPbjo/ueX55I7/k7u0JwG8JwT5" + + "E5LhCQWQEOicEOSZEOKfEEpLCOMlRMgTogwJVAAtxpkW60mL96cl0Gh0Ho0pp7ENNC6AnuhMT/Kk" + + "p/jTU2n0NB49XU7PNNCzAYxcZ0a+w5NR6M8opjH4PIZQzhAbGFIAs9SZWe7JrPRnVtOYtTxmvZzZ" + + "aGDKAKxmZ1aLJ6vNn9VOYyl4LJWcpTGwdAB2hzO705Pd7c/uobH7eOwBOXvIwNYDOCPOnDFPzoQ/" + + "Z4rGMfI4ZjnHauDYAdwZZ+6cJ3fBn7tE467wuGty7oaB6wA83eLydKvX020BT7fTnwL5T8GKp1Dj" + + "UzgwcYdL4k6vxF0BibvpiXv4iXsVifuNiU7AZwdcnh30enYo4Nlh+jMX/jOE4hnK+AwNTDriknTU" + + "K+l4QNIJetJJfpK7Ium0MckDmHzWJfmcV/L5gOQL9GQvfjJWkezjMCbjgCkXXVIueaVcDki5Qk+5" + + "yk+5pki5YUzxAz6/6fL8ltfzOwHP79KfB/CfExTPScbnFGBqoEtqkFdqSEBqKD01jJ8aoUiNMqZS" + + "gS9iXF7Eer2ID3iRQH9B579gKl6wjS+4wLREl7Qkr7SUgLRUeloaPy1dkZZpTMsGvsx1eZnv9bIw" + + "4GUx/SWf/1KoeCk2vpQC00td0su90isD0qvp6bX89HpFeqMxXQbMaHbJaPHKaAvIaKdnKPgZKkWG" + + "xpihA2Z2uGR2emV2B2T20DP7+JkDiswhY6YemDXikjXmlTURkDVFzzLys8yKLKsxyw7MnnHJnvPK" + + "XgjIXnLQs1f42WuK7A1jtgOYs8U1ZysmZxs+ZzsjByjIAStzoKYcOCh3h2vuTkzuLnzubkbuHkHu" + + "XmXuflOuEyjvgGveQUzeIXzeYUaeiyAPocxDmfLQoPwjrvlHMfnH8fknGPknBfnuyvzTpnwPUMFZ" + + "14JzmILz+IILjAIvQQFWWeBjKsCBCi+6Fl7CFF7GF15hFF4VFF5TFt4wFfqBim66Ft3CFN3BF91l" + + "FAUIigjKIpKpiAIqDnQtDsIUh+CLQxnFYYLiCGVxlKmYCuLFuPJiMbx4PC+BwaMLeEwlj23icUH8" + + "RFd+EoafguenMvhpAn66kp9p4meDBLkOV0E+RlCIFxQzBHyBQKgUiH9LP5Cw1FVYjhFW4oXVDGGt" + + "QFivFDaahDKQqNlV1IIRteFF7QyRQiBSKUUak0gHEne4ijsx4m68uIch7hOIB5TiIZNYD5KMuErG" + + "MJIJvGSKITEKJGalxGqS2EHSGVfpHEa6gJcuMaQrAumaUrphkjpAJVsQJVuxJdsIJduZJUBhCVhV" + + "AjWXwMGlOxClO7Gluwilu5mle4Sle1Wl+82lTuCyA4iyg9iyQ4Syw8wyF2EZQlWGMpehweVHEOVH" + + "seXHCeUnmOUnheXuqvLT5nIPcMVZRMU5bMV5QsUFZoWXsALrUFX4mCtw4MqLiMpL2MrLhMorzMqr" + + "wsprqsob5ko/cNVNRNUtbNUdQtVdZlWAsIqgqiKZqyjg6kBEdRC2OoRQHcqsDhNWR6iqo8zVVHBN" + + "DKImFlsTT6hJYNbQhTVMVQ3bXMMF1yYiapOwtSmE2lRmbZqwNl1Vm2muzQbX5SLq8rF1hYS6YmYd" + + "X1gnVNWJzXVScH0por4cW19JqK9m1tcK6+tV9Y3mehm4oRnR0IJtaCM0tDMbFMIGlapBY27QgRs7" + + "EI2d2MZuQmMPs7FP2DigahwyN+rBTSOIpjFs0wShaYrZZBQ2mVVNVnOTHSybQcjmsLIFB0G2xJSt" + + "CGVrKtmGWeYAv9qCfLXV+9U24qvtrFdA0Suw+hXU8goOad6BbN7p3byL2Lyb1bxH1LxX3bzf0uwE" + + "eX0A+fqg9+tDxNeHWa9dRK8R6tcoy2s0pOUIsuWod8txYssJVstJUYu7uuW0pcUD0noW2XrOu/U8" + + "sfUCq9VL1IpVt/pYWnGQtovItkvebZeJbVdYbVdFbdfUbTcsbX6QNzeRb255v7lDfHOX9SZA9Iag" + + "fkOyvKFA2gOR7UHe7SHE9lBWe5ioPULdHmVpp0LkMUh5rLc8nihPYMnpIjlTLWdb5FyIIhGpSPJW" + + "pBAVqSxFmkiRrlZkWhS/lZAyF6nM91YWEpXFLCVfpBSqlWKLUgpRlSJV5d6qSqKqmqWqFanq1apG" + + "i0oGUTcj1S3e6jaiup2lVojUKrVaY1HrIJoOpKbTW9NN1PSwNH0izYBaM2TR6CHaEaR2zFs7QdRO" + + "sbRGkdas1lotWjtEN4PUzXnrFoi6JZZuRaRbU+s2LDoH5O0W1NutPm+3kd5uZ78Fit+CNW+h1rdw" + + "aMcOVMdOn45dpI7d7I494o69mo791g4n6LsDqHcHfd4dIr07zH7nIn6H0LxDWd+hoZ1HUJ1HfTqP" + + "kzpPsDtPijvdNZ2nrZ0e0K6zqK5zPl3nSV0X2F1eDnEXVtPlY+3CQbsvorov+XRfJnVfYXdfFXdf" + + "03TfsHb7Qd/fRL2/5fP+Dun9Xfb7APF7guY9yfqeAu0JRPUE+fSEkHpC2T1h4p4ITU+UtYcK7Y1B" + + "9cb69MaTehPYvXRxL1PTy7b2cqF9iai+JJ++FFJfKrsvTdyXrunLtPZlQ/tzUf35Pv2FpP5idj9f" + + "3C/U9Iut/VLoQClqoNxnoJI0UM0eqBUP1GsGGq0DMuhgM2qwxWewjTTYzh5UiAdVmkGNdVAHHepA" + + "DXX6DHWThnrYQ33ioQHN0JB1SA8dHkENj/kMT5CGp9jDRvGwWTNstQ7bofoZlH7O4aNfIOmX2PoV" + + "sX5No9+w6h3QD1vcPmz1/bCN/GE75wNQ8gGs/QC1fYDDRna4jez0HdlFHtnNGdkjGdmrHdlvG3GC" + + "jR5wGz3oO3qIPHqYM+oiGUVoR1G2UTRs7Ijb2FHfsePksROcsZOSMXft2GnbmAds/Kzb+Dnf8fPk" + + "8QuccS/JOFY77mMbx8EmLrpNXPKduEyeuMKZuCqZuKaduGGb8INN3nSbvOU7eYc8eZczGSCZJGgn" + + "SbZJCmwq0G0qyHcqhDwVypkKk0xFaKeibFNUmCHGzRDra4gnGxI4BrrEwNQa2DYDF2ZMdDMm+RpT" + + "yMZUjjFNYkzXGjMdNmM2zJTrZsr3NRWSTcUcE19iEmpNYptJCjOXupnLfc2VZHM1x1wrMddrzY02" + + "swxmaXaztPha2siWdo5FIbGotBaNzaKDWTvcrJ2+1m6ytYdj7ZNYB7TWIZtVD7ONuNnGfG0TZNsU" + + "x2aU2Mxam9Vms8PsM272OV/7Atm+xLGvSOxrWvuGze6ATW9BT2/FTW+jTG/nTgOl02DdNNQ+DYfP" + + "7EDP7MTN7KLM7ObO7JHO7NXN7LfPOMFnD6BnD+JmD1FmD3NnXaSzCN0syj6Lhs8dQc8dxc0dp8yd" + + "4M6dlM656+ZO2+c84PNn0fPncPPnKfMXHNx5L+k8VjfvY5/HwRcuohcu4RYuUxaucBeuSheu6RZu" + + "2Bf84Is30Yu3cIt3KIt3uYsB0kWCbpFkX6TAlwLRS0G4pRDKUih3KUy6FKFbirIvUeHLMejlWNxy" + + "PGU5gbtMly4zdcts+zIXvpKIXknCraRQVlK5K2nSlXTdSqZ9JRu+motezcetFlJWi7mrfOmqULcq" + + "tq9K4Wul6LVy3FolZa2au1YrXavXrTXa12Tw9Wb0egtuvY2y3s5dV0jXVbp1jX1dB9/oQG904ja6" + + "KRs93I0+6caAbmPIvqGHb46gN8dwmxOUzSnuplG6adZtWu2bdrhjxoF2zOEcCxTHEtexInWs6Rwb" + + "dsdHH3300UcfffTRRx999P8S+v9yvP+fn3zi/t+BrTq2UCIAAA==")))); + + ImageReader reader = ImageIO.getImageReadersByFormatName("GIF").next(); + + System.out.println(stream); + reader.setInput(stream, false, true); + reader.read(0, null); + } + + public static void main(String[] args) throws IOException { + GIFLargeTableIndexTest tests = new GIFLargeTableIndexTest(); + tests.testLargeTableGIF(); + } +} From 11cd91f951d6b0d9809e1e1ed0bf7e77ac678ba6 Mon Sep 17 00:00:00 2001 From: Martin Balao Date: Fri, 26 Aug 2022 21:48:00 +0000 Subject: [PATCH 11/12] 8292688: Support Security properties in security.testlibrary.Proc Reviewed-by: sgehwolf --- jdk/test/java/security/testlibrary/Proc.java | 28 +++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/jdk/test/java/security/testlibrary/Proc.java b/jdk/test/java/security/testlibrary/Proc.java index 95192cd1369..8623def52df 100644 --- a/jdk/test/java/security/testlibrary/Proc.java +++ b/jdk/test/java/security/testlibrary/Proc.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -25,6 +25,9 @@ import java.io.File; import java.io.IOException; import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.PrintStream; +import java.io.UncheckedIOException; import java.net.URL; import java.net.URLClassLoader; import java.nio.file.Files; @@ -107,6 +110,7 @@ public class Proc { private List args = new ArrayList<>(); private Map env = new HashMap<>(); private Map prop = new HashMap(); + private Map secprop = new HashMap(); private boolean inheritIO = false; private boolean noDump = false; @@ -167,6 +171,11 @@ public Proc prop(String a, String b) { prop.put(a, b); return this; } + // Specifies a security property. Can be called multiple times. + public Proc secprop(String a, String b) { + secprop.put(a, b); + return this; + } // Adds a perm to policy. Can be called multiple times. In order to make it // effective, please also call prop("java.security.manager", ""). public Proc perm(Permission p) { @@ -191,6 +200,17 @@ public Proc start() throws IOException { cp.append(url.getFile()); } cmd.add(cp.toString()); + if (!secprop.isEmpty()) { + Path p = Paths.get(getId("security")); + try (OutputStream fos = Files.newOutputStream(p); + PrintStream ps = new PrintStream(fos)) { + secprop.forEach((k,v) -> ps.println(k + "=" + v)); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + prop.put("java.security.properties", p.toString()); + } + for (Entry e: prop.entrySet()) { cmd.add("-D" + e.getKey() + "=" + e.getValue()); } @@ -289,6 +309,12 @@ public int waitFor() throws Exception { } return p.waitFor(); } + // Wait for process end with expected exit code + public void waitFor(int expected) throws Exception { + if (p.waitFor() != expected) { + throw new RuntimeException("Exit code not " + expected); + } + } // The following methods are used inside a proc From 8e8d4d3ae262f8d653e6068f886fdae18b17e97e Mon Sep 17 00:00:00 2001 From: J9 Build Date: Sat, 3 Sep 2022 03:05:23 +0000 Subject: [PATCH 12/12] Update OPENJDK_TAG to merged level jdk8u352-b05 Signed-off-by: J9 Build --- closed/openjdk-tag.gmk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/closed/openjdk-tag.gmk b/closed/openjdk-tag.gmk index 7d7c3e29589..85adc61e124 100644 --- a/closed/openjdk-tag.gmk +++ b/closed/openjdk-tag.gmk @@ -1 +1 @@ -OPENJDK_TAG := jdk8u352-b04 +OPENJDK_TAG := jdk8u352-b05