diff --git a/src/hotspot/share/classfile/classListParser.cpp b/src/hotspot/share/classfile/classListParser.cpp index b123a1fd959..5a7766f0ce6 100644 --- a/src/hotspot/share/classfile/classListParser.cpp +++ b/src/hotspot/share/classfile/classListParser.cpp @@ -467,6 +467,10 @@ void ClassListParser::resolve_indy(Symbol* class_name_symbol, TRAPS) { Klass* klass = SystemDictionary::resolve_or_fail(class_name_symbol, class_loader, protection_domain, true, THREAD); // FIXME should really be just a lookup if (klass != NULL && klass->is_instance_klass()) { InstanceKlass* ik = InstanceKlass::cast(klass); + if (SystemDictionaryShared::has_class_failed_verification(ik)) { + // don't attempt to resolve indy on classes that has previously failed verification + return; + } MetaspaceShared::try_link_class(ik, THREAD); assert(!HAS_PENDING_EXCEPTION, "unexpected exception"); diff --git a/src/hotspot/share/classfile/vmSymbols.hpp b/src/hotspot/share/classfile/vmSymbols.hpp index 4623dbb2c64..d7baa8cdb1d 100644 --- a/src/hotspot/share/classfile/vmSymbols.hpp +++ b/src/hotspot/share/classfile/vmSymbols.hpp @@ -353,6 +353,7 @@ /* Panama Support */ \ template(jdk_internal_invoke_NativeEntryPoint, "jdk/internal/invoke/NativeEntryPoint") \ template(jdk_internal_invoke_NativeEntryPoint_signature, "Ljdk/internal/invoke/NativeEntryPoint;") \ + template(jdk_incubator_foreign_MemoryAccess, "jdk/incubator/foreign/MemoryAccess") \ \ /* Support for JVMCI */ \ JVMCI_VM_SYMBOLS_DO(template, do_alias) \ diff --git a/src/hotspot/share/code/nmethod.cpp b/src/hotspot/share/code/nmethod.cpp index 2971733e883..351a1bb7e2b 100644 --- a/src/hotspot/share/code/nmethod.cpp +++ b/src/hotspot/share/code/nmethod.cpp @@ -1270,7 +1270,6 @@ void nmethod::make_unloaded() { JVMCINMethodData* nmethod_data = jvmci_nmethod_data(); if (nmethod_data != NULL) { nmethod_data->invalidate_nmethod_mirror(this); - nmethod_data->clear_nmethod_mirror(this); } #endif } diff --git a/src/hotspot/share/jfr/support/jfrAllocationTracer.cpp b/src/hotspot/share/jfr/support/jfrAllocationTracer.cpp index 5f62f3e3740..ddf22be2748 100644 --- a/src/hotspot/share/jfr/support/jfrAllocationTracer.cpp +++ b/src/hotspot/share/jfr/support/jfrAllocationTracer.cpp @@ -30,11 +30,12 @@ #include "runtime/thread.hpp" JfrAllocationTracer::JfrAllocationTracer(const Klass* klass, HeapWord* obj, size_t alloc_size, bool outside_tlab, Thread* thread) : _tl(NULL) { - JfrObjectAllocationSample::send_event(klass, alloc_size, outside_tlab, thread); if (LeakProfiler::is_running()) { _tl = thread->jfr_thread_local(); LeakProfiler::sample(obj, alloc_size, thread->as_Java_thread()); } + // Let this happen after LeakProfiler::sample, to possibly reuse a cached stacktrace. + JfrObjectAllocationSample::send_event(klass, alloc_size, outside_tlab, thread); } JfrAllocationTracer::~JfrAllocationTracer() { diff --git a/src/hotspot/share/jvmci/jvmciRuntime.cpp b/src/hotspot/share/jvmci/jvmciRuntime.cpp index e8f0ba69898..a8d9c52ff0f 100644 --- a/src/hotspot/share/jvmci/jvmciRuntime.cpp +++ b/src/hotspot/share/jvmci/jvmciRuntime.cpp @@ -714,6 +714,12 @@ void JVMCINMethodData::invalidate_nmethod_mirror(nmethod* nm) { HotSpotJVMCI::InstalledCode::set_entryPoint(jvmciEnv, nmethod_mirror, 0); } } + + if (_nmethod_mirror_index != -1 && nm->is_unloaded()) { + // Drop the reference to the nmethod mirror object but don't clear the actual oop reference. Otherwise + // it would appear that the nmethod didn't need to be unloaded in the first place. + _nmethod_mirror_index = -1; + } } JVMCIRuntime::JVMCIRuntime(int id) { diff --git a/src/hotspot/share/oops/methodData.cpp b/src/hotspot/share/oops/methodData.cpp index fb314986d76..5b724166514 100644 --- a/src/hotspot/share/oops/methodData.cpp +++ b/src/hotspot/share/oops/methodData.cpp @@ -1601,6 +1601,18 @@ bool MethodData::profile_unsafe(const methodHandle& m, int bci) { return false; } +bool MethodData::profile_memory_access(const methodHandle& m, int bci) { + Bytecode_invoke inv(m , bci); + if (inv.is_invokestatic()) { + if (inv.klass() == vmSymbols::jdk_incubator_foreign_MemoryAccess()) { + if (inv.name()->starts_with("get") || inv.name()->starts_with("set")) { + return true; + } + } + } + return false; +} + int MethodData::profile_arguments_flag() { return TypeProfileLevel % 10; } @@ -1630,6 +1642,10 @@ bool MethodData::profile_arguments_for_invoke(const methodHandle& m, int bci) { return true; } + if (profile_memory_access(m, bci)) { + return true; + } + assert(profile_arguments_jsr292_only(), "inconsistent"); return profile_jsr292(m, bci); } diff --git a/src/hotspot/share/oops/methodData.hpp b/src/hotspot/share/oops/methodData.hpp index 83c7bd6fd6d..464e783b2a4 100644 --- a/src/hotspot/share/oops/methodData.hpp +++ b/src/hotspot/share/oops/methodData.hpp @@ -2148,6 +2148,7 @@ private: static bool profile_jsr292(const methodHandle& m, int bci); static bool profile_unsafe(const methodHandle& m, int bci); + static bool profile_memory_access(const methodHandle& m, int bci); static int profile_arguments_flag(); static bool profile_all_arguments(); static bool profile_arguments_for_invoke(const methodHandle& m, int bci); diff --git a/src/hotspot/share/opto/loopnode.hpp b/src/hotspot/share/opto/loopnode.hpp index aa89d475ef8..5eb5efaaa60 100644 --- a/src/hotspot/share/opto/loopnode.hpp +++ b/src/hotspot/share/opto/loopnode.hpp @@ -1451,6 +1451,7 @@ public: // Mark an IfNode as being dominated by a prior test, // without actually altering the CFG (and hence IDOM info). void dominated_by( Node *prevdom, Node *iff, bool flip = false, bool exclude_loop_predicate = false ); + bool no_dependent_zero_check(Node* n) const; // Split Node 'n' through merge point Node *split_thru_region( Node *n, Node *region ); diff --git a/src/hotspot/share/opto/loopopts.cpp b/src/hotspot/share/opto/loopopts.cpp index 52e56fad024..8c160c058cf 100644 --- a/src/hotspot/share/opto/loopopts.cpp +++ b/src/hotspot/share/opto/loopopts.cpp @@ -278,18 +278,23 @@ void PhaseIdealLoop::dominated_by( Node *prevdom, Node *iff, bool flip, bool exc return; // Let IGVN transformation change control dependence. } - IdealLoopTree *old_loop = get_loop(dp); + IdealLoopTree* old_loop = get_loop(dp); for (DUIterator_Fast imax, i = dp->fast_outs(imax); i < imax; i++) { Node* cd = dp->fast_out(i); // Control-dependent node - if (cd->depends_only_on_test()) { + // Do not rewire Div and Mod nodes which could have a zero divisor to avoid skipping their zero check. + if (cd->depends_only_on_test() && no_dependent_zero_check(cd)) { assert(cd->in(0) == dp, ""); _igvn.replace_input_of(cd, 0, prevdom); set_early_ctrl(cd, false); - IdealLoopTree *new_loop = get_loop(get_ctrl(cd)); + IdealLoopTree* new_loop = get_loop(get_ctrl(cd)); if (old_loop != new_loop) { - if (!old_loop->_child) old_loop->_body.yank(cd); - if (!new_loop->_child) new_loop->_body.push(cd); + if (!old_loop->_child) { + old_loop->_body.yank(cd); + } + if (!new_loop->_child) { + new_loop->_body.push(cd); + } } --i; --imax; @@ -297,6 +302,25 @@ void PhaseIdealLoop::dominated_by( Node *prevdom, Node *iff, bool flip, bool exc } } +// Check if the type of a divisor of a Div or Mod node includes zero. +bool PhaseIdealLoop::no_dependent_zero_check(Node* n) const { + switch (n->Opcode()) { + case Op_DivI: + case Op_ModI: { + // Type of divisor includes 0? + const TypeInt* type_divisor = _igvn.type(n->in(2))->is_int(); + return (type_divisor->_hi < 0 || type_divisor->_lo > 0); + } + case Op_DivL: + case Op_ModL: { + // Type of divisor includes 0? + const TypeLong* type_divisor = _igvn.type(n->in(2))->is_long(); + return (type_divisor->_hi < 0 || type_divisor->_lo > 0); + } + } + return true; +} + //------------------------------has_local_phi_input---------------------------- // Return TRUE if 'n' has Phi inputs from its local block and no other // block-local inputs (all non-local-phi inputs come from earlier blocks) diff --git a/src/java.base/share/classes/com/sun/crypto/provider/RSACipher.java b/src/java.base/share/classes/com/sun/crypto/provider/RSACipher.java index 64a94d7d0e7..1fdcd81accd 100644 --- a/src/java.base/share/classes/com/sun/crypto/provider/RSACipher.java +++ b/src/java.base/share/classes/com/sun/crypto/provider/RSACipher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -25,6 +25,7 @@ package com.sun.crypto.provider; +import java.util.Arrays; import java.util.Locale; import java.security.*; @@ -347,28 +348,40 @@ public final class RSACipher extends CipherSpi { throw new IllegalBlockSizeException("Data must not be longer " + "than " + buffer.length + " bytes"); } + byte[] paddingCopy = null; + byte[] result = null; try { - byte[] data; switch (mode) { case MODE_SIGN: - data = padding.pad(buffer, 0, bufOfs); - return RSACore.rsa(data, privateKey, true); + paddingCopy = padding.pad(buffer, 0, bufOfs); + result = RSACore.rsa(paddingCopy, privateKey, true); + break; case MODE_VERIFY: byte[] verifyBuffer = RSACore.convert(buffer, 0, bufOfs); - data = RSACore.rsa(verifyBuffer, publicKey); - return padding.unpad(data); + paddingCopy = RSACore.rsa(verifyBuffer, publicKey); + result = padding.unpad(paddingCopy); + break; case MODE_ENCRYPT: - data = padding.pad(buffer, 0, bufOfs); - return RSACore.rsa(data, publicKey); + paddingCopy = padding.pad(buffer, 0, bufOfs); + result = RSACore.rsa(paddingCopy, publicKey); + break; case MODE_DECRYPT: byte[] decryptBuffer = RSACore.convert(buffer, 0, bufOfs); - data = RSACore.rsa(decryptBuffer, privateKey, false); - return padding.unpad(data); + paddingCopy = RSACore.rsa(decryptBuffer, privateKey, false); + result = padding.unpad(paddingCopy); + break; default: throw new AssertionError("Internal error"); } + return result; } finally { + Arrays.fill(buffer, 0, bufOfs, (byte)0); bufOfs = 0; + if (paddingCopy != null // will not happen + && paddingCopy != buffer // already cleaned + && paddingCopy != result) { // DO NOT CLEAN, THIS IS RESULT! + Arrays.fill(paddingCopy, (byte)0); + } } } @@ -404,6 +417,7 @@ public final class RSACipher extends CipherSpi { byte[] result = doFinal(); int n = result.length; System.arraycopy(result, 0, out, outOfs, n); + Arrays.fill(result, (byte)0); return n; } @@ -414,15 +428,19 @@ public final class RSACipher extends CipherSpi { if ((encoded == null) || (encoded.length == 0)) { throw new InvalidKeyException("Could not obtain encoded key"); } - if (encoded.length > buffer.length) { - throw new InvalidKeyException("Key is too long for wrapping"); - } - update(encoded, 0, encoded.length); try { - return doFinal(); - } catch (BadPaddingException e) { - // should not occur - throw new InvalidKeyException("Wrapping failed", e); + if (encoded.length > buffer.length) { + throw new InvalidKeyException("Key is too long for wrapping"); + } + update(encoded, 0, encoded.length); + try { + return doFinal(); + } catch (BadPaddingException e) { + // should not occur + throw new InvalidKeyException("Wrapping failed", e); + } + } finally { + Arrays.fill(encoded, (byte)0); } } @@ -453,20 +471,26 @@ public final class RSACipher extends CipherSpi { throw new InvalidKeyException("Unwrapping failed", e); } - if (isTlsRsaPremasterSecret) { - if (!(spec instanceof TlsRsaPremasterSecretParameterSpec)) { - throw new IllegalStateException( - "No TlsRsaPremasterSecretParameterSpec specified"); + try { + if (isTlsRsaPremasterSecret) { + if (!(spec instanceof TlsRsaPremasterSecretParameterSpec)) { + throw new IllegalStateException( + "No TlsRsaPremasterSecretParameterSpec specified"); + } + + // polish the TLS premaster secret + encoded = KeyUtil.checkTlsPreMasterSecretKey( + ((TlsRsaPremasterSecretParameterSpec) spec).getClientVersion(), + ((TlsRsaPremasterSecretParameterSpec) spec).getServerVersion(), + random, encoded, (failover != null)); } - // polish the TLS premaster secret - encoded = KeyUtil.checkTlsPreMasterSecretKey( - ((TlsRsaPremasterSecretParameterSpec)spec).getClientVersion(), - ((TlsRsaPremasterSecretParameterSpec)spec).getServerVersion(), - random, encoded, (failover != null)); + return ConstructKeys.constructKey(encoded, algorithm, type); + } finally { + if (encoded != null) { + Arrays.fill(encoded, (byte) 0); + } } - - return ConstructKeys.constructKey(encoded, algorithm, type); } // see JCE spec diff --git a/src/java.base/share/classes/java/lang/Enum.java b/src/java.base/share/classes/java/lang/Enum.java index cc9b3c20b00..54a1f09c9eb 100644 --- a/src/java.base/share/classes/java/lang/Enum.java +++ b/src/java.base/share/classes/java/lang/Enum.java @@ -66,7 +66,7 @@ import static java.util.Objects.requireNonNull; * @see Class#getEnumConstants() * @see java.util.EnumSet * @see java.util.EnumMap - * @jls 8.9 Enum Types + * @jls 8.9 Enum Classes * @jls 8.9.3 Enum Members * @since 1.5 */ diff --git a/src/java.base/share/classes/java/lang/annotation/Annotation.java b/src/java.base/share/classes/java/lang/annotation/Annotation.java index cd1ed787ceb..07549913831 100644 --- a/src/java.base/share/classes/java/lang/annotation/Annotation.java +++ b/src/java.base/share/classes/java/lang/annotation/Annotation.java @@ -26,16 +26,16 @@ package java.lang.annotation; /** - * The common interface extended by all annotation types. Note that an + * The common interface extended by all annotation interfaces. Note that an * interface that manually extends this one does not define - * an annotation type. Also note that this interface does not itself - * define an annotation type. + * an annotation interface. Also note that this interface does not itself + * define an annotation interface. * - * More information about annotation types can be found in section {@jls 9.6} of - * The Java Language Specification. + * More information about annotation interfaces can be found in section + * {@jls 9.6} of The Java Language Specification. * * The {@link java.lang.reflect.AnnotatedElement} interface discusses - * compatibility concerns when evolving an annotation type from being + * compatibility concerns when evolving an annotation interface from being * non-repeatable to being repeatable. * * @author Josh Bloch @@ -46,7 +46,7 @@ public interface Annotation { * Returns true if the specified object represents an annotation * that is logically equivalent to this one. In other words, * returns true if the specified object is an instance of the same - * annotation type as this instance, all of whose members are equal + * annotation interface as this instance, all of whose members are equal * to the corresponding member of this annotation, as defined below: *
For example, an annotation whose type is meta-annotated with + *
For example, an annotation whose interface is meta-annotated with * {@code @Target(ElementType.FIELD)} may only be written as a modifier for a * field declaration. * *
The constant {@link #TYPE_USE} corresponds to the type contexts in JLS - * 4.11, as well as to two declaration contexts: type declarations (including - * annotation type declarations) and type parameter declarations. + * 4.11, as well as to two declaration contexts: class and interface + * declarations (including annotation declarations) and type parameter + * declarations. * - *
For example, an annotation whose type is meta-annotated with - * {@code @Target(ElementType.TYPE_USE)} may be written on the type of a field - * (or within the type of the field, if it is a nested, parameterized, or array - * type), and may also appear as a modifier for, say, a class declaration. + *
For example, an annotation whose interface is meta-annotated with + * {@code @Target(ElementType.TYPE_USE)} may be written on the class or + * interface of a field (or within the class or interface of the field, if it + * is a nested or parameterized class or interface, or array class), and may + * also appear as a modifier for, say, a class declaration. * - *
The {@code TYPE_USE} constant includes type declarations and type - * parameter declarations as a convenience for designers of type checkers which - * give semantics to annotation types. For example, if the annotation type - * {@code NonNull} is meta-annotated with + *
The {@code TYPE_USE} constant includes class and interface declarations + * and type parameter declarations as a convenience for designers of + * type checkers which give semantics to annotation interfaces. For example, + * if the annotation interface {@code NonNull} is meta-annotated with * {@code @Target(ElementType.TYPE_USE)}, then {@code @NonNull} * {@code class C {...}} could be treated by a type checker as indicating that * all variables of class {@code C} are non-null, while still allowing @@ -71,7 +73,7 @@ package java.lang.annotation; * @jls 4.1 The Kinds of Types and Values */ public enum ElementType { - /** Class, interface (including annotation type), enum, or record + /** Class, interface (including annotation interface), enum, or record * declaration */ TYPE, @@ -90,7 +92,7 @@ public enum ElementType { /** Local variable declaration */ LOCAL_VARIABLE, - /** Annotation type declaration */ + /** Annotation interface declaration (Formerly known as an annotation type.) */ ANNOTATION_TYPE, /** Package declaration */ diff --git a/src/java.base/share/classes/java/lang/annotation/IncompleteAnnotationException.java b/src/java.base/share/classes/java/lang/annotation/IncompleteAnnotationException.java index c143fd5585e..921d4b92fcd 100644 --- a/src/java.base/share/classes/java/lang/annotation/IncompleteAnnotationException.java +++ b/src/java.base/share/classes/java/lang/annotation/IncompleteAnnotationException.java @@ -27,8 +27,8 @@ package java.lang.annotation; /** * Thrown to indicate that a program has attempted to access an element of - * an annotation type that was added to the annotation type definition after - * the annotation was compiled (or serialized). This exception will not be + * an annotation interface that was added to the annotation interface definition + * after the annotation was compiled (or serialized). This exception will not be * thrown if the new element has a default value. * This exception can be thrown by the {@linkplain * java.lang.reflect.AnnotatedElement API used to read annotations @@ -43,7 +43,7 @@ public class IncompleteAnnotationException extends RuntimeException { private static final long serialVersionUID = 8445097402741811912L; /** - * The annotation type. + * The annotation interface. */ private Class extends Annotation> annotationType; /** @@ -53,9 +53,9 @@ public class IncompleteAnnotationException extends RuntimeException { /** * Constructs an IncompleteAnnotationException to indicate that - * the named element was missing from the specified annotation type. + * the named element was missing from the specified annotation interface. * - * @param annotationType the Class object for the annotation type + * @param annotationType the Class object for the annotation interface * @param elementName the name of the missing element * @throws NullPointerException if either parameter is {@code null} */ @@ -70,10 +70,10 @@ public class IncompleteAnnotationException extends RuntimeException { } /** - * Returns the Class object for the annotation type with the + * Returns the Class object for the annotation interface with the * missing element. * - * @return the Class object for the annotation type with the + * @return the Class object for the annotation interface with the * missing element */ public Class extends Annotation> annotationType() { diff --git a/src/java.base/share/classes/java/lang/annotation/Inherited.java b/src/java.base/share/classes/java/lang/annotation/Inherited.java index 9b4080c05d6..3cfc07d6bff 100644 --- a/src/java.base/share/classes/java/lang/annotation/Inherited.java +++ b/src/java.base/share/classes/java/lang/annotation/Inherited.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -26,18 +26,18 @@ package java.lang.annotation; /** - * Indicates that an annotation type is automatically inherited. If - * an Inherited meta-annotation is present on an annotation type - * declaration, and the user queries the annotation type on a class - * declaration, and the class declaration has no annotation for this type, + * Indicates that an annotation interface is automatically inherited. If + * an Inherited meta-annotation is present on an annotation interface + * declaration, and the user queries the annotation interface on a class + * declaration, and the class declaration has no annotation for this interface, * then the class's superclass will automatically be queried for the - * annotation type. This process will be repeated until an annotation for this - * type is found, or the top of the class hierarchy (Object) - * is reached. If no superclass has an annotation for this type, then + * annotation interface. This process will be repeated until an annotation for + * this interface is found, or the top of the class hierarchy (Object) + * is reached. If no superclass has an annotation for this interface, then * the query will indicate that the class in question has no such annotation. * - *
Note that this meta-annotation type has no effect if the annotated - * type is used to annotate anything other than a class. Note also + *
Note that this meta-annotation interface has no effect if the annotated + * interface is used to annotate anything other than a class. Note also * that this meta-annotation only causes annotations to be inherited * from superclasses; annotations on implemented interfaces have no * effect. diff --git a/src/java.base/share/classes/java/lang/annotation/Repeatable.java b/src/java.base/share/classes/java/lang/annotation/Repeatable.java index f9dc170ec73..d8c58d8592a 100644 --- a/src/java.base/share/classes/java/lang/annotation/Repeatable.java +++ b/src/java.base/share/classes/java/lang/annotation/Repeatable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -26,24 +26,24 @@ package java.lang.annotation; /** - * The annotation type {@code java.lang.annotation.Repeatable} is - * used to indicate that the annotation type whose declaration it + * The annotation interface {@code java.lang.annotation.Repeatable} is + * used to indicate that the annotation interface whose declaration it * (meta-)annotates is repeatable. The value of * {@code @Repeatable} indicates the containing annotation - * type for the repeatable annotation type. + * interface for the repeatable annotation interface. * * @since 1.8 - * @jls 9.6.3 Repeatable Annotation Types - * @jls 9.7.5 Multiple Annotations of the Same Type + * @jls 9.6.3 Repeatable Annotation Interfaces + * @jls 9.7.5 Multiple Annotations of the Same Interface */ @Documented @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.ANNOTATION_TYPE) public @interface Repeatable { /** - * Indicates the containing annotation type for the - * repeatable annotation type. - * @return the containing annotation type + * Indicates the containing annotation interface for the + * repeatable annotation interface. + * @return the containing annotation interface */ Class extends Annotation> value(); } diff --git a/src/java.base/share/classes/java/lang/annotation/Retention.java b/src/java.base/share/classes/java/lang/annotation/Retention.java index 6c2a6045c49..daf5f6e9b23 100644 --- a/src/java.base/share/classes/java/lang/annotation/Retention.java +++ b/src/java.base/share/classes/java/lang/annotation/Retention.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -26,15 +26,15 @@ package java.lang.annotation; /** - * Indicates how long annotations with the annotated type are to + * Indicates how long annotations with the annotated interface are to * be retained. If no Retention annotation is present on - * an annotation type declaration, the retention policy defaults to + * an annotation interface declaration, the retention policy defaults to * {@code RetentionPolicy.CLASS}. * *
A Retention meta-annotation has effect only if the - * meta-annotated type is used directly for annotation. It has no - * effect if the meta-annotated type is used as a member type in - * another annotation type. + * meta-annotated interface is used directly for annotation. It has no + * effect if the meta-annotated interface is used as a member interface in + * another annotation interface. * * @author Joshua Bloch * @since 1.5 diff --git a/src/java.base/share/classes/java/lang/annotation/RetentionPolicy.java b/src/java.base/share/classes/java/lang/annotation/RetentionPolicy.java index 82aa198805e..6ec9eb672cf 100644 --- a/src/java.base/share/classes/java/lang/annotation/RetentionPolicy.java +++ b/src/java.base/share/classes/java/lang/annotation/RetentionPolicy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -26,10 +26,10 @@ package java.lang.annotation; /** - * Annotation retention policy. The constants of this enumerated type + * Annotation retention policy. The constants of this enumerated class * describe the various policies for retaining annotations. They are used - * in conjunction with the {@link Retention} meta-annotation type to specify - * how long annotations are to be retained. + * in conjunction with the {@link Retention} meta-annotation interface to + * specify how long annotations are to be retained. * * @author Joshua Bloch * @since 1.5 diff --git a/src/java.base/share/classes/java/lang/annotation/Target.java b/src/java.base/share/classes/java/lang/annotation/Target.java index ea9547d9817..0fe49022005 100644 --- a/src/java.base/share/classes/java/lang/annotation/Target.java +++ b/src/java.base/share/classes/java/lang/annotation/Target.java @@ -26,22 +26,22 @@ package java.lang.annotation; /** - * Indicates the contexts in which an annotation type is applicable. The - * declaration contexts and type contexts in which an annotation type may be - * applicable are specified in JLS 9.6.4.1, and denoted in source code by enum - * constants of {@link ElementType java.lang.annotation.ElementType}. + * Indicates the contexts in which an annotation interface is applicable. The + * declaration contexts and type contexts in which an annotation interface may + * be applicable are specified in JLS 9.6.4.1, and denoted in source code by + * enum constants of {@link ElementType java.lang.annotation.ElementType}. * - *
If an {@code @Target} meta-annotation is not present on an annotation type - * {@code T}, then an annotation of type {@code T} may be written as a - * modifier for any declaration except a type parameter declaration. + *
If an {@code @Target} meta-annotation is not present on an annotation + * interface {@code T}, then an annotation of type {@code T} may be written as + * a modifier for any declaration except a type parameter declaration. * *
If an {@code @Target} meta-annotation is present, the compiler will enforce * the usage restrictions indicated by {@code ElementType} * enum constants, in line with JLS 9.7.4. * *
For example, this {@code @Target} meta-annotation indicates that the - * declared type is itself a meta-annotation type. It can only be used on - * annotation type declarations: + * declared interface is itself a meta-annotation interface. It can only be + * used on annotation interface declarations: *
* @Target(ElementType.ANNOTATION_TYPE)
* public @interface MetaAnnotationType {
@@ -49,12 +49,13 @@ package java.lang.annotation;
* }
*
*
- * This {@code @Target} meta-annotation indicates that the declared type is - * intended solely for use as a member type in complex annotation type - * declarations. It cannot be used to annotate anything directly: + *
This {@code @Target} meta-annotation indicates that the declared class or + * interface is intended solely for use as a member class or interface in + * complex annotation interface declarations. It cannot be used to annotate + * anything directly: *
* @Target({})
- * public @interface MemberType {
+ * public @interface MemberInterface {
* ...
* }
*
@@ -72,16 +73,16 @@ package java.lang.annotation;
* @since 1.5
* @jls 9.6.4.1 @Target
* @jls 9.7.4 Where Annotations May Appear
- * @jls 9.7.5 Multiple Annotations of the Same Type
+ * @jls 9.7.5 Multiple Annotations of the Same Interface
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.ANNOTATION_TYPE)
public @interface Target {
/**
- * Returns an array of the kinds of elements an annotation type
+ * Returns an array of the kinds of elements an annotation interface
* can be applied to.
- * @return an array of the kinds of elements an annotation type
+ * @return an array of the kinds of elements an annotation interface
* can be applied to
*/
ElementType[] value();
diff --git a/src/java.base/share/classes/java/lang/reflect/Method.java b/src/java.base/share/classes/java/lang/reflect/Method.java
index 557948381a6..567ae8be660 100644
--- a/src/java.base/share/classes/java/lang/reflect/Method.java
+++ b/src/java.base/share/classes/java/lang/reflect/Method.java
@@ -405,7 +405,7 @@ public final class Method extends Executable {
*
* @jls 8.4.3 Method Modifiers
* @jls 9.4 Method Declarations
- * @jls 9.6.1 Annotation Type Elements
+ * @jls 9.6.1 Annotation Interface Elements
*/
public String toString() {
return sharedToString(Modifier.methodModifiers(),
@@ -475,7 +475,7 @@ public final class Method extends Executable {
*
* @jls 8.4.3 Method Modifiers
* @jls 9.4 Method Declarations
- * @jls 9.6.1 Annotation Type Elements
+ * @jls 9.6.1 Annotation Interface Elements
*/
@Override
public String toGenericString() {
diff --git a/src/java.base/share/classes/jdk/internal/access/foreign/MemorySegmentProxy.java b/src/java.base/share/classes/jdk/internal/access/foreign/MemorySegmentProxy.java
index e45ad08f8fe..a00b6516a55 100644
--- a/src/java.base/share/classes/jdk/internal/access/foreign/MemorySegmentProxy.java
+++ b/src/java.base/share/classes/jdk/internal/access/foreign/MemorySegmentProxy.java
@@ -29,21 +29,21 @@ package jdk.internal.access.foreign;
import jdk.internal.misc.ScopedMemoryAccess;
/**
- * This proxy interface is required to allow instances of the {@code MemorySegment} interface (which is defined inside
+ * This abstract class is required to allow implementations of the {@code MemorySegment} interface (which is defined inside
* an incubating module) to be accessed from the memory access var handles.
*/
-public interface MemorySegmentProxy {
+public abstract class MemorySegmentProxy {
/**
* Check that memory access is within spatial bounds and that access is compatible with segment access modes.
* @throws UnsupportedOperationException if underlying segment has incompatible access modes (e.g. attempting to write
* a read-only segment).
* @throws IndexOutOfBoundsException if access is out-of-bounds.
*/
- void checkAccess(long offset, long length, boolean readOnly);
- long unsafeGetOffset();
- Object unsafeGetBase();
- boolean isSmall();
- ScopedMemoryAccess.Scope scope();
+ public abstract void checkAccess(long offset, long length, boolean readOnly);
+ public abstract long unsafeGetOffset();
+ public abstract Object unsafeGetBase();
+ public abstract boolean isSmall();
+ public abstract ScopedMemoryAccess.Scope scope();
/* Helper functions for offset computations. These are required so that we can avoid issuing long opcodes
* (e.g. LMUL, LADD) when we're operating on 'small' segments (segments whose length can be expressed with an int).
@@ -51,7 +51,7 @@ public interface MemorySegmentProxy {
* BCE when working with small segments. This workaround should be dropped when JDK-8223051 is resolved.
*/
- static long addOffsets(long op1, long op2, MemorySegmentProxy segmentProxy) {
+ public static long addOffsets(long op1, long op2, MemorySegmentProxy segmentProxy) {
if (segmentProxy.isSmall()) {
// force ints for BCE
if (op1 > Integer.MAX_VALUE || op2 > Integer.MAX_VALUE
@@ -74,7 +74,7 @@ public interface MemorySegmentProxy {
}
}
- static long multiplyOffsets(long op1, long op2, MemorySegmentProxy segmentProxy) {
+ public static long multiplyOffsets(long op1, long op2, MemorySegmentProxy segmentProxy) {
if (segmentProxy.isSmall()) {
if (op1 > Integer.MAX_VALUE || op2 > Integer.MAX_VALUE
|| op1 < Integer.MIN_VALUE || op2 < Integer.MIN_VALUE) {
diff --git a/src/java.base/share/classes/jdk/internal/misc/X-ScopedMemoryAccess.java.template b/src/java.base/share/classes/jdk/internal/misc/X-ScopedMemoryAccess.java.template
index 2bf948d33d6..7e6823718ae 100644
--- a/src/java.base/share/classes/jdk/internal/misc/X-ScopedMemoryAccess.java.template
+++ b/src/java.base/share/classes/jdk/internal/misc/X-ScopedMemoryAccess.java.template
@@ -325,3 +325,6 @@ public class ScopedMemoryAccess {
}
// typed-ops here
+ // Note: all the accessor methods defined below take advantage of argument type profiling
+ // (see src/hotspot/share/oops/methodData.cpp) which greatly enhances performance when the same accessor
+ // method is used repeatedly with different 'base' objects.
diff --git a/src/java.base/share/classes/sun/security/rsa/RSACore.java b/src/java.base/share/classes/sun/security/rsa/RSACore.java
index abf717fc8c2..33534c87da4 100644
--- a/src/java.base/share/classes/sun/security/rsa/RSACore.java
+++ b/src/java.base/share/classes/sun/security/rsa/RSACore.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -231,12 +231,14 @@ public final class RSACore {
if ((n == len + 1) && (b[0] == 0)) {
byte[] t = new byte[len];
System.arraycopy(b, 1, t, 0, len);
+ Arrays.fill(b, (byte)0);
return t;
}
// must be smaller
assert (n < len);
byte[] t = new byte[len];
System.arraycopy(b, 0, t, (len - n), n);
+ Arrays.fill(b, (byte)0);
return t;
}
diff --git a/src/java.base/share/classes/sun/security/rsa/RSAPadding.java b/src/java.base/share/classes/sun/security/rsa/RSAPadding.java
index fe054d50314..c54dbdb8d43 100644
--- a/src/java.base/share/classes/sun/security/rsa/RSAPadding.java
+++ b/src/java.base/share/classes/sun/security/rsa/RSAPadding.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -238,41 +238,33 @@ public final class RSAPadding {
/**
* Pad the data and return the padded block.
*/
- public byte[] pad(byte[] data, int ofs, int len)
- throws BadPaddingException {
- return pad(RSACore.convert(data, ofs, len));
+ public byte[] pad(byte[] data) throws BadPaddingException {
+ return pad(data, 0, data.length);
}
/**
* Pad the data and return the padded block.
*/
- public byte[] pad(byte[] data) throws BadPaddingException {
- if (data.length > maxDataSize) {
+ public byte[] pad(byte[] data, int ofs, int len)
+ throws BadPaddingException {
+ if (len > maxDataSize) {
throw new BadPaddingException("Data must be shorter than "
+ (maxDataSize + 1) + " bytes but received "
- + data.length + " bytes.");
+ + len + " bytes.");
}
switch (type) {
case PAD_NONE:
- return data;
+ return RSACore.convert(data, ofs, len);
case PAD_BLOCKTYPE_1:
case PAD_BLOCKTYPE_2:
- return padV15(data);
+ return padV15(data, ofs, len);
case PAD_OAEP_MGF1:
- return padOAEP(data);
+ return padOAEP(data, ofs, len);
default:
throw new AssertionError();
}
}
- /**
- * Unpad the padded block and return the data.
- */
- public byte[] unpad(byte[] padded, int ofs, int len)
- throws BadPaddingException {
- return unpad(RSACore.convert(padded, ofs, len));
- }
-
/**
* Unpad the padded block and return the data.
*/
@@ -298,11 +290,10 @@ public final class RSAPadding {
/**
* PKCS#1 v1.5 padding (blocktype 1 and 2).
*/
- private byte[] padV15(byte[] data) throws BadPaddingException {
+ private byte[] padV15(byte[] data, int ofs, int len) throws BadPaddingException {
byte[] padded = new byte[paddedSize];
- System.arraycopy(data, 0, padded, paddedSize - data.length,
- data.length);
- int psSize = paddedSize - 3 - data.length;
+ System.arraycopy(data, ofs, padded, paddedSize - len, len);
+ int psSize = paddedSize - 3 - len;
int k = 0;
padded[k++] = 0;
padded[k++] = (byte)type;
@@ -388,7 +379,7 @@ public final class RSAPadding {
* PKCS#1 v2.0 OAEP padding (MGF1).
* Paragraph references refer to PKCS#1 v2.1 (June 14, 2002)
*/
- private byte[] padOAEP(byte[] M) throws BadPaddingException {
+ private byte[] padOAEP(byte[] M, int ofs, int len) throws BadPaddingException {
if (random == null) {
random = JCAUtil.getSecureRandom();
}
@@ -415,7 +406,7 @@ public final class RSAPadding {
int dbLen = EM.length - dbStart;
// start of message M in EM
- int mStart = paddedSize - M.length;
+ int mStart = paddedSize - len;
// build DB
// 2.b: Concatenate lHash, PS, a single octet with hexadecimal value
@@ -424,7 +415,7 @@ public final class RSAPadding {
// (note that PS is all zeros)
System.arraycopy(lHash, 0, EM, dbStart, hLen);
EM[mStart - 1] = 1;
- System.arraycopy(M, 0, EM, mStart, M.length);
+ System.arraycopy(M, ofs, EM, mStart, len);
// produce maskedDB
mgf.generateAndXor(EM, seedStart, seedLen, dbLen, EM, dbStart);
diff --git a/src/java.compiler/share/classes/javax/tools/ToolProvider.java b/src/java.compiler/share/classes/javax/tools/ToolProvider.java
index 74b4f45b3fd..ad7c749b018 100644
--- a/src/java.compiler/share/classes/javax/tools/ToolProvider.java
+++ b/src/java.compiler/share/classes/javax/tools/ToolProvider.java
@@ -27,7 +27,7 @@ package javax.tools;
import java.security.AccessController;
import java.security.PrivilegedAction;
-import java.util.Iterator;
+import java.util.Objects;
import java.util.ServiceConfigurationError;
import java.util.ServiceLoader;
@@ -118,8 +118,7 @@ public class ToolProvider {
try {
ServiceLoader