mirror of
https://github.com/openjdk/jdk18u.git
synced 2025-12-10 00:37:05 -06:00
Merge
This commit is contained in:
commit
9ddf0a10f8
6
.github/workflows/submit.yml
vendored
6
.github/workflows/submit.yml
vendored
@ -924,7 +924,7 @@ jobs:
|
||||
|
||||
- name: Install cygwin
|
||||
run: |
|
||||
Start-Process -FilePath "$HOME\cygwin\setup-x86_64.exe" -ArgumentList "--quiet-mode --packages cygwin=3.2.0-1,autoconf,make,zip,unzip --root $HOME\cygwin\cygwin64 --local-package-dir $HOME\cygwin\packages --site http://mirrors.kernel.org/sourceware/cygwin --no-desktop --no-shortcuts --no-startmenu --no-admin" -Wait -NoNewWindow
|
||||
Start-Process -FilePath "$HOME\cygwin\setup-x86_64.exe" -ArgumentList "--quiet-mode --packages cygwin=3.3.5-1,autoconf,make,zip,unzip --root $HOME\cygwin\cygwin64 --local-package-dir $HOME\cygwin\packages --site http://mirrors.kernel.org/sourceware/cygwin --no-desktop --no-shortcuts --no-startmenu --no-admin" -Wait -NoNewWindow
|
||||
|
||||
- name: Checkout the source
|
||||
uses: actions/checkout@v3
|
||||
@ -1024,7 +1024,7 @@ jobs:
|
||||
|
||||
- name: Install cygwin
|
||||
run: |
|
||||
Start-Process -FilePath "$HOME\cygwin\setup-x86_64.exe" -ArgumentList "--quiet-mode --packages cygwin=3.2.0-1,autoconf,make,zip,unzip --root $HOME\cygwin\cygwin64 --local-package-dir $HOME\cygwin\packages --site http://mirrors.kernel.org/sourceware/cygwin --no-desktop --no-shortcuts --no-startmenu --no-admin" -Wait -NoNewWindow
|
||||
Start-Process -FilePath "$HOME\cygwin\setup-x86_64.exe" -ArgumentList "--quiet-mode --packages cygwin=3.3.5-1,autoconf,make,zip,unzip --root $HOME\cygwin\cygwin64 --local-package-dir $HOME\cygwin\packages --site http://mirrors.kernel.org/sourceware/cygwin --no-desktop --no-shortcuts --no-startmenu --no-admin" -Wait -NoNewWindow
|
||||
|
||||
- name: Checkout the source
|
||||
uses: actions/checkout@v3
|
||||
@ -1207,7 +1207,7 @@ jobs:
|
||||
|
||||
- name: Install cygwin
|
||||
run: |
|
||||
Start-Process -FilePath "$HOME\cygwin\setup-x86_64.exe" -ArgumentList "--quiet-mode --packages cygwin=3.2.0-1,autoconf,make,zip,unzip --root $HOME\cygwin\cygwin64 --local-package-dir $HOME\cygwin\packages --site http://mirrors.kernel.org/sourceware/cygwin --no-desktop --no-shortcuts --no-startmenu --no-admin" -Wait -NoNewWindow
|
||||
Start-Process -FilePath "$HOME\cygwin\setup-x86_64.exe" -ArgumentList "--quiet-mode --packages cygwin=3.3.5-1,autoconf,make,zip,unzip --root $HOME\cygwin\cygwin64 --local-package-dir $HOME\cygwin\packages --site http://mirrors.kernel.org/sourceware/cygwin --no-desktop --no-shortcuts --no-startmenu --no-admin" -Wait -NoNewWindow
|
||||
|
||||
- name: Restore jtreg artifact
|
||||
id: jtreg_restore
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,12 +26,13 @@
|
||||
package jdk.internal.util;
|
||||
|
||||
import java.util.Properties;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
/**
|
||||
* System Property access for internal use only.
|
||||
* Read-only access to System property values initialized during Phase 1
|
||||
* are cached. Setting, clearing, or modifying the value using
|
||||
* {@link System#setProperty) or {@link System#getProperties()} is ignored.
|
||||
* {@link System#setProperty} or {@link System#getProperties()} is ignored.
|
||||
* <strong>{@link SecurityManager#checkPropertyAccess} is NOT checked
|
||||
* in these access methods. The caller of these methods should take care to ensure
|
||||
* that the returned property is not made accessible to untrusted code.</strong>
|
||||
@ -52,6 +53,8 @@ public final class StaticProperty {
|
||||
private static final String NATIVE_ENCODING;
|
||||
private static final String FILE_ENCODING;
|
||||
private static final String JAVA_PROPERTIES_DATE;
|
||||
private static final String SUN_JNU_ENCODING;
|
||||
private static final Charset jnuCharset;
|
||||
|
||||
private StaticProperty() {}
|
||||
|
||||
@ -69,6 +72,8 @@ public final class StaticProperty {
|
||||
NATIVE_ENCODING = getProperty(props, "native.encoding");
|
||||
FILE_ENCODING = getProperty(props, "file.encoding");
|
||||
JAVA_PROPERTIES_DATE = getProperty(props, "java.properties.date", null);
|
||||
SUN_JNU_ENCODING = getProperty(props, "sun.jnu.encoding");
|
||||
jnuCharset = Charset.forName(SUN_JNU_ENCODING, Charset.defaultCharset());
|
||||
}
|
||||
|
||||
private static String getProperty(Properties props, String key) {
|
||||
@ -86,91 +91,77 @@ public final class StaticProperty {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@code java.home} system property.
|
||||
* {@return the {@code java.home} system property}
|
||||
*
|
||||
* <strong>{@link SecurityManager#checkPropertyAccess} is NOT checked
|
||||
* in this method. The caller of this method should take care to ensure
|
||||
* that the returned property is not made accessible to untrusted code.</strong>
|
||||
*
|
||||
* @return the {@code java.home} system property
|
||||
*/
|
||||
public static String javaHome() {
|
||||
return JAVA_HOME;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@code user.home} system property.
|
||||
* {@return the {@code user.home} system property}
|
||||
*
|
||||
* <strong>{@link SecurityManager#checkPropertyAccess} is NOT checked
|
||||
* in this method. The caller of this method should take care to ensure
|
||||
* that the returned property is not made accessible to untrusted code.</strong>
|
||||
*
|
||||
* @return the {@code user.home} system property
|
||||
*/
|
||||
public static String userHome() {
|
||||
return USER_HOME;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@code user.dir} system property.
|
||||
* {@return the {@code user.dir} system property}
|
||||
*
|
||||
* <strong>{@link SecurityManager#checkPropertyAccess} is NOT checked
|
||||
* in this method. The caller of this method should take care to ensure
|
||||
* that the returned property is not made accessible to untrusted code.</strong>
|
||||
*
|
||||
* @return the {@code user.dir} system property
|
||||
*/
|
||||
public static String userDir() {
|
||||
return USER_DIR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@code user.name} system property.
|
||||
* {@return the {@code user.name} system property}
|
||||
*
|
||||
* <strong>{@link SecurityManager#checkPropertyAccess} is NOT checked
|
||||
* in this method. The caller of this method should take care to ensure
|
||||
* that the returned property is not made accessible to untrusted code.</strong>
|
||||
*
|
||||
* @return the {@code user.name} system property
|
||||
*/
|
||||
public static String userName() {
|
||||
return USER_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@code java.library.path} system property.
|
||||
* {@return the {@code java.library.path} system property}
|
||||
*
|
||||
* <strong>{@link SecurityManager#checkPropertyAccess} is NOT checked
|
||||
* in this method. The caller of this method should take care to ensure
|
||||
* that the returned property is not made accessible to untrusted code.</strong>
|
||||
*
|
||||
* @return the {@code java.library.path} system property
|
||||
*/
|
||||
public static String javaLibraryPath() {
|
||||
return JAVA_LIBRARY_PATH;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@code java.io.tmpdir} system property.
|
||||
* {@return the {@code java.io.tmpdir} system property}
|
||||
*
|
||||
* <strong>{@link SecurityManager#checkPropertyAccess} is NOT checked
|
||||
* in this method. The caller of this method should take care to ensure
|
||||
* that the returned property is not made accessible to untrusted code.</strong>
|
||||
*
|
||||
* @return the {@code java.io.tmpdir} system property
|
||||
*/
|
||||
public static String javaIoTmpDir() {
|
||||
return JAVA_IO_TMPDIR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@code sun.boot.library.path} system property.
|
||||
* {@return the {@code sun.boot.library.path} system property}
|
||||
*
|
||||
* <strong>{@link SecurityManager#checkPropertyAccess} is NOT checked
|
||||
* in this method. The caller of this method should take care to ensure
|
||||
* that the returned property is not made accessible to untrusted code.</strong>
|
||||
*
|
||||
* @return the {@code sun.boot.library.path} system property
|
||||
*/
|
||||
public static String sunBootLibraryPath() {
|
||||
return SUN_BOOT_LIBRARY_PATH;
|
||||
@ -178,13 +169,11 @@ public final class StaticProperty {
|
||||
|
||||
|
||||
/**
|
||||
* Return the {@code jdk.serialFilter} system property.
|
||||
* {@return the {@code jdk.serialFilter} system property}
|
||||
*
|
||||
* <strong>{@link SecurityManager#checkPropertyAccess} is NOT checked
|
||||
* in this method. The caller of this method should take care to ensure
|
||||
* that the returned property is not made accessible to untrusted code.</strong>
|
||||
*
|
||||
* @return the {@code jdk.serialFilter} system property
|
||||
*/
|
||||
public static String jdkSerialFilter() {
|
||||
return JDK_SERIAL_FILTER;
|
||||
@ -192,53 +181,66 @@ public final class StaticProperty {
|
||||
|
||||
|
||||
/**
|
||||
* Return the {@code jdk.serialFilterFactory} system property.
|
||||
* {@return the {@code jdk.serialFilterFactory} system property}
|
||||
*
|
||||
* <strong>{@link SecurityManager#checkPropertyAccess} is NOT checked
|
||||
* in this method. The caller of this method should take care to ensure
|
||||
* that the returned property is not made accessible to untrusted code.</strong>
|
||||
*
|
||||
* @return the {@code jdk.serialFilterFactory} system property
|
||||
*/
|
||||
public static String jdkSerialFilterFactory() {
|
||||
return JDK_SERIAL_FILTER_FACTORY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@code native.encoding} system property.
|
||||
* {@return the {@code native.encoding} system property}
|
||||
*
|
||||
* <strong>{@link SecurityManager#checkPropertyAccess} is NOT checked
|
||||
* in this method. The caller of this method should take care to ensure
|
||||
* that the returned property is not made accessible to untrusted code.</strong>
|
||||
*
|
||||
* @return the {@code native.encoding} system property
|
||||
*/
|
||||
public static String nativeEncoding() {
|
||||
return NATIVE_ENCODING;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@code file.encoding} system property.
|
||||
* {@return the {@code file.encoding} system property}
|
||||
*
|
||||
* <strong>{@link SecurityManager#checkPropertyAccess} is NOT checked
|
||||
* in this method. The caller of this method should take care to ensure
|
||||
* that the returned property is not made accessible to untrusted code.</strong>
|
||||
*
|
||||
* @return the {@code file.encoding} system property
|
||||
*/
|
||||
public static String fileEncoding() {
|
||||
return FILE_ENCODING;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@code java.properties.date} system property.
|
||||
* {@return the {@code java.properties.date} system property}
|
||||
*
|
||||
* <strong>{@link SecurityManager#checkPropertyAccess} is NOT checked
|
||||
* in this method.</strong>
|
||||
*
|
||||
* @return the {@code java.properties.date} system property
|
||||
*/
|
||||
public static String javaPropertiesDate() {
|
||||
return JAVA_PROPERTIES_DATE;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return the {@code sun.jnu.encoding} system property}
|
||||
*
|
||||
* <strong>{@link SecurityManager#checkPropertyAccess} is NOT checked
|
||||
* in this method. The caller of this method should take care to ensure
|
||||
* that the returned property is not made accessible to untrusted code.</strong>
|
||||
*/
|
||||
public static String jnuEncoding() {
|
||||
return SUN_JNU_ENCODING;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return {@code Charset} for {@code sun.jnu.encoding} system property}
|
||||
*
|
||||
* <strong>If {@code sun.jnu.encoding} system property has invalid
|
||||
* encoding name, {@link Charset#defaultCharset()} is returned.</strong>
|
||||
*/
|
||||
public static Charset jnuCharset() {
|
||||
return jnuCharset;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -55,7 +55,9 @@
|
||||
package java.lang;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.*;
|
||||
import jdk.internal.util.StaticProperty;
|
||||
|
||||
|
||||
final class ProcessEnvironment
|
||||
@ -163,7 +165,7 @@ final class ProcessEnvironment
|
||||
}
|
||||
|
||||
public static Variable valueOfQueryOnly(String str) {
|
||||
return new Variable(str, str.getBytes());
|
||||
return new Variable(str, str.getBytes(StaticProperty.jnuCharset()));
|
||||
}
|
||||
|
||||
public static Variable valueOf(String str) {
|
||||
@ -172,7 +174,7 @@ final class ProcessEnvironment
|
||||
}
|
||||
|
||||
public static Variable valueOf(byte[] bytes) {
|
||||
return new Variable(new String(bytes), bytes);
|
||||
return new Variable(new String(bytes, StaticProperty.jnuCharset()), bytes);
|
||||
}
|
||||
|
||||
public int compareTo(Variable variable) {
|
||||
@ -196,7 +198,7 @@ final class ProcessEnvironment
|
||||
}
|
||||
|
||||
public static Value valueOfQueryOnly(String str) {
|
||||
return new Value(str, str.getBytes());
|
||||
return new Value(str, str.getBytes(StaticProperty.jnuCharset()));
|
||||
}
|
||||
|
||||
public static Value valueOf(String str) {
|
||||
@ -205,7 +207,7 @@ final class ProcessEnvironment
|
||||
}
|
||||
|
||||
public static Value valueOf(byte[] bytes) {
|
||||
return new Value(new String(bytes), bytes);
|
||||
return new Value(new String(bytes, StaticProperty.jnuCharset()), bytes);
|
||||
}
|
||||
|
||||
public int compareTo(Value value) {
|
||||
|
||||
@ -35,6 +35,7 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Locale;
|
||||
@ -147,7 +148,7 @@ final class ProcessImpl extends Process {
|
||||
private static byte[] toCString(String s) {
|
||||
if (s == null)
|
||||
return null;
|
||||
byte[] bytes = s.getBytes();
|
||||
byte[] bytes = s.getBytes(StaticProperty.jnuCharset());
|
||||
byte[] result = new byte[bytes.length + 1];
|
||||
System.arraycopy(bytes, 0,
|
||||
result, 0,
|
||||
@ -171,7 +172,7 @@ final class ProcessImpl extends Process {
|
||||
byte[][] args = new byte[cmdarray.length-1][];
|
||||
int size = args.length; // For added NUL bytes
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
args[i] = cmdarray[i+1].getBytes();
|
||||
args[i] = cmdarray[i+1].getBytes(StaticProperty.jnuCharset());
|
||||
size += args[i].length;
|
||||
}
|
||||
byte[] argBlock = new byte[size];
|
||||
|
||||
@ -50,20 +50,28 @@ Java_sun_nio_ch_DatagramChannelImpl_disconnect0(JNIEnv *env, jclass clazz,
|
||||
jint fd = fdval(env, fdo);
|
||||
int rv;
|
||||
|
||||
#if defined(__APPLE__)
|
||||
// On macOS systems we use disconnectx
|
||||
rv = disconnectx(fd, SAE_ASSOCID_ANY, SAE_CONNID_ANY);
|
||||
#else
|
||||
SOCKETADDRESS sa;
|
||||
memset(&sa, 0, sizeof(sa));
|
||||
#if defined(_ALLBSD_SOURCE)
|
||||
sa.sa.sa_family = isIPv6 ? AF_INET6 : AF_INET;
|
||||
#else
|
||||
sa.sa.sa_family = AF_UNSPEC;
|
||||
#endif
|
||||
socklen_t len = isIPv6 ? sizeof(struct sockaddr_in6) :
|
||||
sizeof(struct sockaddr_in);
|
||||
|
||||
memset(&sa, 0, sizeof(sa));
|
||||
#if defined(_ALLBSD_SOURCE)
|
||||
sa.sa.sa_family = isIPv6 ? AF_INET6 : AF_INET;
|
||||
#else
|
||||
sa.sa.sa_family = AF_UNSPEC;
|
||||
rv = connect(fd, &sa.sa, len);
|
||||
#endif
|
||||
|
||||
rv = connect(fd, &sa.sa, len);
|
||||
|
||||
#if defined(_ALLBSD_SOURCE)
|
||||
#if defined(_ALLBSD_SOURCE) && !defined(__APPLE__)
|
||||
// On _ALLBSD_SOURCE except __APPLE__ we consider EADDRNOTAVAIL
|
||||
// error to be OK and ignore it. __APPLE__ systems are excluded
|
||||
// in this check since for __APPLE__ systems, unlike other BSD systems,
|
||||
// we issue a "disconnectx" call (a few lines above),
|
||||
// which isn't expected to return this error code.
|
||||
if (rv < 0 && errno == EADDRNOTAVAIL)
|
||||
rv = errno = 0;
|
||||
#elif defined(_AIX)
|
||||
|
||||
@ -755,6 +755,14 @@ public class LambdaToMethod extends TreeTranslator {
|
||||
String functionalInterfaceClass = classSig(targetType);
|
||||
String functionalInterfaceMethodName = samSym.getSimpleName().toString();
|
||||
String functionalInterfaceMethodSignature = typeSig(types.erasure(samSym.type));
|
||||
Symbol baseMethod = refSym.baseSymbol();
|
||||
Symbol origMethod = baseMethod.baseSymbol();
|
||||
if (baseMethod != origMethod && origMethod.owner == syms.objectType.tsym) {
|
||||
//the implementation method is a java.lang.Object method transferred to an
|
||||
//interface that does not declare it. Runtime will refer to this method as to
|
||||
//a java.lang.Object method, so do the same:
|
||||
refSym = ((MethodSymbol) origMethod).asHandle();
|
||||
}
|
||||
String implClass = classSig(types.erasure(refSym.owner.type));
|
||||
String implMethodName = refSym.getQualifiedName().toString();
|
||||
String implMethodSignature = typeSig(types.erasure(refSym.type));
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -63,6 +63,7 @@ import java.util.ServiceLoader;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.zip.ZipException;
|
||||
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.tools.FileObject;
|
||||
@ -560,7 +561,11 @@ public class JavacFileManager extends BaseFileManager implements StandardJavaFil
|
||||
Map<String,String> env = Collections.singletonMap("multi-release", multiReleaseValue);
|
||||
FileSystemProvider jarFSProvider = fsInfo.getJarFSProvider();
|
||||
Assert.checkNonNull(jarFSProvider, "should have been caught before!");
|
||||
this.fileSystem = jarFSProvider.newFileSystem(archivePath, env);
|
||||
try {
|
||||
this.fileSystem = jarFSProvider.newFileSystem(archivePath, env);
|
||||
} catch (ZipException ze) {
|
||||
throw new IOException("ZipException opening \"" + archivePath.getFileName() + "\": " + ze.getMessage(), ze);
|
||||
}
|
||||
} else {
|
||||
this.fileSystem = FileSystems.newFileSystem(archivePath, (ClassLoader)null);
|
||||
}
|
||||
|
||||
@ -1575,9 +1575,9 @@ class ZipFileSystem extends FileSystem {
|
||||
throw new ZipException("invalid CEN header (bad header size)");
|
||||
}
|
||||
IndexNode inode = new IndexNode(cen, pos, nlen);
|
||||
if (hasDotOrDotDot(inode.name)) {
|
||||
if (inode.pathHasDotOrDotDot()) {
|
||||
throw new ZipException("ZIP file can't be opened as a file system " +
|
||||
"because an entry has a '.' or '..' element in its name");
|
||||
"because entry \"" + inode.nameAsString() + "\" has a '.' or '..' element in its name");
|
||||
}
|
||||
inodes.put(inode, inode);
|
||||
if (zc.isUTF8() || (flag & FLAG_USE_UTF8) != 0) {
|
||||
@ -1595,44 +1595,6 @@ class ZipFileSystem extends FileSystem {
|
||||
return cen;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Inode.name to see if it includes a "." or ".." in the name array
|
||||
* @param path the path as stored in Inode.name to verify
|
||||
* @return true if the path contains a "." or ".." entry; false otherwise
|
||||
*/
|
||||
private boolean hasDotOrDotDot(byte[] path) {
|
||||
// Inode.name always includes "/" in path[0]
|
||||
assert path[0] == '/';
|
||||
if (path.length == 1) {
|
||||
return false;
|
||||
}
|
||||
int index = 1;
|
||||
while (index < path.length) {
|
||||
int starting = index;
|
||||
while (index < path.length && path[index] != '/') {
|
||||
index++;
|
||||
}
|
||||
// Check the path snippet for a "." or ".."
|
||||
if (isDotOrDotDotPath(path, starting, index)) {
|
||||
return true;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the path to see if it includes a "." or ".."
|
||||
* @param path the path to check
|
||||
* @return true if the path contains a "." or ".." entry; false otherwise
|
||||
*/
|
||||
private boolean isDotOrDotDotPath(byte[] path, int start, int index) {
|
||||
int pathLen = index - start;
|
||||
if ((pathLen == 1 && path[start] == '.'))
|
||||
return true;
|
||||
return (pathLen == 2 && path[start] == '.') && path[start + 1] == '.';
|
||||
}
|
||||
|
||||
private final void checkUTF8(byte[] a) throws ZipException {
|
||||
try {
|
||||
int end = a.length;
|
||||
@ -2653,6 +2615,37 @@ class ZipFileSystem extends FileSystem {
|
||||
return isdir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check name if it contains a "." or ".." path element
|
||||
* @return true if the path contains a "." or ".." entry; false otherwise
|
||||
*/
|
||||
private boolean pathHasDotOrDotDot() {
|
||||
// name always includes "/" in path[0]
|
||||
assert name[0] == '/';
|
||||
if (name.length == 1) {
|
||||
return false;
|
||||
}
|
||||
int index = 1;
|
||||
while (index < name.length) {
|
||||
int start = index;
|
||||
while (index < name.length && name[index] != '/') {
|
||||
index++;
|
||||
}
|
||||
if (name[start] == '.') {
|
||||
int len = index - start;
|
||||
if (len == 1 || (name[start + 1] == '.' && len == 2)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
index++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected String nameAsString() {
|
||||
return new String(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (!(other instanceof IndexNode)) {
|
||||
@ -2671,7 +2664,7 @@ class ZipFileSystem extends FileSystem {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new String(name) + (isdir ? " (dir)" : " ") + ", index: " + pos;
|
||||
return nameAsString() + (isdir ? " (dir)" : " ") + ", index: " + pos;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3207,7 +3200,7 @@ class ZipFileSystem extends FileSystem {
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder(1024);
|
||||
Formatter fm = new Formatter(sb);
|
||||
fm.format(" name : %s%n", new String(name));
|
||||
fm.format(" name : %s%n", nameAsString());
|
||||
fm.format(" creationTime : %tc%n", creationTime().toMillis());
|
||||
fm.format(" lastAccessTime : %tc%n", lastAccessTime().toMillis());
|
||||
fm.format(" lastModifiedTime: %tc%n", lastModifiedTime().toMillis());
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
* 5026830 5023243 5070673 4052517 4811767 6192449 6397034 6413313
|
||||
* 6464154 6523983 6206031 4960438 6631352 6631966 6850957 6850958
|
||||
* 4947220 7018606 7034570 4244896 5049299 8003488 8054494 8058464
|
||||
* 8067796 8224905 8263729 8265173 8272600 8231297 8282219
|
||||
* 8067796 8224905 8263729 8265173 8272600 8231297 8282219 8285517
|
||||
* @key intermittent
|
||||
* @summary Basic tests for Process and Environment Variable code
|
||||
* @modules java.base/java.lang:open
|
||||
@ -50,6 +50,7 @@ import java.lang.ProcessHandle;
|
||||
import static java.lang.ProcessBuilder.Redirect.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
@ -598,7 +599,11 @@ public class Basic {
|
||||
try {
|
||||
// If round trip conversion works, should be able to set env vars
|
||||
// correctly in child.
|
||||
if (new String(tested.getBytes()).equals(tested)) {
|
||||
String jnuEncoding = System.getProperty("sun.jnu.encoding");
|
||||
Charset cs = jnuEncoding != null
|
||||
? Charset.forName(jnuEncoding, Charset.defaultCharset())
|
||||
: Charset.defaultCharset();
|
||||
if (new String(tested.getBytes(cs), cs).equals(tested)) {
|
||||
out.println("Testing " + encoding + " environment values");
|
||||
ProcessBuilder pb = new ProcessBuilder();
|
||||
pb.environment().put("ASCIINAME",tested);
|
||||
|
||||
183
test/jdk/java/lang/System/i18nEnvArg.java
Normal file
183
test/jdk/java/lang/System/i18nEnvArg.java
Normal file
@ -0,0 +1,183 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8285517
|
||||
* @summary System.getenv() and argument don't return locale dependent data by JEP400
|
||||
* @requires (os.family == "linux")
|
||||
* @modules jdk.charsets
|
||||
* @library /test/lib
|
||||
* @build jdk.test.lib.process.*
|
||||
* @run main i18nEnvArg
|
||||
*/
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Arrays;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HexFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
|
||||
public class i18nEnvArg {
|
||||
final static String EUC_JP_TEXT = "\u6F22\u5B57";
|
||||
|
||||
/*
|
||||
* Checks OS is Linux and OS has ja_JP.eucjp locale or not.
|
||||
* Sets EUC_JP's environment variable and argunments against ProcessBuilder
|
||||
*/
|
||||
public static void main(String[] args) throws Exception {
|
||||
ProcessBuilder pb;
|
||||
List<String> cmds = new ArrayList<>();
|
||||
cmds.addAll(List.of(
|
||||
"--add-modules=" + System.getProperty("test.modules"),
|
||||
"-classpath",
|
||||
System.getProperty("test.class.path"),
|
||||
"-Dtest.class.path=" + System.getProperty("test.class.path"),
|
||||
"-Dtest.modules=" + System.getProperty("test.modules")));
|
||||
if (args.length == 0) {
|
||||
cmds.addAll(
|
||||
List.of("-Dtest.jdk=" + System.getProperty("test.jdk"),
|
||||
"i18nEnvArg",
|
||||
"Start"));
|
||||
} else {
|
||||
String jnuEncoding = System.getProperty("sun.jnu.encoding");
|
||||
Charset dcs = jnuEncoding != null
|
||||
? Charset.forName(jnuEncoding)
|
||||
: Charset.defaultCharset();
|
||||
Charset cs = Charset.forName("x-euc-jp-linux");
|
||||
if (!dcs.equals(cs)) {
|
||||
return;
|
||||
}
|
||||
cmds.addAll(
|
||||
List.of("--add-opens=java.base/java.lang=ALL-UNNAMED",
|
||||
"i18nEnvArg$Verify",
|
||||
EUC_JP_TEXT));
|
||||
}
|
||||
pb = ProcessTools.createTestJvm(cmds);
|
||||
Map<String, String> environ = pb.environment();
|
||||
environ.clear();
|
||||
environ.put("LANG", "ja_JP.eucjp");
|
||||
if (args.length != 0) {
|
||||
environ.put(EUC_JP_TEXT, EUC_JP_TEXT);
|
||||
}
|
||||
ProcessTools.executeProcess(pb)
|
||||
.outputTo(System.out)
|
||||
.errorTo(System.err)
|
||||
.shouldHaveExitValue(0);
|
||||
}
|
||||
|
||||
public static class Verify {
|
||||
|
||||
private static String toReadable(String s) {
|
||||
if (s == null)
|
||||
return "null";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(char ch : s.toCharArray()) {
|
||||
sb.append(String.format("\\u%04X", (int)ch));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/*
|
||||
* Verify environment variable and argument are encoded by Linux's
|
||||
* eucjp or not
|
||||
*/
|
||||
public static void main(String[] args) throws Exception {
|
||||
Charset cs = Charset.forName("x-euc-jp-linux");
|
||||
byte[] euc = EUC_JP_TEXT.getBytes(cs);
|
||||
try ( ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
PrintStream ps = new PrintStream(baos); ) {
|
||||
if (!EUC_JP_TEXT.equals(args[0])) {
|
||||
ps.println("argument EUC_JP_TEXT is:");
|
||||
ps.println(" Actual: " + toReadable(args[0]));
|
||||
ps.println(" Expected: " + toReadable(EUC_JP_TEXT));
|
||||
}
|
||||
String s = System.getenv(EUC_JP_TEXT);
|
||||
if (!EUC_JP_TEXT.equals(s)) {
|
||||
ps.println("getenv(\"EUC_JP_TEXT\") is:");
|
||||
ps.println(" Actual: " + toReadable(s));
|
||||
ps.println(" Expected: " + toReadable(EUC_JP_TEXT));
|
||||
} else {
|
||||
try {
|
||||
Class<?> ProcessEnvironment_cls =
|
||||
Class.forName("java.lang.ProcessEnvironment");
|
||||
Field theEnvironment_fid =
|
||||
ProcessEnvironment_cls.getDeclaredField("theEnvironment");
|
||||
theEnvironment_fid.setAccessible(true);
|
||||
HashMap theEnvironment =
|
||||
(HashMap) theEnvironment_fid.get(null);
|
||||
Class<?> ExternalData_cls =
|
||||
Class.forName("java.lang.ProcessEnvironment$ExternalData");
|
||||
Method getBytes_mid =
|
||||
ExternalData_cls.getDeclaredMethod("getBytes");
|
||||
getBytes_mid.setAccessible(true);
|
||||
HexFormat hf = HexFormat.of()
|
||||
.withUpperCase()
|
||||
.withPrefix("\\x");
|
||||
for (Object k : theEnvironment.keySet()) {
|
||||
if (EUC_JP_TEXT.equals(k.toString())) {
|
||||
byte[] ba = (byte[]) getBytes_mid.invoke(k,
|
||||
(Object[])null);
|
||||
if (!Arrays.equals(euc, ba)) {
|
||||
ps.println(
|
||||
"Variable EUC_JP_TEXT is encoded by:");
|
||||
ps.println(" Actual: "
|
||||
+ hf.formatHex(ba));
|
||||
ps.println(" Expected: "
|
||||
+ hf.formatHex(euc));
|
||||
}
|
||||
ba = (byte[]) getBytes_mid.invoke(
|
||||
theEnvironment.get(k),
|
||||
(Object[])null);
|
||||
if (!Arrays.equals(euc, ba)) {
|
||||
ps.println(
|
||||
"Value EUC_JP_TEXT is encoded by:");
|
||||
ps.println(" Actual: "
|
||||
+ hf.formatHex(ba));
|
||||
ps.println(" Expected: "
|
||||
+ hf.formatHex(euc));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ps.println(
|
||||
"Check ProcessEnvironment class implementation");
|
||||
e.printStackTrace(ps);
|
||||
}
|
||||
}
|
||||
byte[] ba = baos.toByteArray();
|
||||
if (ba.length > 0) {
|
||||
System.err.write(ba);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -22,7 +22,7 @@
|
||||
*/
|
||||
|
||||
/* @test
|
||||
* @bug 7132924
|
||||
* @bug 7132924 8285515
|
||||
* @library /test/lib
|
||||
* @key intermittent
|
||||
* @summary Test DatagramChannel.disconnect when DatagramChannel is connected to an IPv4 socket
|
||||
|
||||
@ -51,7 +51,6 @@ public class HashesOrderTest {
|
||||
new RuntimeException("jmod tool not found")
|
||||
);
|
||||
|
||||
private String DATE = "2021-01-06T14:36:00+02:00";
|
||||
private int NUM_MODULES = 64;
|
||||
private Path mods;
|
||||
private Path lib1;
|
||||
@ -113,7 +112,6 @@ public class HashesOrderTest {
|
||||
List<String> args = new ArrayList<>();
|
||||
args.add("create");
|
||||
Collections.addAll(args, options);
|
||||
Collections.addAll(args, "--date", DATE);
|
||||
Collections.addAll(args, "--class-path", mclasses.toString(),
|
||||
outfile.toString());
|
||||
|
||||
|
||||
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8282080
|
||||
* @summary Check that serializable lambdas referring to j.l.Object methods work.
|
||||
* @compile SerializableObjectMethods.java
|
||||
* @run main SerializableObjectMethods
|
||||
*/
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
|
||||
public class SerializableObjectMethods {
|
||||
|
||||
interface I1 extends Serializable {}
|
||||
|
||||
interface I2 extends I1 {
|
||||
|
||||
@Override
|
||||
public int hashCode();
|
||||
|
||||
}
|
||||
|
||||
interface F<T, R> extends Serializable {
|
||||
|
||||
R apply(T t);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
new SerializableObjectMethods().run();
|
||||
}
|
||||
|
||||
void run() throws IOException, ClassNotFoundException {
|
||||
saveLoad((F<I1, Integer>) I1::hashCode).apply(new I1() {});
|
||||
saveLoad((F<I2, Integer>) I2::hashCode).apply(new I2() {});
|
||||
}
|
||||
|
||||
<T, R> F<T, R> saveLoad(F<T, R> value) throws IOException, ClassNotFoundException {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
try ( ObjectOutputStream oos = new ObjectOutputStream(out)) {
|
||||
oos.writeObject(value);
|
||||
}
|
||||
try (ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(out.toByteArray()))) {
|
||||
return (F<T, R>) ois.readObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user