diff --git a/jdk/make/Tools.gmk b/jdk/make/Tools.gmk index 32174efec0c..0165341c491 100644 --- a/jdk/make/Tools.gmk +++ b/jdk/make/Tools.gmk @@ -147,6 +147,15 @@ $(eval $(call SetupJavaCompilation,BUILD_INTERIM_JIMAGE, \ EXCLUDES := jdk/internal/jimage/concurrent, \ BIN := $(BUILDTOOLS_OUTPUTDIR)/interim_jimage_classes)) +# Because of the explicit INCLUDES in the compilation setup above, the service provider +# file will not be copied unless META-INF/services would also be added to the INCLUDES. +# Adding META-INF/services would include all files in that directory when only the one +# is needed, which is why this explicit copy is defined instead. +$(eval $(call SetupCopyFiles,COPY_JIMAGE_SERVICE_PROVIDER, \ + SRC := $(JDK_TOPDIR)/src/java.base/share/classes, \ + DEST := $(BUILDTOOLS_OUTPUTDIR)/interim_jimage_classes, \ + FILES := META-INF/services/java.nio.file.spi.FileSystemProvider)) + ########################################################################################## # Tools needed on solaris because OBJCOPY is broken. @@ -173,7 +182,7 @@ ifeq ($(OPENJDK_TARGET_OS), solaris) PROGRAM := fix_empty_sec_hdr_flags)) endif -$(BUILD_TOOLS_JDK): $(BUILD_INTERIM_JIMAGE) +$(BUILD_TOOLS_JDK): $(BUILD_INTERIM_JIMAGE) $(COPY_JIMAGE_SERVICE_PROVIDER) java-tools: $(BUILD_TOOLS_JDK) diff --git a/jdk/make/launcher/Launcher-jdk.runtime.gmk b/jdk/make/launcher/Launcher-jdk.runtime.gmk index 220c2ff40e8..96c02be5689 100644 --- a/jdk/make/launcher/Launcher-jdk.runtime.gmk +++ b/jdk/make/launcher/Launcher-jdk.runtime.gmk @@ -66,19 +66,6 @@ UNPACKEXE_LANG := C ifeq ($(OPENJDK_TARGET_OS), solaris) UNPACKEXE_LANG := C++ endif -UNPACKEXE_DEBUG_SYMBOLS := true -# On windows, unpack200 is linked completely differently to all other -# executables, using the compiler with the compiler arguments. -# It's also linked incrementally, producing a .ilk file that needs to -# be kept away. -ifeq ($(OPENJDK_TARGET_OS), windows) - BUILD_UNPACKEXE_LDEXE := $(CC) - EXE_OUT_OPTION_save := $(EXE_OUT_OPTION) - EXE_OUT_OPTION := -Fe - # With the current way unpack200 is built, debug symbols aren't supported - # anyway. - UNPACKEXE_DEBUG_SYMBOLS := false -endif # The linker on older SuSE distros (e.g. on SLES 10) complains with: # "Invalid version tag `SUNWprivate_1.1'. Only anonymous version tag is allowed in executable." @@ -93,49 +80,36 @@ $(eval $(call SetupNativeCompilation,BUILD_UNPACKEXE, \ SRC := $(UNPACKEXE_SRC), \ LANG := $(UNPACKEXE_LANG), \ OPTIMIZATION := LOW, \ - CFLAGS := $(UNPACKEXE_CFLAGS) $(CXXFLAGS_JDKEXE) \ - -DFULL, \ + CFLAGS := $(UNPACKEXE_CFLAGS) $(CXXFLAGS_JDKEXE) -DFULL, \ CFLAGS_release := -DPRODUCT, \ CFLAGS_linux := -fPIC, \ CFLAGS_solaris := -KPIC, \ CFLAGS_macosx := -fPIC, \ MAPFILE := $(UNPACK_MAPFILE),\ - LDFLAGS := $(UNPACKEXE_ZIPOBJS), \ - LDFLAGS_windows := $(CXXFLAGS_JDKEXE), \ - LDFLAGS_unix := $(LDFLAGS_JDKEXE) $(LDFLAGS_CXX_JDK) \ + LDFLAGS := $(UNPACKEXE_ZIPOBJS) \ + $(LDFLAGS_JDKEXE) $(LDFLAGS_CXX_JDK) \ $(call SET_SHARED_LIBRARY_NAME,$(LIBRARY_PREFIX)unpack$(SHARED_LIBRARY_SUFFIX)) \ $(call SET_SHARED_LIBRARY_ORIGIN), \ LDFLAGS_linux := -lc, \ LDFLAGS_solaris := $(UNPACKEXE_LDFLAGS_solaris) -lc, \ LDFLAGS_SUFFIX := $(LIBCXX), \ OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/unpackexe$(OUTPUT_SUBDIR), \ - OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/unpackexe$(OUTPUT_SUBDIR), \ + OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/modules_cmds/$(MODULE), \ PROGRAM := unpack200, \ VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \ RC_FLAGS := $(RC_FLAGS) \ -D "JDK_FNAME=unpack200.exe" \ -D "JDK_INTERNAL_NAME=unpack200" \ -D "JDK_FTYPE=0x1L", \ - DEBUG_SYMBOLS := $(UNPACKEXE_DEBUG_SYMBOLS), \ + DEBUG_SYMBOLS := true, \ MANIFEST := $(JDK_TOPDIR)/src/jdk.runtime/windows/native/unpack200/unpack200_proto.exe.manifest)) -ifeq ($(OPENJDK_TARGET_OS), windows) - EXE_OUT_OPTION := $(EXE_OUT_OPTION_save) -endif - ifneq ($(USE_EXTERNAL_LIBZ), true) $(BUILD_UNPACKEXE): $(UNPACKEXE_ZIPOBJS) endif -# Build into object dir and copy executable afterwards to avoid .ilk file in -# image. The real fix would be clean up linking of unpack200 using -# -link -incremental:no -# like all other launchers. -$(SUPPORT_OUTPUTDIR)/modules_cmds/$(MODULE)/unpack200$(EXE_SUFFIX): $(BUILD_UNPACKEXE) - $(call install-file) - -TARGETS += $(SUPPORT_OUTPUTDIR)/modules_cmds/$(MODULE)/unpack200$(EXE_SUFFIX) +TARGETS += $(BUILD_UNPACKEXE) ################################################################################ diff --git a/jdk/make/src/classes/build/tools/module/boot.modules b/jdk/make/src/classes/build/tools/module/boot.modules index d51fbfb4913..7c7748e4167 100644 --- a/jdk/make/src/classes/build/tools/module/boot.modules +++ b/jdk/make/src/classes/build/tools/module/boot.modules @@ -1,7 +1,5 @@ java.base java.desktop -java.activation -java.annotations.common java.compiler java.corba java.instrument @@ -18,9 +16,7 @@ java.sql java.sql.rowset java.transaction java.xml -java.xml.bind java.xml.crypto -java.xml.ws jdk.charsets jdk.deploy jdk.deploy.osx diff --git a/jdk/make/src/classes/build/tools/module/ext.modules b/jdk/make/src/classes/build/tools/module/ext.modules index ac6b6a2ac2f..882ead8ce76 100644 --- a/jdk/make/src/classes/build/tools/module/ext.modules +++ b/jdk/make/src/classes/build/tools/module/ext.modules @@ -1,3 +1,7 @@ +java.activation +java.annotations.common +java.xml.bind +java.xml.ws jdk.crypto.ec jdk.crypto.mscapi jdk.crypto.pkcs11 diff --git a/jdk/src/java.base/share/classes/com/sun/crypto/provider/GHASH.java b/jdk/src/java.base/share/classes/com/sun/crypto/provider/GHASH.java index 8b0ba28e898..ee747c8e36c 100644 --- a/jdk/src/java.base/share/classes/com/sun/crypto/provider/GHASH.java +++ b/jdk/src/java.base/share/classes/com/sun/crypto/provider/GHASH.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,9 +29,7 @@ package com.sun.crypto.provider; -import java.util.Arrays; -import java.security.*; -import static com.sun.crypto.provider.AESConstants.AES_BLOCK_SIZE; +import java.security.ProviderException; /** * This class represents the GHASH function defined in NIST 800-38D @@ -44,62 +43,90 @@ import static com.sun.crypto.provider.AESConstants.AES_BLOCK_SIZE; */ final class GHASH { - private static final byte P128 = (byte) 0xe1; //reduction polynomial - - private static boolean getBit(byte[] b, int pos) { - int p = pos / 8; - pos %= 8; - int i = (b[p] >>> (7 - pos)) & 1; - return i != 0; + private static long getLong(byte[] buffer, int offset) { + long result = 0; + int end = offset + 8; + for (int i = offset; i < end; ++i) { + result = (result << 8) + (buffer[i] & 0xFF); + } + return result; } - private static void shift(byte[] b) { - byte temp, temp2; - temp2 = 0; - for (int i = 0; i < b.length; i++) { - temp = (byte) ((b[i] & 0x01) << 7); - b[i] = (byte) ((b[i] & 0xff) >>> 1); - b[i] = (byte) (b[i] | temp2); - temp2 = temp; + private static void putLong(byte[] buffer, int offset, long value) { + int end = offset + 8; + for (int i = end - 1; i >= offset; --i) { + buffer[i] = (byte) value; + value >>= 8; } } - // Given block X and Y, returns the muliplication of X * Y - private static byte[] blockMult(byte[] x, byte[] y) { - if (x.length != AES_BLOCK_SIZE || y.length != AES_BLOCK_SIZE) { - throw new RuntimeException("illegal input sizes"); - } - byte[] z = new byte[AES_BLOCK_SIZE]; - byte[] v = y.clone(); - // calculate Z1-Z127 and V1-V127 - for (int i = 0; i < 127; i++) { + private static final int AES_BLOCK_SIZE = 16; + + // Multiplies state0, state1 by V0, V1. + private void blockMult(long V0, long V1) { + long Z0 = 0; + long Z1 = 0; + long X; + + // Separate loops for processing state0 and state1. + X = state0; + for (int i = 0; i < 64; i++) { // Zi+1 = Zi if bit i of x is 0 - if (getBit(x, i)) { - for (int n = 0; n < z.length; n++) { - z[n] ^= v[n]; - } - } - boolean lastBitOfV = getBit(v, 127); - shift(v); - if (lastBitOfV) v[0] ^= P128; + long mask = X >> 63; + Z0 ^= V0 & mask; + Z1 ^= V1 & mask; + + // Save mask for conditional reduction below. + mask = (V1 << 63) >> 63; + + // V = rightshift(V) + long carry = V0 & 1; + V0 = V0 >>> 1; + V1 = (V1 >>> 1) | (carry << 63); + + // Conditional reduction modulo P128. + V0 ^= 0xe100000000000000L & mask; + X <<= 1; } + + X = state1; + for (int i = 64; i < 127; i++) { + // Zi+1 = Zi if bit i of x is 0 + long mask = X >> 63; + Z0 ^= V0 & mask; + Z1 ^= V1 & mask; + + // Save mask for conditional reduction below. + mask = (V1 << 63) >> 63; + + // V = rightshift(V) + long carry = V0 & 1; + V0 = V0 >>> 1; + V1 = (V1 >>> 1) | (carry << 63); + + // Conditional reduction. + V0 ^= 0xe100000000000000L & mask; + X <<= 1; + } + // calculate Z128 - if (getBit(x, 127)) { - for (int n = 0; n < z.length; n++) { - z[n] ^= v[n]; - } - } - return z; + long mask = X >> 63; + Z0 ^= V0 & mask; + Z1 ^= V1 & mask; + + // Save result. + state0 = Z0; + state1 = Z1; } // hash subkey H; should not change after the object has been constructed - private final byte[] subkeyH; + private final long subkeyH0, subkeyH1; // buffer for storing hash - private byte[] state; + private long state0, state1; // variables for save/restore calls - private byte[] stateSave = null; + private long stateSave0, stateSave1; /** * Initializes the cipher in the specified mode with the given key @@ -114,8 +141,8 @@ final class GHASH { if ((subkeyH == null) || subkeyH.length != AES_BLOCK_SIZE) { throw new ProviderException("Internal error"); } - this.subkeyH = subkeyH; - this.state = new byte[AES_BLOCK_SIZE]; + this.subkeyH0 = getLong(subkeyH, 0); + this.subkeyH1 = getLong(subkeyH, 8); } /** @@ -124,31 +151,33 @@ final class GHASH { * this object for different data w/ the same H. */ void reset() { - Arrays.fill(state, (byte) 0); + state0 = 0; + state1 = 0; } /** * Save the current snapshot of this GHASH object. */ void save() { - stateSave = state.clone(); + stateSave0 = state0; + stateSave1 = state1; } /** * Restores this object using the saved snapshot. */ void restore() { - state = stateSave; + state0 = stateSave0; + state1 = stateSave1; } private void processBlock(byte[] data, int ofs) { if (data.length - ofs < AES_BLOCK_SIZE) { throw new RuntimeException("need complete block"); } - for (int n = 0; n < state.length; n++) { - state[n] ^= data[ofs + n]; - } - state = blockMult(state, subkeyH); + state0 ^= getLong(data, ofs); + state1 ^= getLong(data, ofs + 8); + blockMult(subkeyH0, subkeyH1); } void update(byte[] in) { @@ -169,10 +198,10 @@ final class GHASH { } byte[] digest() { - try { - return state.clone(); - } finally { - reset(); - } + byte[] result = new byte[AES_BLOCK_SIZE]; + putLong(result, 0, state0); + putLong(result, 8, state1); + reset(); + return result; } } diff --git a/jdk/src/java.base/share/classes/java/io/PushbackInputStream.java b/jdk/src/java.base/share/classes/java/io/PushbackInputStream.java index d70c73b19c9..fc5439e625b 100644 --- a/jdk/src/java.base/share/classes/java/io/PushbackInputStream.java +++ b/jdk/src/java.base/share/classes/java/io/PushbackInputStream.java @@ -28,9 +28,10 @@ package java.io; /** * A PushbackInputStream adds * functionality to another input stream, namely - * the ability to "push back" or "unread" - * one byte. This is useful in situations where - * it is convenient for a fragment of code + * the ability to "push back" or "unread" bytes, + * by storing pushed-back bytes in an internal buffer. + * This is useful in situations where + * it is convenient for a fragment of code * to read an indefinite number of data bytes * that are delimited by a particular byte * value; after reading the terminating byte, @@ -77,11 +78,9 @@ class PushbackInputStream extends FilterInputStream { /** * Creates a PushbackInputStream * with a pushback buffer of the specified size, - * and saves its argument, the input stream + * and saves its argument, the input stream * in, for later use. Initially, - * there is no pushed-back byte (the field - * pushBack is initialized to - * -1). + * the pushback buffer is empty. * * @param in the input stream from which bytes will be read. * @param size the size of the pushback buffer. @@ -99,11 +98,9 @@ class PushbackInputStream extends FilterInputStream { /** * Creates a PushbackInputStream - * and saves its argument, the input stream + * with a 1-byte pushback buffer, and saves its argument, the input stream * in, for later use. Initially, - * there is no pushed-back byte (the field - * pushBack is initialized to - * -1). + * the pushback buffer is empty. * * @param in the input stream from which bytes will be read. */ diff --git a/jdk/src/java.base/share/classes/java/lang/ProcessBuilder.java b/jdk/src/java.base/share/classes/java/lang/ProcessBuilder.java index a62594383fc..72b260309d6 100644 --- a/jdk/src/java.base/share/classes/java/lang/ProcessBuilder.java +++ b/jdk/src/java.base/share/classes/java/lang/ProcessBuilder.java @@ -951,9 +951,6 @@ public final class ProcessBuilder * {@code command} array as its argument. This may result in * a {@link SecurityException} being thrown. * - *

If the operating system does not support the creation of - * processes, an {@link UnsupportedOperationException} will be thrown. - * *

Starting an operating system process is highly system-dependent. * Among the many things that can go wrong are: *