This commit is contained in:
Henry Jen 2020-01-09 20:16:21 +00:00
commit 231d9afe6f
68 changed files with 1586 additions and 598 deletions

View file

@ -181,9 +181,9 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence {
}
/**
* Returns the current capacity. The capacity is the amount of storage
* available for newly inserted characters, beyond which an allocation
* will occur.
* Returns the current capacity. The capacity is the number of characters
* that can be stored (including already written characters), beyond which
* an allocation will occur.
*
* @return the current capacity
*/

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -90,10 +90,15 @@ package java.lang;
@jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.RECORDS,
essentialAPI=true)
public abstract class Record {
/**
* Constructor for record classes to call.
*/
protected Record() {}
/**
* Indicates whether some other object is "equal to" this one. In addition
* to the general contract of {@link Object#equals(Object)},
* record classes must further participate in the invariant that when
* to the general contract of {@link Object#equals(Object) Object.equals},
* record classes must further obey the invariant that when
* a record instance is "copied" by passing the result of the record component
* accessor methods to the canonical constructor, as follows:
* <pre>
@ -102,17 +107,38 @@ public abstract class Record {
* then it must be the case that {@code r.equals(copy)}.
*
* @implSpec
* The implicitly provided implementation returns {@code true} if and
* only if the argument is an instance of the same record type as this object,
* and each component of this record is equal to the corresponding component
* of the argument, according to {@link java.util.Objects#equals(Object,Object)}
* for components whose types are reference types, and according to the semantics
* of the {@code equals} method on the corresponding primitive wrapper type.
* The implicitly provided implementation returns {@code true} if
* and only if the argument is an instance of the same record type
* as this object, and each component of this record is equal to
* the corresponding component of the argument; otherwise, {@code
* false} is returned. Equality of a component {@code c} is
* determined as follows:
* <ul>
*
* <li> If the component is of a reference type, the component is
* considered equal if and only if {@link
* java.util.Objects#equals(Object,Object)
* Objects.equals(this.c(), r.c()} would return {@code true}.
*
* <li> If the component is of a primitive type, using the
* corresponding primitive wrapper class {@code PW} (the
* corresponding wrapper class for {@code int} is {@code
* java.lang.Integer}, and so on), the component is considered
* equal if and only if {@code
* PW.valueOf(this.c()).equals(PW.valueOf(r.c()))} would return
* {@code true}.
*
* </ul>
*
* The implicitly provided implementation conforms to the
* semantics described above; the implementation may or may not
* accomplish this by using calls to the particular methods
* listed.
*
* @see java.util.Objects#equals(Object,Object)
*
* @param obj the reference object with which to compare.
* @return {@code true} if this object is the same as the obj
* @return {@code true} if this object is equal to the
* argument; {@code false} otherwise.
*/
@Override

View file

@ -239,6 +239,9 @@ public class AlgorithmId implements Serializable, DerEncoder {
* return a name such as "MD5withRSA" for a signature algorithm on
* some systems. It also returns names like "OID.1.2.3.4", when
* no particular name for the algorithm is known.
*
* Note: for ecdsa-with-SHA2 plus hash algorithm (Ex: SHA-256), this method
* returns the "full" signature algorithm (Ex: SHA256withECDSA) directly.
*/
public String getName() {
String algName = nameTable.get(algid);
@ -248,7 +251,7 @@ public class AlgorithmId implements Serializable, DerEncoder {
if ((params != null) && algid.equals((Object)specifiedWithECDSA_oid)) {
try {
AlgorithmId paramsId =
AlgorithmId.parse(new DerValue(getEncodedParams()));
AlgorithmId.parse(new DerValue(params.toByteArray()));
String paramsName = paramsId.getName();
algName = makeSigAlg(paramsName, "EC");
} catch (IOException e) {
@ -264,12 +267,18 @@ public class AlgorithmId implements Serializable, DerEncoder {
/**
* Returns the DER encoded parameter, which can then be
* used to initialize java.security.AlgorithmParamters.
* used to initialize java.security.AlgorithmParameters.
*
* Note: for ecdsa-with-SHA2 plus hash algorithm (Ex: SHA-256), this method
* returns null because {@link #getName()} has already returned the "full"
* signature algorithm (Ex: SHA256withECDSA).
*
* @return DER encoded parameters, or null not present.
*/
public byte[] getEncodedParams() throws IOException {
return (params == null) ? null : params.toByteArray();
return (params == null || algid.equals(specifiedWithECDSA_oid))
? null
: params.toByteArray();
}
/**

View file

@ -324,6 +324,7 @@ int getAllInterfacesAndAddresses (JNIEnv *env, netif **netifPP)
goto err;
}
loopif->naddrs += c;
loopif->ipv6Index = ptr->Ipv6IfIndex;
} else {
int index = ptr->IfIndex;
if (index != 0) {

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -1455,7 +1455,7 @@ static void setMulticastInterface(JNIEnv *env, jobject this, int fd, int fd1,
* address is bound to and use the IPV6_MULTICAST_IF
* option instead of IP_MULTICAST_IF
*/
if (ipv6_supported) {
if (ipv6_supported && fd1 >= 0) {
static jclass ni_class = NULL;
if (ni_class == NULL) {
jclass c = (*env)->FindClass(env, "java/net/NetworkInterface");
@ -1496,7 +1496,7 @@ static void setMulticastInterface(JNIEnv *env, jobject this, int fd, int fd1,
* On IPv4 system extract addr[0] and use the IP_MULTICAST_IF
* option. For IPv6 both must be done.
*/
if (ipv6_supported) {
if (ipv6_supported && fd1 >= 0) {
static jfieldID ni_indexID = NULL;
struct in_addr in;
int index;
@ -1508,7 +1508,6 @@ static void setMulticastInterface(JNIEnv *env, jobject this, int fd, int fd1,
CHECK_NULL(ni_indexID);
}
index = (*env)->GetIntField(env, value, ni_indexID);
if (isAdapterIpv6Enabled(env, index) != 0) {
if (setsockopt(fd1, IPPROTO_IPV6, IPV6_MULTICAST_IF,
(const char*)&index, sizeof(index)) < 0) {
@ -1523,16 +1522,18 @@ static void setMulticastInterface(JNIEnv *env, jobject this, int fd, int fd1,
return;
}
}
/* If there are any IPv4 addresses on this interface then
* repeat the operation on the IPv4 fd */
if (fd >= 0) {
/* If there are any IPv4 addresses on this interface then
* repeat the operation on the IPv4 fd */
if (getInet4AddrFromIf(env, value, &in) < 0) {
return;
}
if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
(const char*)&in, sizeof(in)) < 0) {
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
if (getInet4AddrFromIf(env, value, &in) < 0) {
return;
}
if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
(const char*)&in, sizeof(in)) < 0) {
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
}
}
return;
} else {
@ -1877,7 +1878,7 @@ jobject getMulticastInterface(JNIEnv *env, jobject this, int fd, int fd1, jint o
addr = (*env)->GetObjectArrayElement(env, addrArray, 0);
return addr;
} else if (index == 0) { // index == 0 typically means IPv6 not configured on the interfaces
} else if (index == 0 && fd >= 0) {
// falling back to treat interface as configured for IPv4
jobject netObject = NULL;
netObject = getIPv4NetworkInterface(env, this, fd, opt, 0);