mirror of
https://github.com/openjdk/jdk.git
synced 2026-04-18 10:50:23 +00:00
Merge
This commit is contained in:
commit
0db7d246b1
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2011, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2011, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2014, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2011, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
|
||||
# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2011, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2011, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2011, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2014, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2011, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2011, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2015, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2015, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2011, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2011, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2011, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2015, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2015, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2011, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2011, 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
|
||||
@ -58,10 +58,6 @@ else
|
||||
|
||||
endif
|
||||
|
||||
ifeq ($(OPENJDK_TARGET_OS), solaris)
|
||||
UNPACKEXE_TOOLCHAIN := TOOLCHAIN_LINK_CXX
|
||||
endif
|
||||
|
||||
UNPACK_MAPFILE_DIR := $(JDK_TOPDIR)/make/mapfiles/libunpack
|
||||
UNPACK_MAPFILE_PLATFORM_FILE := \
|
||||
$(UNPACK_MAPFILE_DIR)/mapfile-vers-unpack200-$(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH)
|
||||
@ -79,7 +75,7 @@ endif
|
||||
|
||||
$(eval $(call SetupNativeCompilation,BUILD_UNPACKEXE, \
|
||||
SRC := $(UNPACKEXE_SRC), \
|
||||
TOOLCHAIN := $(UNPACKEXE_TOOLCHAIN), \
|
||||
TOOLCHAIN := TOOLCHAIN_LINK_CXX, \
|
||||
OPTIMIZATION := LOW, \
|
||||
CFLAGS := $(UNPACKEXE_CFLAGS) $(CXXFLAGS_JDKEXE) -DFULL, \
|
||||
CFLAGS_release := -DPRODUCT, \
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2011, 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
|
||||
|
||||
@ -255,7 +255,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJIMAGE, \
|
||||
CXXFLAGS := $(CXXFLAGS_JDKLIB) $(JIMAGELIB_CPPFLAGS), \
|
||||
CFLAGS_unix := -UDEBUG, \
|
||||
MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libjimage/mapfile-vers, \
|
||||
LDFLAGS := $(LDFLAGS_JDKLIB) \
|
||||
LDFLAGS := $(LDFLAGS_JDKLIB) $(LDFLAGS_CXX_JDK) \
|
||||
$(call SET_SHARED_LIBRARY_ORIGIN), \
|
||||
LDFLAGS_windows := -export:JIMAGE_Open -export:JIMAGE_Close \
|
||||
-export:JIMAGE_PackageToModule \
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2011, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2011, 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
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2011, 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
|
||||
|
||||
@ -33,7 +33,6 @@ import java.nio.file.Paths;
|
||||
import java.security.AccessController;
|
||||
import java.security.Permission;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@ -333,7 +332,7 @@ public interface ModuleFinder {
|
||||
*
|
||||
* <p> When locating modules then any exceptions or errors thrown by the
|
||||
* {@code find} or {@code findAll} methods of the underlying module finders
|
||||
* will be propogated to the caller of the resulting module finder's
|
||||
* will be propagated to the caller of the resulting module finder's
|
||||
* {@code find} or {@code findAll} methods. </p>
|
||||
*
|
||||
* @param finders
|
||||
@ -342,8 +341,8 @@ public interface ModuleFinder {
|
||||
* @return A {@code ModuleFinder} that composes a sequence of module finders
|
||||
*/
|
||||
static ModuleFinder compose(ModuleFinder... finders) {
|
||||
final List<ModuleFinder> finderList = Arrays.asList(finders);
|
||||
finderList.forEach(Objects::requireNonNull);
|
||||
// copy the list, also checking for nulls
|
||||
final List<ModuleFinder> finderList = List.of(finders);
|
||||
|
||||
return new ModuleFinder() {
|
||||
private final Map<String, ModuleReference> nameToModule = new HashMap<>();
|
||||
|
||||
@ -81,7 +81,7 @@ import sun.util.logging.PlatformLogger;
|
||||
* <li>
|
||||
* Currently, only CookieStore.add(URI, HttpCookie) and CookieStore.get(URI)
|
||||
* are used by CookieManager. Others are for completeness and might be needed
|
||||
* by a more sophisticated CookieStore implementation, e.g. a NetscapeCookieSotre.
|
||||
* by a more sophisticated CookieStore implementation, e.g. a NetscapeCookieStore.
|
||||
* </li>
|
||||
* </ul>
|
||||
* </blockquote>
|
||||
@ -201,10 +201,9 @@ public class CookieManager extends CookieHandler
|
||||
throw new IllegalArgumentException("Argument is null");
|
||||
}
|
||||
|
||||
Map<String, List<String>> cookieMap = new java.util.HashMap<>();
|
||||
// if there's no default CookieStore, no way for us to get any cookie
|
||||
if (cookieJar == null)
|
||||
return Collections.unmodifiableMap(cookieMap);
|
||||
return Map.of();
|
||||
|
||||
boolean secureLink = "https".equalsIgnoreCase(uri.getScheme());
|
||||
List<HttpCookie> cookies = new java.util.ArrayList<>();
|
||||
@ -244,8 +243,7 @@ public class CookieManager extends CookieHandler
|
||||
// apply sort rule (RFC 2965 sec. 3.3.4)
|
||||
List<String> cookieHeader = sortByPath(cookies);
|
||||
|
||||
cookieMap.put("Cookie", cookieHeader);
|
||||
return Collections.unmodifiableMap(cookieMap);
|
||||
return Map.of("Cookie", cookieHeader);
|
||||
}
|
||||
|
||||
public void
|
||||
|
||||
@ -217,7 +217,7 @@ public final class URLPermission extends Permission {
|
||||
* where method-names is the list of methods separated by commas
|
||||
* and header-names is the list of permitted headers separated by commas.
|
||||
* There is no white space in the returned String. If header-names is empty
|
||||
* then the colon separator will not be present.
|
||||
* then the colon separator may not be present.
|
||||
*/
|
||||
public String getActions() {
|
||||
return actions;
|
||||
|
||||
@ -31,11 +31,10 @@ import java.io.UncheckedIOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Objects;
|
||||
import java.nio.file.FileTreeWalker.Event;
|
||||
|
||||
/**
|
||||
* An {@code Iterator to iterate over the nodes of a file tree.
|
||||
* An {@code Iterator} to iterate over the nodes of a file tree.
|
||||
*
|
||||
* <pre>{@code
|
||||
* try (FileTreeIterator iterator = new FileTreeIterator(start, maxDepth, options)) {
|
||||
@ -62,7 +61,7 @@ class FileTreeIterator implements Iterator<Event>, Closeable {
|
||||
* @throws SecurityException
|
||||
* if the security manager denies access to the starting file
|
||||
* @throws NullPointerException
|
||||
* if {@code start} or {@code options} is {@ocde null} or
|
||||
* if {@code start} or {@code options} is {@code null} or
|
||||
* the options array contains a {@code null} element
|
||||
*/
|
||||
FileTreeIterator(Path start, int maxDepth, FileVisitOption... options)
|
||||
|
||||
@ -171,7 +171,7 @@ class FileTreeWalker implements Closeable {
|
||||
* if {@code options} contains an element that is not a
|
||||
* {@code FileVisitOption}
|
||||
* @throws NullPointerException
|
||||
* if {@code options} is {@ocde null} or the options
|
||||
* if {@code options} is {@code null} or the options
|
||||
* array contains a {@code null} element
|
||||
*/
|
||||
FileTreeWalker(Collection<FileVisitOption> options, int maxDepth) {
|
||||
|
||||
@ -479,6 +479,10 @@ public abstract class KeyStoreSpi {
|
||||
} else if (engineIsKeyEntry(alias)) {
|
||||
KeyStore.PasswordProtection pp =
|
||||
(KeyStore.PasswordProtection)protParam;
|
||||
if (pp.getProtectionAlgorithm() != null) {
|
||||
throw new KeyStoreException(
|
||||
"unsupported password protection algorithm");
|
||||
}
|
||||
char[] password = pp.getPassword();
|
||||
|
||||
Key key = engineGetKey(alias, password);
|
||||
@ -524,6 +528,10 @@ public abstract class KeyStoreSpi {
|
||||
KeyStore.PasswordProtection pProtect = null;
|
||||
if (protParam != null) {
|
||||
pProtect = (KeyStore.PasswordProtection)protParam;
|
||||
if (pProtect.getProtectionAlgorithm() != null) {
|
||||
throw new KeyStoreException(
|
||||
"unsupported password protection algorithm");
|
||||
}
|
||||
}
|
||||
|
||||
// set entry
|
||||
|
||||
@ -32,10 +32,13 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.ByteArrayInputStream;
|
||||
|
||||
import java.security.InvalidKeyException;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import sun.security.util.Debug;
|
||||
import sun.security.util.MessageDigestSpi2;
|
||||
|
||||
import javax.crypto.SecretKey;
|
||||
|
||||
/**
|
||||
* This MessageDigest class provides applications the functionality of a
|
||||
@ -548,7 +551,7 @@ public abstract class MessageDigest extends MessageDigestSpi {
|
||||
* and its original parent (Object).
|
||||
*/
|
||||
|
||||
static class Delegate extends MessageDigest {
|
||||
static class Delegate extends MessageDigest implements MessageDigestSpi2 {
|
||||
|
||||
// The provider implementation (delegate)
|
||||
private MessageDigestSpi digestSpi;
|
||||
@ -601,6 +604,14 @@ public abstract class MessageDigest extends MessageDigestSpi {
|
||||
digestSpi.engineUpdate(input);
|
||||
}
|
||||
|
||||
public void engineUpdate(SecretKey key) throws InvalidKeyException {
|
||||
if (digestSpi instanceof MessageDigestSpi2) {
|
||||
((MessageDigestSpi2)digestSpi).engineUpdate(key);
|
||||
} else {
|
||||
throw new UnsupportedOperationException
|
||||
("Digest does not support update of SecretKey object");
|
||||
}
|
||||
}
|
||||
protected byte[] engineDigest() {
|
||||
return digestSpi.engineDigest();
|
||||
}
|
||||
|
||||
@ -37,7 +37,6 @@ import java.nio.ByteBuffer;
|
||||
import java.security.Provider.Service;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.CipherSpi;
|
||||
import javax.crypto.IllegalBlockSizeException;
|
||||
import javax.crypto.BadPaddingException;
|
||||
import javax.crypto.NoSuchPaddingException;
|
||||
@ -180,15 +179,12 @@ public abstract class Signature extends SignatureSpi {
|
||||
private static final String RSA_CIPHER = "RSA/ECB/PKCS1Padding";
|
||||
|
||||
// all the services we need to lookup for compatibility with Cipher
|
||||
private static final List<ServiceId> rsaIds = Arrays.asList(
|
||||
new ServiceId[] {
|
||||
new ServiceId("Signature", "NONEwithRSA"),
|
||||
new ServiceId("Cipher", "RSA/ECB/PKCS1Padding"),
|
||||
new ServiceId("Cipher", "RSA/ECB"),
|
||||
new ServiceId("Cipher", "RSA//PKCS1Padding"),
|
||||
new ServiceId("Cipher", "RSA"),
|
||||
}
|
||||
);
|
||||
private static final List<ServiceId> rsaIds = List.of(
|
||||
new ServiceId("Signature", "NONEwithRSA"),
|
||||
new ServiceId("Cipher", "RSA/ECB/PKCS1Padding"),
|
||||
new ServiceId("Cipher", "RSA/ECB"),
|
||||
new ServiceId("Cipher", "RSA//PKCS1Padding"),
|
||||
new ServiceId("Cipher", "RSA"));
|
||||
|
||||
/**
|
||||
* Returns a Signature object that implements the specified signature
|
||||
|
||||
@ -88,8 +88,6 @@ import java.time.temporal.Temporal;
|
||||
import java.time.temporal.TemporalAmount;
|
||||
import java.time.temporal.TemporalUnit;
|
||||
import java.time.temporal.UnsupportedTemporalTypeException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Matcher;
|
||||
@ -578,8 +576,7 @@ public final class Duration
|
||||
* the simple initialization in Duration.
|
||||
*/
|
||||
private static class DurationUnits {
|
||||
static final List<TemporalUnit> UNITS =
|
||||
Collections.unmodifiableList(Arrays.<TemporalUnit>asList(SECONDS, NANOS));
|
||||
static final List<TemporalUnit> UNITS = List.of(SECONDS, NANOS);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
@ -83,8 +83,6 @@ import java.time.temporal.TemporalAmount;
|
||||
import java.time.temporal.TemporalQueries;
|
||||
import java.time.temporal.TemporalUnit;
|
||||
import java.time.temporal.UnsupportedTemporalTypeException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Matcher;
|
||||
@ -152,8 +150,7 @@ public final class Period
|
||||
/**
|
||||
* The set of supported units.
|
||||
*/
|
||||
private static final List<TemporalUnit> SUPPORTED_UNITS =
|
||||
Collections.unmodifiableList(Arrays.<TemporalUnit>asList(YEARS, MONTHS, DAYS));
|
||||
private static final List<TemporalUnit> SUPPORTED_UNITS = List.of(YEARS, MONTHS, DAYS);
|
||||
|
||||
/**
|
||||
* The number of years.
|
||||
|
||||
@ -76,14 +76,14 @@ import java.time.temporal.UnsupportedTemporalTypeException;
|
||||
import java.time.zone.ZoneRules;
|
||||
import java.time.zone.ZoneRulesException;
|
||||
import java.time.zone.ZoneRulesProvider;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import static java.util.Map.entry;
|
||||
|
||||
/**
|
||||
* A time-zone ID, such as {@code Europe/Paris}.
|
||||
* <p>
|
||||
@ -220,39 +220,36 @@ public abstract class ZoneId implements Serializable {
|
||||
* </ul>
|
||||
* The map is unmodifiable.
|
||||
*/
|
||||
public static final Map<String, String> SHORT_IDS;
|
||||
static {
|
||||
Map<String, String> map = new HashMap<>(64);
|
||||
map.put("ACT", "Australia/Darwin");
|
||||
map.put("AET", "Australia/Sydney");
|
||||
map.put("AGT", "America/Argentina/Buenos_Aires");
|
||||
map.put("ART", "Africa/Cairo");
|
||||
map.put("AST", "America/Anchorage");
|
||||
map.put("BET", "America/Sao_Paulo");
|
||||
map.put("BST", "Asia/Dhaka");
|
||||
map.put("CAT", "Africa/Harare");
|
||||
map.put("CNT", "America/St_Johns");
|
||||
map.put("CST", "America/Chicago");
|
||||
map.put("CTT", "Asia/Shanghai");
|
||||
map.put("EAT", "Africa/Addis_Ababa");
|
||||
map.put("ECT", "Europe/Paris");
|
||||
map.put("IET", "America/Indiana/Indianapolis");
|
||||
map.put("IST", "Asia/Kolkata");
|
||||
map.put("JST", "Asia/Tokyo");
|
||||
map.put("MIT", "Pacific/Apia");
|
||||
map.put("NET", "Asia/Yerevan");
|
||||
map.put("NST", "Pacific/Auckland");
|
||||
map.put("PLT", "Asia/Karachi");
|
||||
map.put("PNT", "America/Phoenix");
|
||||
map.put("PRT", "America/Puerto_Rico");
|
||||
map.put("PST", "America/Los_Angeles");
|
||||
map.put("SST", "Pacific/Guadalcanal");
|
||||
map.put("VST", "Asia/Ho_Chi_Minh");
|
||||
map.put("EST", "-05:00");
|
||||
map.put("MST", "-07:00");
|
||||
map.put("HST", "-10:00");
|
||||
SHORT_IDS = Collections.unmodifiableMap(map);
|
||||
}
|
||||
public static final Map<String, String> SHORT_IDS = Map.ofEntries(
|
||||
entry("ACT", "Australia/Darwin"),
|
||||
entry("AET", "Australia/Sydney"),
|
||||
entry("AGT", "America/Argentina/Buenos_Aires"),
|
||||
entry("ART", "Africa/Cairo"),
|
||||
entry("AST", "America/Anchorage"),
|
||||
entry("BET", "America/Sao_Paulo"),
|
||||
entry("BST", "Asia/Dhaka"),
|
||||
entry("CAT", "Africa/Harare"),
|
||||
entry("CNT", "America/St_Johns"),
|
||||
entry("CST", "America/Chicago"),
|
||||
entry("CTT", "Asia/Shanghai"),
|
||||
entry("EAT", "Africa/Addis_Ababa"),
|
||||
entry("ECT", "Europe/Paris"),
|
||||
entry("IET", "America/Indiana/Indianapolis"),
|
||||
entry("IST", "Asia/Kolkata"),
|
||||
entry("JST", "Asia/Tokyo"),
|
||||
entry("MIT", "Pacific/Apia"),
|
||||
entry("NET", "Asia/Yerevan"),
|
||||
entry("NST", "Pacific/Auckland"),
|
||||
entry("PLT", "Asia/Karachi"),
|
||||
entry("PNT", "America/Phoenix"),
|
||||
entry("PRT", "America/Puerto_Rico"),
|
||||
entry("PST", "America/Los_Angeles"),
|
||||
entry("SST", "Pacific/Guadalcanal"),
|
||||
entry("VST", "Asia/Ho_Chi_Minh"),
|
||||
entry("EST", "-05:00"),
|
||||
entry("MST", "-07:00"),
|
||||
entry("HST", "-10:00")
|
||||
);
|
||||
/**
|
||||
* Serialization version.
|
||||
*/
|
||||
|
||||
@ -77,8 +77,6 @@ import java.time.temporal.TemporalQueries;
|
||||
import java.time.temporal.TemporalUnit;
|
||||
import java.time.temporal.UnsupportedTemporalTypeException;
|
||||
import java.time.temporal.ValueRange;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@ -105,8 +103,7 @@ final class ChronoPeriodImpl
|
||||
/**
|
||||
* The set of supported units.
|
||||
*/
|
||||
private static final List<TemporalUnit> SUPPORTED_UNITS =
|
||||
Collections.unmodifiableList(Arrays.<TemporalUnit>asList(YEARS, MONTHS, DAYS));
|
||||
private static final List<TemporalUnit> SUPPORTED_UNITS = List.of(YEARS, MONTHS, DAYS);
|
||||
|
||||
/**
|
||||
* The chronology.
|
||||
|
||||
@ -59,10 +59,7 @@ package java.time.chrono;
|
||||
|
||||
import static java.time.temporal.ChronoField.EPOCH_DAY;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FilePermission;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.io.ObjectInputStream;
|
||||
@ -83,7 +80,6 @@ import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Properties;
|
||||
|
||||
import sun.util.logging.PlatformLogger;
|
||||
@ -512,7 +508,7 @@ public final class HijrahChronology extends AbstractChronology implements Serial
|
||||
|
||||
@Override
|
||||
public List<Era> eras() {
|
||||
return Arrays.<Era>asList(HijrahEra.values());
|
||||
return List.of(HijrahEra.values());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
@ -90,7 +90,6 @@ import java.time.temporal.ChronoField;
|
||||
import java.time.temporal.TemporalAccessor;
|
||||
import java.time.temporal.TemporalField;
|
||||
import java.time.temporal.ValueRange;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
@ -492,7 +491,7 @@ public final class IsoChronology extends AbstractChronology implements Serializa
|
||||
|
||||
@Override
|
||||
public List<Era> eras() {
|
||||
return Arrays.<Era>asList(IsoEra.values());
|
||||
return List.of(IsoEra.values());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
@ -81,7 +81,6 @@ import java.time.temporal.TemporalAdjusters;
|
||||
import java.time.temporal.TemporalField;
|
||||
import java.time.temporal.UnsupportedTemporalTypeException;
|
||||
import java.time.temporal.ValueRange;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@ -379,7 +378,7 @@ public final class JapaneseChronology extends AbstractChronology implements Seri
|
||||
|
||||
@Override
|
||||
public List<Era> eras() {
|
||||
return Arrays.<Era>asList(JapaneseEra.values());
|
||||
return List.of(JapaneseEra.values());
|
||||
}
|
||||
|
||||
JapaneseEra getCurrentEra() {
|
||||
|
||||
@ -72,7 +72,6 @@ import java.time.temporal.ChronoField;
|
||||
import java.time.temporal.TemporalAccessor;
|
||||
import java.time.temporal.TemporalField;
|
||||
import java.time.temporal.ValueRange;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
@ -306,7 +305,7 @@ public final class MinguoChronology extends AbstractChronology implements Serial
|
||||
|
||||
@Override
|
||||
public List<Era> eras() {
|
||||
return Arrays.<Era>asList(MinguoEra.values());
|
||||
return List.of(MinguoEra.values());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
@ -342,7 +342,7 @@ public final class ThaiBuddhistChronology extends AbstractChronology implements
|
||||
|
||||
@Override
|
||||
public List<Era> eras() {
|
||||
return Arrays.<Era>asList(ThaiBuddhistEra.values());
|
||||
return List.of(ThaiBuddhistEra.values());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
@ -1685,6 +1685,7 @@ public final class DateTimeFormatter {
|
||||
public DateTimeFormatter withResolverFields(TemporalField... resolverFields) {
|
||||
Set<TemporalField> fields = null;
|
||||
if (resolverFields != null) {
|
||||
// Set.of cannot be used because it is hostile to nulls and duplicate elements
|
||||
fields = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(resolverFields)));
|
||||
}
|
||||
if (Objects.equals(this.resolverFields, fields)) {
|
||||
|
||||
@ -387,9 +387,9 @@ public final class ZoneOffsetTransition
|
||||
*/
|
||||
List<ZoneOffset> getValidOffsets() {
|
||||
if (isGap()) {
|
||||
return Collections.emptyList();
|
||||
return List.of();
|
||||
}
|
||||
return Arrays.asList(getOffsetBefore(), getOffsetAfter());
|
||||
return List.of(getOffsetBefore(), getOffsetAfter());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
@ -303,7 +303,6 @@ public final class ZoneRules implements Serializable {
|
||||
* Creates an instance of ZoneRules that has fixed zone rules.
|
||||
*
|
||||
* @param offset the offset this fixed zone rules is based on, not null
|
||||
* @return the zone rules, not null
|
||||
* @see #isFixedOffset()
|
||||
*/
|
||||
private ZoneRules(ZoneOffset offset) {
|
||||
@ -970,7 +969,7 @@ public final class ZoneRules implements Serializable {
|
||||
* @return an immutable list of transition rules, not null
|
||||
*/
|
||||
public List<ZoneOffsetTransitionRule> getTransitionRules() {
|
||||
return Collections.unmodifiableList(Arrays.asList(lastRules));
|
||||
return List.of(lastRules);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -2491,34 +2491,29 @@ public abstract class ResourceBundle {
|
||||
/**
|
||||
* The default format <code>List</code>, which contains the strings
|
||||
* <code>"java.class"</code> and <code>"java.properties"</code>, in
|
||||
* this order. This <code>List</code> is {@linkplain
|
||||
* Collections#unmodifiableList(List) unmodifiable}.
|
||||
* this order. This <code>List</code> is unmodifiable.
|
||||
*
|
||||
* @see #getFormats(String)
|
||||
*/
|
||||
public static final List<String> FORMAT_DEFAULT
|
||||
= Collections.unmodifiableList(Arrays.asList("java.class",
|
||||
"java.properties"));
|
||||
= List.of("java.class", "java.properties");
|
||||
|
||||
/**
|
||||
* The class-only format <code>List</code> containing
|
||||
* <code>"java.class"</code>. This <code>List</code> is {@linkplain
|
||||
* Collections#unmodifiableList(List) unmodifiable}.
|
||||
* <code>"java.class"</code>. This <code>List</code> is unmodifiable.
|
||||
*
|
||||
* @see #getFormats(String)
|
||||
*/
|
||||
public static final List<String> FORMAT_CLASS
|
||||
= Collections.unmodifiableList(Arrays.asList("java.class"));
|
||||
public static final List<String> FORMAT_CLASS = List.of("java.class");
|
||||
|
||||
/**
|
||||
* The properties-only format <code>List</code> containing
|
||||
* <code>"java.properties"</code>. This <code>List</code> is
|
||||
* {@linkplain Collections#unmodifiableList(List) unmodifiable}.
|
||||
* <code>"java.properties"</code>. This <code>List</code> is unmodifiable.
|
||||
*
|
||||
* @see #getFormats(String)
|
||||
*/
|
||||
public static final List<String> FORMAT_PROPERTIES
|
||||
= Collections.unmodifiableList(Arrays.asList("java.properties"));
|
||||
= List.of("java.properties");
|
||||
|
||||
/**
|
||||
* The time-to-live constant for not caching loaded resource bundle
|
||||
|
||||
@ -56,8 +56,8 @@ public interface ToolProvider {
|
||||
/**
|
||||
* Returns the name of this tool provider.
|
||||
*
|
||||
* @apiNote It is recommended that the name be the same as would be used on
|
||||
* the command line: for example, "javac", "jar", "jlink".
|
||||
* @apiNote It is recommended that the name be the same as would be
|
||||
* used on the command line: for example, "javac", "jar", "jlink".
|
||||
*
|
||||
* @return the name of this tool provider
|
||||
*/
|
||||
@ -67,12 +67,13 @@ public interface ToolProvider {
|
||||
* Runs an instance of the tool, returning zero for a successful run.
|
||||
* Any non-zero return value indicates a tool-specific error during the
|
||||
* execution.
|
||||
*
|
||||
* Two streams should be provided, for "expected" output, and for any
|
||||
* error messages. If it is not necessary to distinguish the output,
|
||||
* the same stream may be used for both.
|
||||
*
|
||||
* @apiNote The interpretation of the arguments will be specific to
|
||||
* each tool.
|
||||
* each tool.
|
||||
*
|
||||
* @param out a stream to which "expected" output should be written
|
||||
*
|
||||
@ -81,12 +82,13 @@ public interface ToolProvider {
|
||||
* @param args the command-line arguments for the tool
|
||||
*
|
||||
* @return the result of executing the tool.
|
||||
* A return value of 0 means the tool did not encounter any errors;
|
||||
* any other value indicates that at least one error occurred during
|
||||
* execution.
|
||||
* A return value of 0 means the tool did not encounter any errors;
|
||||
* any other value indicates that at least one error occurred
|
||||
* during execution.
|
||||
*
|
||||
* @throws NullPointerException if any of the arguments are {@code null},
|
||||
* or if there are any {@code null} values in the {@code args} array
|
||||
* or if there are any {@code null} values in the {@code args}
|
||||
* array
|
||||
*/
|
||||
int run(PrintWriter out, PrintWriter err, String... args);
|
||||
|
||||
@ -94,16 +96,17 @@ public interface ToolProvider {
|
||||
* Runs an instance of the tool, returning zero for a successful run.
|
||||
* Any non-zero return value indicates a tool-specific error during the
|
||||
* execution.
|
||||
*
|
||||
* Two streams should be provided, for "expected" output, and for any
|
||||
* error messages. If it is not necessary to distinguish the output,
|
||||
* the same stream may be used for both.
|
||||
*
|
||||
* @apiNote The interpretation of the arguments will be specific to
|
||||
* each tool.
|
||||
* each tool.
|
||||
*
|
||||
* @implNote This implementation wraps the {@code out} and {@code err}
|
||||
* streams within {@link PrintWriter}s, and then calls
|
||||
* {@link run(PrintWriter, PrintWriter, String[])}.
|
||||
* streams within {@link PrintWriter}s, and then calls
|
||||
* {@link #run(PrintWriter, PrintWriter, String[])}.
|
||||
*
|
||||
* @param out a stream to which "expected" output should be written
|
||||
*
|
||||
@ -112,12 +115,13 @@ public interface ToolProvider {
|
||||
* @param args the command-line arguments for the tool
|
||||
*
|
||||
* @return the result of executing the tool.
|
||||
* A return value of 0 means the tool did not encounter any errors;
|
||||
* any other value indicates that at least one error occurred during
|
||||
* execution.
|
||||
* A return value of 0 means the tool did not encounter any errors;
|
||||
* any other value indicates that at least one error occurred
|
||||
* during execution.
|
||||
*
|
||||
* @throws NullPointerException if any of the arguments are {@code null},
|
||||
* or if there are any {@code null} values in the {@code args} array
|
||||
* or if there are any {@code null} values in the {@code args}
|
||||
* array
|
||||
*/
|
||||
default int run(PrintStream out, PrintStream err, String... args) {
|
||||
Objects.requireNonNull(out);
|
||||
|
||||
@ -27,7 +27,6 @@ package java.util.stream;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.AbstractSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
@ -1720,12 +1719,12 @@ public final class Collectors {
|
||||
|
||||
@Override
|
||||
public Set<Map.Entry<Boolean, T>> entrySet() {
|
||||
return new AbstractSet<Map.Entry<Boolean, T>>() {
|
||||
return new AbstractSet<>() {
|
||||
@Override
|
||||
public Iterator<Map.Entry<Boolean, T>> iterator() {
|
||||
Map.Entry<Boolean, T> falseEntry = new SimpleImmutableEntry<>(false, forFalse);
|
||||
Map.Entry<Boolean, T> trueEntry = new SimpleImmutableEntry<>(true, forTrue);
|
||||
return Arrays.asList(falseEntry, trueEntry).iterator();
|
||||
return List.of(falseEntry, trueEntry).iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -282,7 +282,7 @@ public interface Stream<T> extends BaseStream<T, Stream<T>> {
|
||||
*/
|
||||
<R> Stream<R> flatMap(Function<? super T, ? extends Stream<? extends R>> mapper);
|
||||
|
||||
/**:
|
||||
/**
|
||||
* Returns an {@code IntStream} consisting of the results of replacing each
|
||||
* element of this stream with the contents of a mapped stream produced by
|
||||
* applying the provided mapping function to each element. Each mapped
|
||||
|
||||
@ -154,7 +154,6 @@ module java.base {
|
||||
exports jdk.internal.module to
|
||||
java.instrument,
|
||||
java.management,
|
||||
jdk.dynalink,
|
||||
jdk.jartool,
|
||||
jdk.jlink;
|
||||
exports jdk.internal.misc to
|
||||
|
||||
@ -432,6 +432,8 @@ public class HKSCS {
|
||||
continue;
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
char c = s.charAt(i);
|
||||
if (c == UNMAPPABLE_DECODING)
|
||||
continue;
|
||||
int hi = c >> 8;
|
||||
if (c2b[hi] == C2B_UNMAPPABLE) {
|
||||
c2b[hi] = new char[0x100];
|
||||
|
||||
@ -282,7 +282,7 @@ final class EllipticCurvesExtension extends HelloExtension {
|
||||
private static int getPreferredCurve(int[] curves,
|
||||
AlgorithmConstraints constraints) {
|
||||
for (int curveId : curves) {
|
||||
if (constraints.permits(
|
||||
if (isSupported(curveId) && constraints.permits(
|
||||
EnumSet.of(CryptoPrimitive.KEY_AGREEMENT),
|
||||
"EC", idToParams.get(curveId))) {
|
||||
return curveId;
|
||||
|
||||
@ -49,6 +49,7 @@ import sun.security.internal.spec.TlsPrfParameterSpec;
|
||||
import sun.security.ssl.CipherSuite.*;
|
||||
import static sun.security.ssl.CipherSuite.PRF.*;
|
||||
import sun.security.util.KeyUtil;
|
||||
import sun.security.util.MessageDigestSpi2;
|
||||
import sun.security.provider.certpath.OCSPResponse;
|
||||
|
||||
/**
|
||||
@ -2124,63 +2125,14 @@ static final class CertificateVerify extends HandshakeMessage {
|
||||
md.update(temp);
|
||||
}
|
||||
|
||||
private static final Class<?> delegate;
|
||||
private static final Field spiField;
|
||||
|
||||
static {
|
||||
try {
|
||||
delegate = Class.forName("java.security.MessageDigest$Delegate");
|
||||
spiField = delegate.getDeclaredField("digestSpi");
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Reflection failed", e);
|
||||
}
|
||||
makeAccessible(spiField);
|
||||
}
|
||||
|
||||
private static void makeAccessible(final AccessibleObject o) {
|
||||
AccessController.doPrivileged(new PrivilegedAction<Object>() {
|
||||
@Override
|
||||
public Object run() {
|
||||
o.setAccessible(true);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ConcurrentHashMap does not allow null values, use this marker object
|
||||
private static final Object NULL_OBJECT = new Object();
|
||||
|
||||
// cache Method objects per Spi class
|
||||
// Note that this will prevent the Spi classes from being GC'd. We assume
|
||||
// that is not a problem.
|
||||
private static final Map<Class<?>,Object> methodCache =
|
||||
new ConcurrentHashMap<>();
|
||||
|
||||
private static void digestKey(MessageDigest md, SecretKey key) {
|
||||
try {
|
||||
// Verify that md is implemented via MessageDigestSpi, not
|
||||
// via JDK 1.1 style MessageDigest subclassing.
|
||||
if (md.getClass() != delegate) {
|
||||
throw new Exception("Digest is not a MessageDigestSpi");
|
||||
}
|
||||
MessageDigestSpi spi = (MessageDigestSpi)spiField.get(md);
|
||||
Class<?> clazz = spi.getClass();
|
||||
Object r = methodCache.get(clazz);
|
||||
if (r == null) {
|
||||
try {
|
||||
r = clazz.getDeclaredMethod("implUpdate", SecretKey.class);
|
||||
makeAccessible((Method)r);
|
||||
} catch (NoSuchMethodException e) {
|
||||
r = NULL_OBJECT;
|
||||
}
|
||||
methodCache.put(clazz, r);
|
||||
}
|
||||
if (r == NULL_OBJECT) {
|
||||
if (md instanceof MessageDigestSpi2) {
|
||||
((MessageDigestSpi2)md).engineUpdate(key);
|
||||
} else {
|
||||
throw new Exception(
|
||||
"Digest does not support implUpdate(SecretKey)");
|
||||
}
|
||||
Method update = (Method)r;
|
||||
update.invoke(spi, key);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(
|
||||
"Could not obtain encoded key and "
|
||||
|
||||
@ -1172,11 +1172,18 @@ final class ServerHandshaker extends Handshaker {
|
||||
if (trySetCipherSuite(suite) == false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (debug != null && Debug.isOn("handshake")) {
|
||||
System.out.println("Standard ciphersuite chosen: " + suite);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
for (CipherSuite suite : legacySuites) {
|
||||
if (trySetCipherSuite(suite)) {
|
||||
if (debug != null && Debug.isOn("handshake")) {
|
||||
System.out.println("Legacy ciphersuite chosen: " + suite);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 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
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.security.util;
|
||||
|
||||
import java.security.InvalidKeyException;
|
||||
import javax.crypto.SecretKey;
|
||||
|
||||
/**
|
||||
* Special interface for additional MessageDigestSpi method(s).
|
||||
*/
|
||||
public interface MessageDigestSpi2 {
|
||||
|
||||
/**
|
||||
* Updates the digest using the specified key.
|
||||
* This is used for SSL 3.0 only, we may deprecate and remove the support
|
||||
* of this in the future
|
||||
*
|
||||
* @param key the key whose value is to be digested.
|
||||
*/
|
||||
void engineUpdate(SecretKey key) throws InvalidKeyException;
|
||||
}
|
||||
@ -376,14 +376,14 @@ public class Base64 {
|
||||
return null;
|
||||
}
|
||||
|
||||
int lengthDataBits = binaryData.length * EIGHTBIT;
|
||||
if (lengthDataBits == 0) {
|
||||
long lengthDataBits = ((long) binaryData.length) * ((long) EIGHTBIT);
|
||||
if (lengthDataBits == 0L) {
|
||||
return "";
|
||||
}
|
||||
|
||||
int fewerThan24bits = lengthDataBits % TWENTYFOURBITGROUP;
|
||||
int numberTriplets = lengthDataBits / TWENTYFOURBITGROUP;
|
||||
int numberQuartet = fewerThan24bits != 0 ? numberTriplets + 1 : numberTriplets;
|
||||
long fewerThan24bits = lengthDataBits % TWENTYFOURBITGROUP;
|
||||
int numberTriplets = (int) (lengthDataBits / TWENTYFOURBITGROUP);
|
||||
int numberQuartet = fewerThan24bits != 0L ? numberTriplets + 1 : numberTriplets;
|
||||
int quartesPerLine = length / 4;
|
||||
int numberLines = (numberQuartet - 1) / quartesPerLine;
|
||||
char encodedData[] = null;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 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
|
||||
@ -34,6 +34,8 @@ import javax.crypto.SecretKey;
|
||||
|
||||
import sun.nio.ch.DirectBuffer;
|
||||
|
||||
import sun.security.util.MessageDigestSpi2;
|
||||
|
||||
import sun.security.pkcs11.wrapper.*;
|
||||
import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
|
||||
|
||||
@ -49,7 +51,8 @@ import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
|
||||
* @author Andreas Sterbenz
|
||||
* @since 1.5
|
||||
*/
|
||||
final class P11Digest extends MessageDigestSpi implements Cloneable {
|
||||
final class P11Digest extends MessageDigestSpi implements Cloneable,
|
||||
MessageDigestSpi2 {
|
||||
|
||||
/* fields initialized, no session acquired */
|
||||
private final static int S_BLANK = 1;
|
||||
@ -233,10 +236,11 @@ final class P11Digest extends MessageDigestSpi implements Cloneable {
|
||||
}
|
||||
|
||||
// Called by SunJSSE via reflection during the SSL 3.0 handshake if
|
||||
// the master secret is sensitive. We may want to consider making this
|
||||
// method public in a future release.
|
||||
protected void implUpdate(SecretKey key) throws InvalidKeyException {
|
||||
|
||||
// the master secret is sensitive.
|
||||
// Note: Change to protected after this method is moved from
|
||||
// sun.security.util.MessageSpi2 interface to
|
||||
// java.security.MessageDigestSpi class
|
||||
public void engineUpdate(SecretKey key) throws InvalidKeyException {
|
||||
// SunJSSE calls this method only if the key does not have a RAW
|
||||
// encoding, i.e. if it is sensitive. Therefore, no point in calling
|
||||
// SecretKeyFactory to try to convert it. Just verify it ourselves.
|
||||
|
||||
@ -2339,7 +2339,7 @@ public class ConsoleReader
|
||||
|
||||
Stack<Character> pushBackChar = new Stack<Character>();
|
||||
|
||||
if (terminal.isAnsiSupported()) {
|
||||
if (terminal.isAnsiSupported() && System.console() != null) {
|
||||
//detect the prompt length by reading the cursor position from the terminal
|
||||
//the real prompt length could differ from the simple prompt length due to
|
||||
//use of escape sequences:
|
||||
|
||||
@ -26,5 +26,7 @@
|
||||
module jdk.jartool {
|
||||
exports com.sun.jarsigner;
|
||||
exports jdk.security.jarsigner;
|
||||
|
||||
provides java.util.spi.ToolProvider with sun.tools.jar.JarToolProvider;
|
||||
}
|
||||
|
||||
|
||||
@ -27,6 +27,7 @@ package sun.tools.jar;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.PrintStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.lang.module.ModuleFinder;
|
||||
import java.lang.module.ModuleDescriptor.Version;
|
||||
import java.nio.file.Path;
|
||||
@ -253,7 +254,8 @@ class GNUStyleOptions {
|
||||
|
||||
// process options
|
||||
for (; count < args.length; count++) {
|
||||
if (args[count].charAt(0) != '-' || args[count].equals("-C"))
|
||||
if (args[count].charAt(0) != '-' || args[count].equals("-C")
|
||||
|| args[count].equals("--release"))
|
||||
break;
|
||||
|
||||
String name = args[count];
|
||||
@ -289,7 +291,7 @@ class GNUStyleOptions {
|
||||
throw new BadArgs("error.unrecognized.option", name).showUsage(true);
|
||||
}
|
||||
|
||||
static void printHelp(PrintStream out) {
|
||||
static void printHelp(PrintWriter out) {
|
||||
out.format("%s%n", Main.getMsg("main.help.preopt"));
|
||||
for (OptionType type : OptionType.values()) {
|
||||
boolean typeHeadingWritten = false;
|
||||
@ -312,16 +314,16 @@ class GNUStyleOptions {
|
||||
out.format("%n%s%n%n", Main.getMsg("main.help.postopt"));
|
||||
}
|
||||
|
||||
static void printCompatHelp(PrintStream out) {
|
||||
static void printCompatHelp(PrintWriter out) {
|
||||
out.format("%s%n", Main.getMsg("usage.compat"));
|
||||
}
|
||||
|
||||
static void printUsageSummary(PrintStream out) {
|
||||
static void printUsageSummary(PrintWriter out) {
|
||||
out.format("%s%n", Main.getMsg("main.usage.summary"));
|
||||
out.format("%s%n", Main.getMsg("main.usage.summary.try"));
|
||||
}
|
||||
|
||||
static void printVersion(PrintStream out) {
|
||||
static void printVersion(PrintWriter out) {
|
||||
out.format("%s %s%n", "jar", System.getProperty("java.version"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 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
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.tools.jar;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.spi.ToolProvider;
|
||||
|
||||
public class JarToolProvider implements ToolProvider {
|
||||
public String name() {
|
||||
return "jar";
|
||||
}
|
||||
|
||||
public int run(PrintWriter out, PrintWriter err, String... args) {
|
||||
boolean ok = new Main(out, err, name()).run(args);
|
||||
return ok ? 0 : 1;
|
||||
}
|
||||
}
|
||||
@ -76,7 +76,7 @@ import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
|
||||
public
|
||||
class Main {
|
||||
String program;
|
||||
PrintStream out, err;
|
||||
PrintWriter out, err;
|
||||
String fname, mname, ename;
|
||||
String zname = "";
|
||||
String rootjar = null;
|
||||
@ -189,9 +189,9 @@ class Main {
|
||||
USAGE_SUMMARY(GNUStyleOptions::printUsageSummary),
|
||||
VERSION(GNUStyleOptions::printVersion);
|
||||
|
||||
private Consumer<PrintStream> printFunction;
|
||||
Info(Consumer<PrintStream> f) { this.printFunction = f; }
|
||||
void print(PrintStream out) { printFunction.accept(out); }
|
||||
private Consumer<PrintWriter> printFunction;
|
||||
Info(Consumer<PrintWriter> f) { this.printFunction = f; }
|
||||
void print(PrintWriter out) { printFunction.accept(out); }
|
||||
};
|
||||
Info info;
|
||||
|
||||
@ -252,6 +252,12 @@ class Main {
|
||||
}
|
||||
|
||||
public Main(PrintStream out, PrintStream err, String program) {
|
||||
this.out = new PrintWriter(out, true);
|
||||
this.err = new PrintWriter(err, true);
|
||||
this.program = program;
|
||||
}
|
||||
|
||||
public Main(PrintWriter out, PrintWriter err, String program) {
|
||||
this.out = out;
|
||||
this.err = err;
|
||||
this.program = program;
|
||||
|
||||
@ -153,7 +153,7 @@ public class JlinkTask {
|
||||
= taskHelper.newOptionsHelper(JlinkTask.class, recognizedOptions);
|
||||
private PrintWriter log;
|
||||
|
||||
void setLog(PrintWriter out) {
|
||||
void setLog(PrintWriter out, PrintWriter err) {
|
||||
log = out;
|
||||
taskHelper.setLog(log);
|
||||
}
|
||||
@ -182,7 +182,8 @@ public class JlinkTask {
|
||||
|
||||
int run(String[] args) {
|
||||
if (log == null) {
|
||||
setLog(new PrintWriter(System.out, true));
|
||||
setLog(new PrintWriter(System.out, true),
|
||||
new PrintWriter(System.err, true));
|
||||
}
|
||||
try {
|
||||
optionsHelper.handleOptions(this, args);
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
package jdk.tools.jlink.internal;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.spi.ToolProvider;
|
||||
|
||||
public class Main {
|
||||
public static void main(String... args) throws Exception {
|
||||
@ -34,17 +35,27 @@ public class Main {
|
||||
System.exit(rc);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Entry point that does <i>not</i> call System.exit.
|
||||
*
|
||||
* @param args command line arguments
|
||||
* @param out output stream
|
||||
* @param err error output stream
|
||||
* @param args command line arguments
|
||||
* @return an exit code. 0 means success, non-zero means an error occurred.
|
||||
*/
|
||||
public static int run(String[] args, PrintWriter out) {
|
||||
public static int run(PrintWriter out, PrintWriter err, String... args) {
|
||||
JlinkTask t = new JlinkTask();
|
||||
t.setLog(out);
|
||||
t.setLog(out, err);
|
||||
return t.run(args);
|
||||
}
|
||||
|
||||
public static class JlinkToolProvider implements ToolProvider {
|
||||
public String name() {
|
||||
return "jlink";
|
||||
}
|
||||
|
||||
public int run(PrintWriter out, PrintWriter err, String... args) {
|
||||
return Main.run(out, err, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,6 +32,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.lang.module.Configuration;
|
||||
import java.lang.module.ModuleReader;
|
||||
@ -136,8 +137,8 @@ public class JmodTask {
|
||||
private static final String MODULE_INFO = "module-info.class";
|
||||
|
||||
private Options options;
|
||||
private PrintStream out = System.out;
|
||||
void setLog(PrintStream out) {
|
||||
private PrintWriter out = new PrintWriter(System.out, true);
|
||||
void setLog(PrintWriter out, PrintWriter err) {
|
||||
this.out = out;
|
||||
}
|
||||
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
package jdk.tools.jmod;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.spi.ToolProvider;
|
||||
|
||||
public class Main {
|
||||
public static void main(String... args) throws Exception {
|
||||
@ -37,13 +38,24 @@ public class Main {
|
||||
/**
|
||||
* Entry point that does <i>not</i> call System.exit.
|
||||
*
|
||||
* @param args command line arguments
|
||||
* @param out output stream
|
||||
* @param err error output stream
|
||||
* @param args command line arguments
|
||||
* @return an exit code. 0 means success, non-zero means an error occurred.
|
||||
*/
|
||||
public static int run(String[] args, PrintStream out) {
|
||||
public static int run(PrintWriter out, PrintWriter err, String... args) {
|
||||
JmodTask t = new JmodTask();
|
||||
t.setLog(out);
|
||||
t.setLog(out, err);
|
||||
return t.run(args);
|
||||
}
|
||||
|
||||
public static class JmodToolProvider implements ToolProvider {
|
||||
public String name() {
|
||||
return "jmod";
|
||||
}
|
||||
|
||||
public int run(PrintWriter out, PrintWriter err, String... args) {
|
||||
return Main.run(out, err, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,6 +31,9 @@ module jdk.jlink {
|
||||
|
||||
uses jdk.tools.jlink.plugin.Plugin;
|
||||
|
||||
provides java.util.spi.ToolProvider with jdk.tools.jmod.Main.JmodToolProvider;
|
||||
provides java.util.spi.ToolProvider with jdk.tools.jlink.internal.Main.JlinkToolProvider;
|
||||
|
||||
provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.FileCopierPlugin;
|
||||
provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.StripDebugPlugin;
|
||||
provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.ExcludePlugin;
|
||||
|
||||
@ -25,8 +25,8 @@
|
||||
* @test
|
||||
* @library /lib/testlibrary
|
||||
* @modules java.base/jdk.internal.module
|
||||
* jdk.jlink/jdk.tools.jmod
|
||||
* jdk.compiler
|
||||
* jdk.jlink
|
||||
* @build ModuleReaderTest CompilerUtils JarUtils
|
||||
* @run testng ModuleReaderTest
|
||||
* @summary Basic tests for java.lang.module.ModuleReader
|
||||
@ -48,6 +48,7 @@ import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
import java.util.spi.ToolProvider;
|
||||
|
||||
import jdk.internal.module.ConfigurableModuleFinder;
|
||||
import jdk.internal.module.ConfigurableModuleFinder.Phase;
|
||||
@ -196,8 +197,11 @@ public class ModuleReaderTest {
|
||||
String cp = MODS_DIR.resolve(TEST_MODULE).toString();
|
||||
String jmod = dir.resolve("m.jmod").toString();
|
||||
String[] args = { "create", "--class-path", cp, jmod };
|
||||
jdk.tools.jmod.JmodTask task = new jdk.tools.jmod.JmodTask();
|
||||
assertEquals(task.run(args), 0);
|
||||
ToolProvider jmodTool = ToolProvider.findFirst("jmod")
|
||||
.orElseThrow(() ->
|
||||
new RuntimeException("jmod tool not found")
|
||||
);
|
||||
assertEquals(jmodTool.run(System.out, System.out, args), 0);
|
||||
|
||||
test(dir);
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@ import java.util.Base64;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8048621 8133090
|
||||
* @bug 8048621 8133090 8167371
|
||||
* @summary Test basic operations with keystores (jks, jceks, pkcs12)
|
||||
* @author Yu-Ching Valerie PENG
|
||||
*/
|
||||
@ -116,6 +116,8 @@ public class TestKeyStoreBasic {
|
||||
};
|
||||
private static final String ALIAS_HEAD = "test";
|
||||
|
||||
private static final String CRYPTO_ALG = "PBEWithHmacSHA256AndAES_128";
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
TestKeyStoreBasic jstest = new TestKeyStoreBasic();
|
||||
jstest.run();
|
||||
@ -125,7 +127,7 @@ public class TestKeyStoreBasic {
|
||||
for (String provider : PROVIDERS) {
|
||||
try {
|
||||
runTest(provider);
|
||||
System.out.println("Test with provider " + provider + "passed");
|
||||
System.out.println("Test with provider " + provider + " passed");
|
||||
} catch (java.security.KeyStoreException e) {
|
||||
if (provider.equals("SunPKCS11-Solaris")) {
|
||||
System.out.println("KeyStoreException is expected: "
|
||||
@ -236,6 +238,44 @@ public class TestKeyStoreBasic {
|
||||
// compare the creation date of the 2 key stores for all aliases
|
||||
compareCreationDate(ks, ks2, numEntries);
|
||||
|
||||
// check setEntry/getEntry with a password protection algorithm
|
||||
if ("PKCS12".equalsIgnoreCase(ks.getType())) {
|
||||
System.out.println(
|
||||
"Skipping the setEntry/getEntry check for PKCS12 keystore...");
|
||||
return;
|
||||
}
|
||||
String alias = ALIAS_HEAD + ALIAS_HEAD;
|
||||
KeyStore.PasswordProtection pw =
|
||||
new KeyStore.PasswordProtection(PASSWD2, CRYPTO_ALG, null);
|
||||
KeyStore.PrivateKeyEntry entry =
|
||||
new KeyStore.PrivateKeyEntry(privateKey, new Certificate[]{ cert });
|
||||
checkSetEntry(ks, alias, pw, entry);
|
||||
ks.setEntry(alias, entry, new KeyStore.PasswordProtection(PASSWD2));
|
||||
checkGetEntry(ks, alias, pw);
|
||||
}
|
||||
|
||||
// check setEntry with a password protection algorithm
|
||||
private void checkSetEntry(KeyStore ks, String alias,
|
||||
KeyStore.PasswordProtection pw, KeyStore.Entry entry) throws Exception {
|
||||
try {
|
||||
ks.setEntry(alias, entry, pw);
|
||||
throw new Exception(
|
||||
"ERROR: expected KeyStore.setEntry to throw an exception");
|
||||
} catch (KeyStoreException e) {
|
||||
// ignore the expected exception
|
||||
}
|
||||
}
|
||||
|
||||
// check getEntry with a password protection algorithm
|
||||
private void checkGetEntry(KeyStore ks, String alias,
|
||||
KeyStore.PasswordProtection pw) throws Exception {
|
||||
try {
|
||||
ks.getEntry(alias, pw);
|
||||
throw new Exception(
|
||||
"ERROR: expected KeyStore.getEntry to throw an exception");
|
||||
} catch (KeyStoreException e) {
|
||||
// ignore the expected exception
|
||||
}
|
||||
}
|
||||
|
||||
// check key store type
|
||||
|
||||
@ -25,13 +25,14 @@
|
||||
* @test
|
||||
* @bug 8163798
|
||||
* @summary basic tests for multi-release jar versioned streams
|
||||
* @library /lib/testlibrary
|
||||
* @modules jdk.jartool/sun.tools.jar java.base/jdk.internal.util.jar
|
||||
* @build jdk.testlibrary.FileUtils
|
||||
* @run testng TestVersionedStream
|
||||
*/
|
||||
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@ -40,29 +41,31 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.net.URI;
|
||||
import java.nio.file.FileVisitResult;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.SimpleFileVisitor;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
public class TestVersionedStream {
|
||||
private String userdir;
|
||||
import jdk.testlibrary.FileUtils;
|
||||
|
||||
@BeforeClass
|
||||
public void initialize() {
|
||||
userdir = System.getProperty("user.dir", ".");
|
||||
public class TestVersionedStream {
|
||||
private final Path userdir;
|
||||
private final Set<String> unversionedEntryNames;
|
||||
|
||||
public TestVersionedStream() throws IOException {
|
||||
userdir = Paths.get(System.getProperty("user.dir", "."));
|
||||
|
||||
// These are not real class files even though they end with .class.
|
||||
// They are resource files so jar tool validation won't reject them.
|
||||
@ -70,91 +73,103 @@ public class TestVersionedStream {
|
||||
// could be in a concealed package if this was a modular multi-release
|
||||
// jar.
|
||||
createFiles(
|
||||
"base/p/Bar.class",
|
||||
"base/p/Foo.class",
|
||||
"base/p/Main.class",
|
||||
"v9/p/Foo.class",
|
||||
"v10/p/Foo.class",
|
||||
"v10/q/Bar.class",
|
||||
"v11/p/Bar.class",
|
||||
"v11/p/Foo.class"
|
||||
);
|
||||
|
||||
jar("cf mmr.jar -C base . --release 9 -C v9 . --release 10 -C v10 . --release 11 -C v11 .");
|
||||
jar("cf mmr.jar -C base . --release 9 -C v9 . " +
|
||||
"--release 10 -C v10 . --release 11 -C v11 .");
|
||||
|
||||
System.out.println("Contents of mmr.jar\n=======");
|
||||
jar("tf mmr.jar");
|
||||
|
||||
try(JarFile jf = new JarFile("mmr.jar")) {
|
||||
unversionedEntryNames = jf.stream()
|
||||
.map(je -> je.getName())
|
||||
.peek(System.out::println)
|
||||
.map(nm -> nm.startsWith("META-INF/versions/")
|
||||
? nm.replaceFirst("META-INF/versions/\\d+/", "")
|
||||
: nm)
|
||||
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||
}
|
||||
|
||||
System.out.println("=======");
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public void close() throws IOException {
|
||||
Path root = Paths.get(userdir);
|
||||
Files.walkFileTree(root, new SimpleFileVisitor<>() {
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
||||
Files.delete(file);
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
|
||||
if (!dir.equals(root)) {
|
||||
Files.delete(dir);
|
||||
}
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
});
|
||||
Files.walk(userdir, 1)
|
||||
.filter(p -> !p.equals(userdir))
|
||||
.forEach(p -> {
|
||||
try {
|
||||
if (Files.isDirectory(p)) {
|
||||
FileUtils.deleteFileTreeWithRetry(p);
|
||||
} else {
|
||||
FileUtils.deleteFileIfExistsWithRetry(p);
|
||||
}
|
||||
} catch (IOException x) {
|
||||
throw new UncheckedIOException(x);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] data() {
|
||||
List<String> p = List.of(
|
||||
"META-INF/",
|
||||
"META-INF/MANIFEST.MF",
|
||||
"p/",
|
||||
"p/Foo.class",
|
||||
"p/Main.class"
|
||||
);
|
||||
List<String> q = List.of(
|
||||
"META-INF/",
|
||||
"META-INF/MANIFEST.MF",
|
||||
"p/",
|
||||
"p/Foo.class",
|
||||
"p/Main.class",
|
||||
"q/",
|
||||
"q/Bar.class"
|
||||
);
|
||||
Runtime.Version rt = JarFile.runtimeVersion();
|
||||
return new Object[][] {
|
||||
{Runtime.Version.parse("8"), p},
|
||||
{Runtime.Version.parse("9"), p},
|
||||
{Runtime.Version.parse("10"), q},
|
||||
{Runtime.Version.parse("11"), q},
|
||||
{JarFile.baseVersion(), p},
|
||||
{rt, rt.major() > 9 ? q : p}
|
||||
{Runtime.Version.parse("8")},
|
||||
{Runtime.Version.parse("9")},
|
||||
{Runtime.Version.parse("10")},
|
||||
{Runtime.Version.parse("11")},
|
||||
{JarFile.baseVersion()},
|
||||
{JarFile.runtimeVersion()}
|
||||
};
|
||||
}
|
||||
|
||||
@Test(dataProvider="data")
|
||||
public void test(Runtime.Version version, List<String> names) throws Exception {
|
||||
public void test(Runtime.Version version) throws Exception {
|
||||
try (JarFile jf = new JarFile(new File("mmr.jar"), false, ZipFile.OPEN_READ, version);
|
||||
Stream<JarEntry> jes = jdk.internal.util.jar.VersionedStream.stream(jf))
|
||||
Stream<JarEntry> jes = jdk.internal.util.jar.VersionedStream.stream(jf))
|
||||
{
|
||||
Assert.assertNotNull(jes);
|
||||
|
||||
List<JarEntry> entries = jes.collect(Collectors.toList());
|
||||
// put versioned entries in list so we can reuse them
|
||||
List<JarEntry> versionedEntries = jes.collect(Collectors.toList());
|
||||
|
||||
// verify the correct order
|
||||
List<String> enames = entries.stream()
|
||||
.map(je -> je.getName())
|
||||
.collect(Collectors.toList());
|
||||
Assert.assertEquals(enames, names);
|
||||
Assert.assertTrue(versionedEntries.size() > 0);
|
||||
|
||||
// also keep the names
|
||||
List<String> versionedNames = new ArrayList<>(versionedEntries.size());
|
||||
|
||||
// verify the correct order while building enames
|
||||
Iterator<String> allIt = unversionedEntryNames.iterator();
|
||||
Iterator<JarEntry> verIt = versionedEntries.iterator();
|
||||
boolean match = false;
|
||||
|
||||
while (verIt.hasNext()) {
|
||||
match = false;
|
||||
if (!allIt.hasNext()) break;
|
||||
String name = verIt.next().getName();
|
||||
versionedNames.add(name);
|
||||
while (allIt.hasNext()) {
|
||||
if (name.equals(allIt.next())) {
|
||||
match = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!match) {
|
||||
Assert.fail("versioned entries not in same order as unversioned entries");
|
||||
}
|
||||
|
||||
// verify the contents
|
||||
Map<String,String> contents = new HashMap<>();
|
||||
contents.put("p/Bar.class", "base/p/Bar.class\n");
|
||||
contents.put("p/Main.class", "base/p/Main.class\n");
|
||||
if (version.major() > 9) {
|
||||
contents.put("q/Bar.class", "v10/q/Bar.class\n");
|
||||
}
|
||||
switch (version.major()) {
|
||||
case 8:
|
||||
contents.put("p/Foo.class", "base/p/Foo.class\n");
|
||||
@ -164,9 +179,12 @@ public class TestVersionedStream {
|
||||
break;
|
||||
case 10:
|
||||
contents.put("p/Foo.class", "v10/p/Foo.class\n");
|
||||
contents.put("q/Bar.class", "v10/q/Bar.class\n");
|
||||
break;
|
||||
case 11:
|
||||
contents.put("p/Bar.class", "v11/p/Bar.class\n");
|
||||
contents.put("p/Foo.class", "v11/p/Foo.class\n");
|
||||
contents.put("q/Bar.class", "v10/q/Bar.class\n");
|
||||
break;
|
||||
default:
|
||||
Assert.fail("Test out of date, please add more cases");
|
||||
@ -174,9 +192,9 @@ public class TestVersionedStream {
|
||||
|
||||
contents.entrySet().stream().forEach(e -> {
|
||||
String name = e.getKey();
|
||||
int i = enames.indexOf(name);
|
||||
int i = versionedNames.indexOf(name);
|
||||
Assert.assertTrue(i != -1, name + " not in enames");
|
||||
JarEntry je = entries.get(i);
|
||||
JarEntry je = versionedEntries.get(i);
|
||||
try (InputStream is = jf.getInputStream(je)) {
|
||||
String s = new String(is.readAllBytes());
|
||||
Assert.assertTrue(s.endsWith(e.getValue()), s);
|
||||
@ -210,5 +228,4 @@ public class TestVersionedStream {
|
||||
new sun.tools.jar.Main(System.out, System.err, "jar")
|
||||
.run(args.split(" +"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
49
jdk/test/sun/nio/cs/TestHKSCS.java
Normal file
49
jdk/test/sun/nio/cs/TestHKSCS.java
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 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
|
||||
* 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 8166258
|
||||
* @summary Some corner cases for hkscs charsets
|
||||
* @modules jdk.charsets
|
||||
* @run main TestHKSCS
|
||||
*/
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class TestHKSCS {
|
||||
public static void main(String args[]) throws Exception {
|
||||
String[] charsets = { "x-MS950-HKSCS-XP",
|
||||
"x-MS950-HKSCS",
|
||||
"Big5-HKSCS",
|
||||
"x-Big5-HKSCS-2001"
|
||||
};
|
||||
String s = "\ufffd\ud87f\udffd";
|
||||
byte[] bytes = new byte[] { 0x3f, 0x3f };
|
||||
for (String cs : charsets) {
|
||||
if (!Arrays.equals(bytes, s.getBytes(cs))) {
|
||||
throw new RuntimeException(cs + " failed to decode u+fffd");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -299,11 +299,12 @@ public abstract class PKCS11Test {
|
||||
+ props.getProperty("os.arch") + "-" + props.getProperty("sun.arch.data.model");
|
||||
String[] nssLibDirs = osMap.get(osid);
|
||||
if (nssLibDirs == null) {
|
||||
System.out.println("Unsupported OS, skipping: " + osid);
|
||||
System.out.println("Warning: unsupported OS: " + osid
|
||||
+ ", please initialize NSS librarys location firstly, skipping test");
|
||||
return null;
|
||||
}
|
||||
if (nssLibDirs.length == 0) {
|
||||
System.out.println("NSS not supported on this platform, skipping test");
|
||||
System.out.println("Warning: NSS not supported on this platform, skipping test");
|
||||
return null;
|
||||
}
|
||||
String nssLibDir = null;
|
||||
@ -315,6 +316,10 @@ public abstract class PKCS11Test {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (nssLibDir == null) {
|
||||
System.out.println("Warning: can't find NSS librarys on this machine, skipping test");
|
||||
return null;
|
||||
}
|
||||
return nssLibDir;
|
||||
}
|
||||
|
||||
@ -624,6 +629,11 @@ public abstract class PKCS11Test {
|
||||
PKCS11_BASE + "/nss/lib/windows-amd64/".replace('/', SEP)});
|
||||
osMap.put("MacOSX-x86_64-64", new String[]{
|
||||
PKCS11_BASE + "/nss/lib/macosx-x86_64/"});
|
||||
osMap.put("Linux-arm-32", new String[]{
|
||||
"/usr/lib/arm-linux-gnueabi/nss/",
|
||||
"/usr/lib/arm-linux-gnueabihf/nss/"});
|
||||
osMap.put("Linux-aarch64-64", new String[]{
|
||||
"/usr/lib/aarch64-linux-gnu/nss/"});
|
||||
}
|
||||
|
||||
private final static char[] hexDigits = "0123456789abcdef".toCharArray();
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
. ${TESTSRC-.}/common.sh
|
||||
|
||||
setup
|
||||
${JAVA} -cp ${TESTCLASSES} CheckEngine
|
||||
${JAVA} ${TESTVMOPTS} ${TESTJAVAOPTS} -cp ${TESTCLASSES} CheckEngine
|
||||
if [ $? -eq 2 ]; then
|
||||
echo "No js engine found and engine not required; test vacuously passes."
|
||||
exit 0
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
. ${TESTSRC-.}/common.sh
|
||||
|
||||
setup
|
||||
${JAVA} -cp ${TESTCLASSES} CheckEngine
|
||||
${JAVA} ${TESTVMOPTS} ${TESTJAVAOPTS} -cp ${TESTCLASSES} CheckEngine
|
||||
if [ $? -eq 2 ]; then
|
||||
echo "No js engine found and engine not required; test vacuously passes."
|
||||
exit 0
|
||||
|
||||
@ -33,14 +33,14 @@
|
||||
. ${TESTSRC-.}/common.sh
|
||||
|
||||
setup
|
||||
${JAVA} -cp ${TESTCLASSES} CheckEngine
|
||||
${JAVA} ${TESTVMOPTS} ${TESTJAVAOPTS} -cp ${TESTCLASSES} CheckEngine
|
||||
if [ $? -eq 2 ]; then
|
||||
echo "No js engine found and engine not required; test vacuously passes."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
rm -f Hello.class
|
||||
${JAVAC} ${TESTSRC}/Hello.java -d .
|
||||
${JAVAC} ${TESTTOOLVMOPTS} ${TESTJAVACOPTS} ${TESTSRC}/Hello.java -d .
|
||||
|
||||
# we check whether classpath setting for app classes
|
||||
# work with jrunscript. Script should be able to
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
. ${TESTSRC-.}/common.sh
|
||||
|
||||
setup
|
||||
${JAVA} -cp ${TESTCLASSES} CheckEngine
|
||||
${JAVA} ${TESTVMOPTS} ${TESTJAVAOPTS} -cp ${TESTCLASSES} CheckEngine
|
||||
if [ $? -eq 2 ]; then
|
||||
echo "No js engine found and engine not required; test vacuously passes."
|
||||
exit 0
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
. ${TESTSRC-.}/common.sh
|
||||
|
||||
setup
|
||||
${JAVA} -cp ${TESTCLASSES} CheckEngine
|
||||
${JAVA} ${TESTVMOPTS} ${TESTJAVAOPTS} -cp ${TESTCLASSES} CheckEngine
|
||||
if [ $? -eq 2 ]; then
|
||||
echo "No js engine found and engine not required; test vacuously passes."
|
||||
exit 0
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
. ${TESTSRC-.}/common.sh
|
||||
|
||||
setup
|
||||
${JAVA} -cp ${TESTCLASSES} CheckEngine
|
||||
${JAVA} ${TESTVMOPTS} ${TESTJAVAOPTS} -cp ${TESTCLASSES} CheckEngine
|
||||
if [ $? -eq 2 ]; then
|
||||
echo "No js engine found and engine not required; test vacuously passes."
|
||||
exit 0
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
/**
|
||||
* @test
|
||||
* @bug 4806786 8023113
|
||||
* @modules jdk.jartool/sun.tools.jar
|
||||
* @modules jdk.jartool
|
||||
* @summary jar -C doesn't ignore multiple // in path
|
||||
*/
|
||||
|
||||
@ -32,10 +32,15 @@ import java.io.*;
|
||||
import java.nio.file.*;
|
||||
import java.util.*;
|
||||
import java.util.jar.*;
|
||||
import java.util.spi.ToolProvider;
|
||||
import java.util.stream.Stream;
|
||||
import sun.tools.jar.Main;
|
||||
|
||||
public class ChangeDir {
|
||||
private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
|
||||
.orElseThrow(() ->
|
||||
new RuntimeException("jar tool not found")
|
||||
);
|
||||
|
||||
private final static String jarName = "test.jar";
|
||||
private final static String fileName = "hello.txt";
|
||||
|
||||
@ -88,8 +93,9 @@ public class ChangeDir {
|
||||
argList.add(topDir.toString() + sep + "a" + sep + sep + "b"); // Note double 'sep' is intentional
|
||||
argList.add(fileName);
|
||||
|
||||
Main jarTool = new Main(System.out, System.err, "jar");
|
||||
if (!jarTool.run(argList.toArray(new String[argList.size()]))) {
|
||||
int rc = JAR_TOOL.run(System.out, System.err,
|
||||
argList.toArray(new String[argList.size()]));
|
||||
if (rc != 0) {
|
||||
fail("Could not create jar file.");
|
||||
}
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
* duplicates that sometimes cause exceptions and other times do not,
|
||||
* demonstrating identical behavior to JDK 8 jar tool.
|
||||
* @library /lib/testlibrary
|
||||
* @modules jdk.jartool/sun.tools.jar
|
||||
* @modules jdk.jartool
|
||||
* @build jdk.testlibrary.FileUtils
|
||||
* @run testng InputFilesTest
|
||||
*/
|
||||
@ -47,12 +47,18 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.spi.ToolProvider;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.zip.ZipException;
|
||||
|
||||
import jdk.testlibrary.FileUtils;
|
||||
|
||||
public class InputFilesTest {
|
||||
private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
|
||||
.orElseThrow(() ->
|
||||
new RuntimeException("jar tool not found")
|
||||
);
|
||||
|
||||
private final String nl = System.lineSeparator();
|
||||
private final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
private final PrintStream out = new PrintStream(baos);
|
||||
@ -195,9 +201,9 @@ public class InputFilesTest {
|
||||
PrintStream err = new PrintStream(baes);
|
||||
PrintStream saveErr = System.err;
|
||||
System.setErr(err);
|
||||
boolean ok = new sun.tools.jar.Main(out, err, "jar").run(cmdline.split(" +"));
|
||||
int rc = JAR_TOOL.run(out, err, cmdline.split(" +"));
|
||||
System.setErr(saveErr);
|
||||
if (!ok) {
|
||||
if (rc != 0) {
|
||||
String s = baes.toString();
|
||||
if (s.startsWith("java.util.zip.ZipException: duplicate entry: ")) {
|
||||
throw new ZipException(s);
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
/*
|
||||
* @test
|
||||
* @bug 7201156
|
||||
* @modules jdk.jartool/sun.tools.jar
|
||||
* @modules jdk.jartool
|
||||
* @summary jar tool fails to convert file separation characters for list and extract
|
||||
* @author Sean Chou
|
||||
*/
|
||||
@ -43,10 +43,13 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarOutputStream;
|
||||
|
||||
import sun.tools.jar.Main;
|
||||
import java.util.spi.ToolProvider;
|
||||
|
||||
public class JarBackSlash {
|
||||
private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
|
||||
.orElseThrow(() ->
|
||||
new RuntimeException("jar tool not found")
|
||||
);
|
||||
|
||||
// used construct an entry JarBackSlash/dir/file.txt
|
||||
private static String JARBACKSLASH = "JarBackSlash";
|
||||
@ -78,8 +81,8 @@ public class JarBackSlash {
|
||||
PipedInputStream pipedInput = new PipedInputStream(pipedOutput);
|
||||
PrintStream out = new PrintStream(pipedOutput);
|
||||
|
||||
Main jarTool = new Main(out, System.err, "jar");
|
||||
if (!jarTool.run(jarArgs)) {
|
||||
int rc = JAR_TOOL.run(out, System.err, jarArgs);
|
||||
if (rc != 0) {
|
||||
fail("Could not list jar file.");
|
||||
}
|
||||
|
||||
@ -101,8 +104,8 @@ public class JarBackSlash {
|
||||
PipedInputStream pipedInput = new PipedInputStream(pipedOutput);
|
||||
PrintStream out = new PrintStream(pipedOutput);
|
||||
|
||||
Main jarTool = new Main(out, System.err, "jar");
|
||||
if (!jarTool.run(jarArgs)) {
|
||||
int rc = JAR_TOOL.run(out, System.err, jarArgs);
|
||||
if (rc != 0) {
|
||||
fail("Could not list jar file.");
|
||||
}
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
/**
|
||||
* @test
|
||||
* @bug 4225317 6969651
|
||||
* @modules jdk.jartool/sun.tools.jar
|
||||
* @modules jdk.jartool
|
||||
* @summary Check extracted files have date as per those in the .jar file
|
||||
*/
|
||||
|
||||
@ -33,9 +33,14 @@ import java.io.PrintWriter;
|
||||
import java.nio.file.attribute.FileTime;
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
import sun.tools.jar.Main;
|
||||
import java.util.spi.ToolProvider;
|
||||
|
||||
public class JarEntryTime {
|
||||
static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
|
||||
.orElseThrow(() ->
|
||||
new RuntimeException("jar tool not found")
|
||||
);
|
||||
|
||||
|
||||
// ZipEntry's mod date has 2 seconds precision: give extra time to
|
||||
// allow for e.g. rounding/truncation and networked/samba drives.
|
||||
@ -114,10 +119,8 @@ public class JarEntryTime {
|
||||
check(fileInner.setLastModified(earlier));
|
||||
|
||||
// Make a jar file from that directory structure
|
||||
Main jartool = new Main(System.out, System.err, "jar");
|
||||
check(jartool.run(new String[] {
|
||||
"cf",
|
||||
jarFile.getName(), dirOuter.getName() } ));
|
||||
check(JAR_TOOL.run(System.out, System.err,
|
||||
"cf", jarFile.getName(), dirOuter.getName()) == 0);
|
||||
check(jarFile.exists());
|
||||
|
||||
check(cleanup(dirInner));
|
||||
@ -142,7 +145,6 @@ public class JarEntryTime {
|
||||
final long start = testFile.lastModified();
|
||||
|
||||
// Extract and check the last modified values are the current times.
|
||||
// See sun.tools.jar.Main
|
||||
extractJar(jarFile, true);
|
||||
|
||||
try (PrintWriter pw = new PrintWriter(testFile)) {
|
||||
|
||||
165
jdk/test/tools/jar/ReleaseBeforeFiles.java
Normal file
165
jdk/test/tools/jar/ReleaseBeforeFiles.java
Normal file
@ -0,0 +1,165 @@
|
||||
/*
|
||||
* Copyright (c) 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
|
||||
* 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 8167237
|
||||
* @summary test that both old style command line options and new gnu style
|
||||
* command line options work with the --release option whether or
|
||||
* not the --release option is preceded by a file name.
|
||||
* @library /lib/testlibrary
|
||||
* @modules jdk.jartool/sun.tools.jar
|
||||
* @build jdk.testlibrary.FileUtils
|
||||
* @run testng ReleaseBeforeFiles
|
||||
*/
|
||||
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import jdk.testlibrary.FileUtils;
|
||||
|
||||
public class ReleaseBeforeFiles {
|
||||
private Runnable onCompletion;
|
||||
|
||||
@BeforeMethod
|
||||
public void reset() {
|
||||
onCompletion = null;
|
||||
}
|
||||
|
||||
@AfterMethod
|
||||
public void run() {
|
||||
if (onCompletion != null) {
|
||||
onCompletion.run();
|
||||
}
|
||||
}
|
||||
|
||||
@Test // passes before bug fix
|
||||
public void test1() throws IOException {
|
||||
mkdir("test1");
|
||||
touch("test1/testfile1");
|
||||
jar("cf test.jar --release 9 test1");
|
||||
jar("tf test.jar");
|
||||
rm("test.jar test1");
|
||||
}
|
||||
|
||||
@Test // fails before bug fix
|
||||
public void test2() throws IOException {
|
||||
System.out.println("=====");
|
||||
mkdir("test1");
|
||||
touch("test1/testfile1");
|
||||
onCompletion = () -> rm("test.jar test1");
|
||||
jar("--create --file=test.jar --release 9 test1");
|
||||
jar("tf test.jar");
|
||||
}
|
||||
|
||||
@Test // passes before bug fix
|
||||
public void test3() throws IOException {
|
||||
System.out.println("=====");
|
||||
mkdir("test1");
|
||||
touch("test1/testfile1");
|
||||
jar("-cf test.jar -C test1 .");
|
||||
jar("-uf test.jar --release 9 -C test1 .");
|
||||
jar("tf test.jar");
|
||||
rm("test.jar test1");
|
||||
}
|
||||
|
||||
@Test // fails before bug fix
|
||||
public void test4() throws IOException {
|
||||
System.out.println("=====");
|
||||
mkdir("test1");
|
||||
touch("test1/testfile1");
|
||||
onCompletion = () -> rm("test.jar test1");
|
||||
jar("--create --file=test.jar -C test1 .");
|
||||
jar("--update --file=test.jar --release 9 -C test1 .");
|
||||
jar("tf test.jar");
|
||||
}
|
||||
|
||||
@Test // passes before bug fix since test2 precedes --release 9
|
||||
public void test5() throws IOException {
|
||||
System.out.println("=====");
|
||||
mkdir("test1 test2");
|
||||
touch("test1/testfile1 test2/testfile2");
|
||||
jar("--create --file=test.jar -C test1 .");
|
||||
jar("--update --file=test.jar test2 --release 9 -C test1 .");
|
||||
jar("tf test.jar");
|
||||
rm("test.jar test1 test2");
|
||||
}
|
||||
|
||||
private Stream<Path> mkpath(String... args) {
|
||||
return Arrays.stream(args).map(d -> Paths.get(".", d.split("/")));
|
||||
}
|
||||
|
||||
private void mkdir(String cmdline) {
|
||||
System.out.println("mkdir -p " + cmdline);
|
||||
mkpath(cmdline.split(" +")).forEach(p -> {
|
||||
try {
|
||||
Files.createDirectories(p);
|
||||
} catch (IOException x) {
|
||||
throw new UncheckedIOException(x);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void touch(String cmdline) {
|
||||
System.out.println("touch " + cmdline);
|
||||
mkpath(cmdline.split(" +")).forEach(p -> {
|
||||
try {
|
||||
Files.createFile(p);
|
||||
} catch (IOException x) {
|
||||
throw new UncheckedIOException(x);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void rm(String cmdline) {
|
||||
System.out.println("rm -rf " + cmdline);
|
||||
mkpath(cmdline.split(" +")).forEach(p -> {
|
||||
try {
|
||||
if (Files.isDirectory(p)) {
|
||||
FileUtils.deleteFileTreeWithRetry(p);
|
||||
} else {
|
||||
FileUtils.deleteFileIfExistsWithRetry(p);
|
||||
}
|
||||
} catch (IOException x) {
|
||||
throw new UncheckedIOException(x);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void jar(String cmdline) throws IOException {
|
||||
System.out.println("jar " + cmdline);
|
||||
boolean ok = new sun.tools.jar.Main(System.out, System.err, "jar")
|
||||
.run(cmdline.split(" +"));
|
||||
Assert.assertTrue(ok);
|
||||
}
|
||||
}
|
||||
@ -24,7 +24,7 @@
|
||||
/**
|
||||
* @test
|
||||
* @bug 7175845
|
||||
* @modules jdk.jartool/sun.tools.jar
|
||||
* @modules jdk.jartool
|
||||
* @summary jar -uf should not change file permission
|
||||
*/
|
||||
|
||||
@ -32,9 +32,13 @@ import java.io.*;
|
||||
import java.nio.file.*;
|
||||
import java.nio.file.attribute.*;
|
||||
import java.util.Set;
|
||||
import sun.tools.jar.Main;
|
||||
import java.util.spi.ToolProvider;
|
||||
|
||||
public class UpdateJar {
|
||||
private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
|
||||
.orElseThrow(() ->
|
||||
new RuntimeException("jar tool not found")
|
||||
);
|
||||
|
||||
private static void cleanup(String... fnames) throws Throwable {
|
||||
for (String fname : fnames) {
|
||||
@ -55,12 +59,12 @@ public class UpdateJar {
|
||||
fos1.write(0);
|
||||
}
|
||||
String[] jarArgs = new String[] {"cfM0", jar, e0};
|
||||
if (!new Main(System.out, System.err, "jar").run(jarArgs)) {
|
||||
if (JAR_TOOL.run(System.out, System.err, jarArgs) != 0) {
|
||||
fail("Could not create jar file.");
|
||||
}
|
||||
Set<PosixFilePermission> pm = Files.getPosixFilePermissions(Paths.get(jar));
|
||||
jarArgs = new String[] {"uf", jar, e1};
|
||||
if (!new Main(System.out, System.err, "jar").run(jarArgs)) {
|
||||
if (JAR_TOOL.run(System.out, System.err, jarArgs) != 0) {
|
||||
fail("Could not create jar file.");
|
||||
}
|
||||
equal(pm, Files.getPosixFilePermissions(Paths.get(jar)));
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
/**
|
||||
* @test
|
||||
* @bug 6434207 6442687 6984046
|
||||
* @modules jdk.jartool/sun.tools.jar
|
||||
* @modules jdk.jartool
|
||||
* @summary Ensure that jar ufm actually updates the
|
||||
* existing jar file's manifest with contents of the
|
||||
* manifest file.
|
||||
@ -32,14 +32,19 @@
|
||||
|
||||
import java.io.*;
|
||||
import java.util.logging.*;
|
||||
import java.util.spi.ToolProvider;
|
||||
import java.util.zip.*;
|
||||
import sun.tools.jar.Main;
|
||||
|
||||
public class UpdateManifest {
|
||||
static PrintStream out = System.out;
|
||||
static PrintStream err = System.err;
|
||||
static boolean debug = true;
|
||||
|
||||
static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
|
||||
.orElseThrow(() ->
|
||||
new RuntimeException("jar tool not found")
|
||||
);
|
||||
|
||||
static final Logger JAR_LOGGER = Logger.getLogger("java.util.jar");
|
||||
|
||||
public static void realMain(String[] args) throws Throwable {
|
||||
@ -64,17 +69,14 @@ public class UpdateManifest {
|
||||
// Create a jar file, specifying a Main-Class
|
||||
final String jarFileName = "um-existence.jar";
|
||||
new File(jarFileName).delete(); // remove pre-existing first!
|
||||
Main jartool = new Main(out, err, "jar");
|
||||
boolean status = jartool.run(
|
||||
new String[] { "cfe", jarFileName, "Hello", existence.getPath() });
|
||||
check(status);
|
||||
int status = JAR_TOOL.run(out, err, "cfe", jarFileName,
|
||||
"Hello", existence.getPath());
|
||||
check(status == 0);
|
||||
checkManifest(jarFileName, "Hello");
|
||||
|
||||
// Update that jar file by changing the Main-Class
|
||||
jartool = new Main(out, err, "jar");
|
||||
status = jartool.run(
|
||||
new String[] { "ufe", jarFileName, "Bye" });
|
||||
check(status);
|
||||
status = JAR_TOOL.run(out, err, "ufe", jarFileName, "Bye");
|
||||
check(status == 0);
|
||||
checkManifest(jarFileName, "Bye");
|
||||
}
|
||||
|
||||
@ -101,11 +103,9 @@ public class UpdateManifest {
|
||||
// Create a jar file
|
||||
final String jarFileName = "um-test.jar";
|
||||
new File(jarFileName).delete(); // remove pre-existing first!
|
||||
Main jartool = new Main(out, err, "jar");
|
||||
boolean status = jartool.run(
|
||||
new String[] {"cfm", jarFileName,
|
||||
manifestOrig.getPath(), hello.getPath() });
|
||||
check(status);
|
||||
int status = JAR_TOOL.run(out, err, "cfm", jarFileName,
|
||||
manifestOrig.getPath(), hello.getPath());
|
||||
check(status == 0);
|
||||
|
||||
// Create a new manifest, to use in updating the jar file.
|
||||
File manifestUpdate = File.createTempFile("manifestUpdate", ".txt");
|
||||
@ -122,10 +122,9 @@ public class UpdateManifest {
|
||||
pw.close();
|
||||
|
||||
// Update jar file with manifest
|
||||
jartool = new Main(out, err, "jar");
|
||||
status = jartool.run(
|
||||
new String[] { "ufm", jarFileName, manifestUpdate.getPath() });
|
||||
check(status);
|
||||
status = JAR_TOOL.run(out, err, "ufm",
|
||||
jarFileName, manifestUpdate.getPath());
|
||||
check(status == 0);
|
||||
|
||||
// Extract jar, and verify contents of manifest file
|
||||
File f = new File(jarFileName);
|
||||
|
||||
@ -24,17 +24,21 @@
|
||||
/*
|
||||
* @test
|
||||
* @bug 4408526 6854795
|
||||
* @modules jdk.jartool/sun.tools.jar
|
||||
* @modules jdk.jartool
|
||||
* @summary Index the non-meta files in META-INF, such as META-INF/services.
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.jar.*;
|
||||
import sun.tools.jar.Main;
|
||||
import java.util.spi.ToolProvider;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
public class MetaInf {
|
||||
static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
|
||||
.orElseThrow(() ->
|
||||
new RuntimeException("jar tool not found")
|
||||
);
|
||||
|
||||
static String jarName = "a.jar";
|
||||
static String INDEX = "META-INF/INDEX.LIST";
|
||||
@ -43,7 +47,7 @@ public class MetaInf {
|
||||
System.getProperty("test.src") + File.separatorChar + "jarcontents";
|
||||
|
||||
static void run(String ... args) {
|
||||
if (! new Main(System.out, System.err, "jar").run(args))
|
||||
if (JAR_TOOL.run(System.out, System.err, args) != 0)
|
||||
throw new Error("jar failed: args=" + Arrays.toString(args));
|
||||
}
|
||||
|
||||
|
||||
@ -32,13 +32,13 @@ import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.spi.ToolProvider;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import jdk.tools.jlink.plugin.Plugin;
|
||||
import jdk.tools.jlink.internal.PluginRepository;
|
||||
import tests.Helper;
|
||||
import tests.JImageGenerator;
|
||||
import tests.JImageGenerator.InMemoryFile;
|
||||
|
||||
/*
|
||||
* @test
|
||||
@ -48,13 +48,17 @@ import tests.JImageGenerator.InMemoryFile;
|
||||
* @modules java.base/jdk.internal.jimage
|
||||
* jdk.jdeps/com.sun.tools.classfile
|
||||
* jdk.jlink/jdk.tools.jlink.internal
|
||||
* jdk.jlink/jdk.tools.jmod
|
||||
* jdk.jlink/jdk.tools.jimage
|
||||
* jdk.compiler
|
||||
* @build tests.*
|
||||
* @run main/othervm -Xmx1g JLinkTest
|
||||
*/
|
||||
public class JLinkTest {
|
||||
static final ToolProvider JLINK_TOOL = ToolProvider.findFirst("jlink")
|
||||
.orElseThrow(() ->
|
||||
new RuntimeException("jlink tool not found")
|
||||
);
|
||||
|
||||
// number of built-in plugins from jdk.jlink module
|
||||
private static int getNumJlinkPlugins() {
|
||||
ModuleDescriptor desc = Plugin.class.getModule().getDescriptor();
|
||||
@ -180,7 +184,8 @@ public class JLinkTest {
|
||||
{
|
||||
// Help
|
||||
StringWriter writer = new StringWriter();
|
||||
jdk.tools.jlink.internal.Main.run(new String[]{"--help"}, new PrintWriter(writer));
|
||||
PrintWriter pw = new PrintWriter(writer);
|
||||
JLINK_TOOL.run(pw, pw, "--help");
|
||||
String output = writer.toString();
|
||||
if (output.split("\n").length < 10) {
|
||||
System.err.println(output);
|
||||
@ -202,7 +207,9 @@ public class JLinkTest {
|
||||
{
|
||||
// List plugins
|
||||
StringWriter writer = new StringWriter();
|
||||
jdk.tools.jlink.internal.Main.run(new String[]{"--list-plugins"}, new PrintWriter(writer));
|
||||
PrintWriter pw = new PrintWriter(writer);
|
||||
|
||||
JLINK_TOOL.run(pw, pw, "--list-plugins");
|
||||
String output = writer.toString();
|
||||
long number = Stream.of(output.split("\\R"))
|
||||
.filter((s) -> s.matches("Plugin Name:.*"))
|
||||
|
||||
@ -27,8 +27,7 @@
|
||||
* @author Andrei Eremeev
|
||||
* @library /lib/testlibrary
|
||||
* @modules java.base/jdk.internal.module
|
||||
* jdk.jlink/jdk.tools.jlink.internal
|
||||
* jdk.jlink/jdk.tools.jmod
|
||||
* jdk.jlink
|
||||
* jdk.compiler
|
||||
* @build jdk.testlibrary.ProcessTools
|
||||
* jdk.testlibrary.OutputAnalyzer
|
||||
@ -44,11 +43,21 @@ import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.spi.ToolProvider;
|
||||
|
||||
import jdk.testlibrary.OutputAnalyzer;
|
||||
import jdk.testlibrary.ProcessTools;
|
||||
|
||||
public class BasicTest {
|
||||
static final ToolProvider JMOD_TOOL = ToolProvider.findFirst("jmod")
|
||||
.orElseThrow(() ->
|
||||
new RuntimeException("jmod tool not found")
|
||||
);
|
||||
|
||||
static final ToolProvider JLINK_TOOL = ToolProvider.findFirst("jlink")
|
||||
.orElseThrow(() ->
|
||||
new RuntimeException("jlink tool not found")
|
||||
);
|
||||
|
||||
private final Path jdkHome = Paths.get(System.getProperty("test.jdk"));
|
||||
private final Path jdkMods = jdkHome.resolve("jmods");
|
||||
@ -110,20 +119,22 @@ public class BasicTest {
|
||||
"--add-modules", modName,
|
||||
"--output", image.toString());
|
||||
Collections.addAll(args, options);
|
||||
int rc = jdk.tools.jlink.internal.Main.run(args.toArray(new String[args.size()]), new PrintWriter(System.out));
|
||||
|
||||
PrintWriter pw = new PrintWriter(System.out);
|
||||
int rc = JLINK_TOOL.run(pw, pw, args.toArray(new String[args.size()]));
|
||||
if (rc != 0) {
|
||||
throw new AssertionError("Jlink failed: rc = " + rc);
|
||||
}
|
||||
}
|
||||
|
||||
private void runJmod(String cp, String modName) {
|
||||
int rc = jdk.tools.jmod.Main.run(new String[] {
|
||||
int rc = JMOD_TOOL.run(System.out, System.out, new String[] {
|
||||
"create",
|
||||
"--class-path", cp,
|
||||
"--module-version", "1.0",
|
||||
"--main-class", "jdk.test.Test",
|
||||
jmods.resolve(modName + ".jmod").toString(),
|
||||
}, System.out);
|
||||
});
|
||||
if (rc != 0) {
|
||||
throw new AssertionError("Jmod failed: rc = " + rc);
|
||||
}
|
||||
|
||||
@ -24,8 +24,8 @@
|
||||
/*
|
||||
* @test
|
||||
* @library /lib/testlibrary
|
||||
* @modules jdk.jlink/jdk.tools.jmod
|
||||
* jdk.compiler
|
||||
* @modules jdk.compiler
|
||||
* jdk.jlink
|
||||
* @build jdk.testlibrary.FileUtils CompilerUtils
|
||||
* @run testng JmodNegativeTest
|
||||
* @summary Negative tests for jmod
|
||||
@ -39,6 +39,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.spi.ToolProvider;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
import jdk.testlibrary.FileUtils;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
@ -51,6 +52,11 @@ import static org.testng.Assert.assertTrue;
|
||||
|
||||
public class JmodNegativeTest {
|
||||
|
||||
static final ToolProvider JMOD_TOOL = ToolProvider.findFirst("jmod")
|
||||
.orElseThrow(() ->
|
||||
new RuntimeException("jmod tool not found")
|
||||
);
|
||||
|
||||
static final String TEST_SRC = System.getProperty("test.src", ".");
|
||||
static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
|
||||
static final Path EXPLODED_DIR = Paths.get("build");
|
||||
@ -515,7 +521,7 @@ public class JmodNegativeTest {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
PrintStream ps = new PrintStream(baos);
|
||||
System.out.println("jmod " + Arrays.asList(args));
|
||||
int ec = jdk.tools.jmod.Main.run(args, ps);
|
||||
int ec = JMOD_TOOL.run(ps, ps, args);
|
||||
return new JmodResult(ec, new String(baos.toByteArray(), UTF_8));
|
||||
}
|
||||
|
||||
|
||||
@ -24,8 +24,8 @@
|
||||
/*
|
||||
* @test
|
||||
* @library /lib/testlibrary
|
||||
* @modules jdk.jlink/jdk.tools.jmod
|
||||
* jdk.compiler
|
||||
* @modules jdk.compiler
|
||||
* jdk.jlink
|
||||
* @build jdk.testlibrary.FileUtils CompilerUtils
|
||||
* @run testng JmodTest
|
||||
* @summary Basic test for jmod
|
||||
@ -38,6 +38,7 @@ import java.nio.file.*;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.spi.ToolProvider;
|
||||
import java.util.stream.Stream;
|
||||
import jdk.testlibrary.FileUtils;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
@ -51,6 +52,11 @@ import static org.testng.Assert.*;
|
||||
|
||||
public class JmodTest {
|
||||
|
||||
static final ToolProvider JMOD_TOOL = ToolProvider.findFirst("jmod")
|
||||
.orElseThrow(() ->
|
||||
new RuntimeException("jmod tool not found")
|
||||
);
|
||||
|
||||
static final String TEST_SRC = System.getProperty("test.src", ".");
|
||||
static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
|
||||
static final Path EXPLODED_DIR = Paths.get("build");
|
||||
@ -479,7 +485,7 @@ public class JmodTest {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
PrintStream ps = new PrintStream(baos);
|
||||
System.out.println("jmod " + Arrays.asList(args));
|
||||
int ec = jdk.tools.jmod.Main.run(args, ps);
|
||||
int ec = JMOD_TOOL.run(ps, ps, args);
|
||||
return new JmodResult(ec, new String(baos.toByteArray(), UTF_8));
|
||||
}
|
||||
|
||||
|
||||
@ -27,8 +27,7 @@
|
||||
* @author Andrei Eremeev
|
||||
* @library /lib/testlibrary
|
||||
* @modules java.base/jdk.internal.module
|
||||
* jdk.jlink/jdk.tools.jlink.internal
|
||||
* jdk.jlink/jdk.tools.jmod
|
||||
* jdk.jlink
|
||||
* jdk.compiler
|
||||
* @build CompilerUtils
|
||||
* @run testng HashesTest
|
||||
@ -53,6 +52,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.spi.ToolProvider;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import jdk.internal.module.ConfigurableModuleFinder;
|
||||
@ -63,6 +63,10 @@ import org.testng.annotations.Test;
|
||||
import static org.testng.Assert.*;
|
||||
|
||||
public class HashesTest {
|
||||
static final ToolProvider JMOD_TOOL = ToolProvider.findFirst("jmod")
|
||||
.orElseThrow(() ->
|
||||
new RuntimeException("jmod tool not found")
|
||||
);
|
||||
|
||||
private final Path testSrc = Paths.get(System.getProperty("test.src"));
|
||||
private final Path modSrc = testSrc.resolve("src");
|
||||
@ -204,7 +208,7 @@ public class HashesTest {
|
||||
}
|
||||
|
||||
private void runJmod(List<String> args) {
|
||||
int rc = jdk.tools.jmod.Main.run(args.toArray(new String[args.size()]), System.out);
|
||||
int rc = JMOD_TOOL.run(System.out, System.out, args.toArray(new String[args.size()]));
|
||||
System.out.println("jmod options: " + args.stream().collect(Collectors.joining(" ")));
|
||||
if (rc != 0) {
|
||||
throw new AssertionError("Jmod failed: rc = " + rc);
|
||||
|
||||
@ -24,9 +24,9 @@
|
||||
/**
|
||||
* @test
|
||||
* @library /lib/testlibrary
|
||||
* @modules jdk.jartool/sun.tools.jar
|
||||
* jdk.jlink/jdk.tools.jmod
|
||||
* jdk.compiler
|
||||
* @modules jdk.compiler
|
||||
* jdk.jartool
|
||||
* jdk.jlink
|
||||
* @build BasicTest CompilerUtils jdk.testlibrary.*
|
||||
* @run testng BasicTest
|
||||
* @summary Basic test of starting an application as a module
|
||||
@ -36,6 +36,7 @@ import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.spi.ToolProvider;
|
||||
|
||||
import jdk.testlibrary.ProcessTools;
|
||||
|
||||
@ -46,6 +47,14 @@ import static org.testng.Assert.*;
|
||||
|
||||
@Test
|
||||
public class BasicTest {
|
||||
private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
|
||||
.orElseThrow(() ->
|
||||
new RuntimeException("jar tool not found")
|
||||
);
|
||||
private static final ToolProvider JMOD_TOOL = ToolProvider.findFirst("jmod")
|
||||
.orElseThrow(() ->
|
||||
new RuntimeException("jmod tool not found")
|
||||
);
|
||||
|
||||
private static final Path USER_DIR = Paths.get(System.getProperty("user.dir"));
|
||||
|
||||
@ -132,10 +141,8 @@ public class BasicTest {
|
||||
"--main-class=" + MAIN_CLASS,
|
||||
"-C", classes, "."
|
||||
};
|
||||
boolean success
|
||||
= new sun.tools.jar.Main(System.out, System.out, "jar")
|
||||
.run(args);
|
||||
assertTrue(success);
|
||||
int rc = JAR_TOOL.run(System.out, System.out, args);
|
||||
assertTrue(rc == 0);
|
||||
|
||||
// java --module-path mlib -module $TESTMODULE
|
||||
int exitValue = exec("--module-path", dir.toString(),
|
||||
@ -164,8 +171,8 @@ public class BasicTest {
|
||||
"--main-class", MAIN_CLASS,
|
||||
jmod
|
||||
};
|
||||
jdk.tools.jmod.JmodTask task = new jdk.tools.jmod.JmodTask();
|
||||
assertEquals(task.run(args), 0);
|
||||
|
||||
assertEquals(JMOD_TOOL.run(System.out, System.out, args), 0);
|
||||
|
||||
// java --module-path mods --module $TESTMODULE
|
||||
int exitValue = exec("--module-path", dir.toString(),
|
||||
@ -229,10 +236,8 @@ public class BasicTest {
|
||||
"--file=" + jar,
|
||||
"-C", classes, "."
|
||||
};
|
||||
boolean success
|
||||
= new sun.tools.jar.Main(System.out, System.out, "jar")
|
||||
.run(args);
|
||||
assertTrue(success);
|
||||
int rc = JAR_TOOL.run(System.out, System.out, args);
|
||||
assertTrue(rc == 0);
|
||||
|
||||
// java --module-path mods -m $TESTMODULE
|
||||
int exitValue = exec("--module-path", dir.toString(), "-m", TEST_MODULE);
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
* @bug 8159596
|
||||
* @library /lib/testlibrary
|
||||
* @modules jdk.compiler
|
||||
* jdk.jartool/sun.tools.jar
|
||||
* jdk.jartool
|
||||
* @build DryRunTest CompilerUtils jdk.testlibrary.ProcessTools
|
||||
* @run testng DryRunTest
|
||||
* @summary Test java --dry-run
|
||||
@ -37,6 +37,7 @@ import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.spi.ToolProvider;
|
||||
|
||||
import jdk.testlibrary.ProcessTools;
|
||||
|
||||
@ -78,8 +79,8 @@ public class DryRunTest {
|
||||
Files.createDirectories(LIBS_DIR);
|
||||
|
||||
// create JAR files with no module-info.class
|
||||
assertTrue(jar(M_MODULE, "p/Lib.class"));
|
||||
assertTrue(jar(TEST_MODULE, "jdk/test/Main.class"));
|
||||
assertTrue(jar(M_MODULE, "p/Lib.class") == 0);
|
||||
assertTrue(jar(TEST_MODULE, "jdk/test/Main.class") == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -197,7 +198,12 @@ public class DryRunTest {
|
||||
assertTrue(exitValue != 0);
|
||||
}
|
||||
|
||||
private static boolean jar(String name, String entries) throws IOException {
|
||||
private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
|
||||
.orElseThrow(() ->
|
||||
new RuntimeException("jar tool not found")
|
||||
);
|
||||
|
||||
private static int jar(String name, String entries) throws IOException {
|
||||
Path jar = LIBS_DIR.resolve(name + ".jar");
|
||||
|
||||
// jar --create ...
|
||||
@ -207,8 +213,6 @@ public class DryRunTest {
|
||||
"--file=" + jar,
|
||||
"-C", classes, entries
|
||||
};
|
||||
boolean success
|
||||
= new sun.tools.jar.Main(System.out, System.out, "jar").run(args);
|
||||
return success;
|
||||
return JAR_TOOL.run(System.out, System.out, args);
|
||||
}
|
||||
}
|
||||
|
||||
@ -338,6 +338,10 @@ public class JImageGenerator {
|
||||
}
|
||||
|
||||
public static class JModTask {
|
||||
static final java.util.spi.ToolProvider JMOD_TOOL =
|
||||
java.util.spi.ToolProvider.findFirst("jmod").orElseThrow(() ->
|
||||
new RuntimeException("jmod tool not found")
|
||||
);
|
||||
|
||||
private final List<Path> classpath = new ArrayList<>();
|
||||
private final List<Path> libs = new ArrayList<>();
|
||||
@ -477,7 +481,8 @@ public class JImageGenerator {
|
||||
String[] args = optionsJMod(cmd);
|
||||
System.err.println("jmod options: " + optionsPrettyPrint(args));
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
int exitCode = jdk.tools.jmod.Main.run(args, new PrintStream(baos));
|
||||
PrintStream ps = new PrintStream(baos);
|
||||
int exitCode = JMOD_TOOL.run(ps, ps, args);
|
||||
String msg = new String(baos.toByteArray());
|
||||
return new Result(exitCode, msg, output);
|
||||
}
|
||||
@ -556,6 +561,10 @@ public class JImageGenerator {
|
||||
}
|
||||
|
||||
public static class JLinkTask {
|
||||
static final java.util.spi.ToolProvider JLINK_TOOL =
|
||||
java.util.spi.ToolProvider.findFirst("jlink").orElseThrow(() ->
|
||||
new RuntimeException("jlink tool not found")
|
||||
);
|
||||
|
||||
private final List<Path> jars = new ArrayList<>();
|
||||
private final List<Path> jmods = new ArrayList<>();
|
||||
@ -691,7 +700,8 @@ public class JImageGenerator {
|
||||
String[] args = optionsJLink();
|
||||
System.err.println("jlink options: " + optionsPrettyPrint(args));
|
||||
StringWriter writer = new StringWriter();
|
||||
int exitCode = jdk.tools.jlink.internal.Main.run(args, new PrintWriter(writer));
|
||||
PrintWriter pw = new PrintWriter(writer);
|
||||
int exitCode = JLINK_TOOL.run(pw, pw, args);
|
||||
return new Result(exitCode, writer.toString(), output);
|
||||
}
|
||||
|
||||
@ -699,7 +709,8 @@ public class JImageGenerator {
|
||||
String[] args = optionsPostProcessJLink();
|
||||
System.err.println("jlink options: " + optionsPrettyPrint(args));
|
||||
StringWriter writer = new StringWriter();
|
||||
int exitCode = jdk.tools.jlink.internal.Main.run(args, new PrintWriter(writer));
|
||||
PrintWriter pw = new PrintWriter(writer);
|
||||
int exitCode = JLINK_TOOL.run(pw, pw, args);
|
||||
return new Result(exitCode, writer.toString(), output);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user