This commit is contained in:
Jesper Wilhelmsson 2020-12-17 20:41:37 +00:00
commit f15528eb64
63 changed files with 649 additions and 324 deletions

View file

@ -74,7 +74,7 @@ define SetupInterimModule
EXCLUDE_FILES := $(TOPDIR)/src/$1/share/classes/module-info.java \ EXCLUDE_FILES := $(TOPDIR)/src/$1/share/classes/module-info.java \
Standard.java, \ Standard.java, \
EXTRA_FILES := $(BUILDTOOLS_OUTPUTDIR)/gensrc/$1.interim/module-info.java, \ EXTRA_FILES := $(BUILDTOOLS_OUTPUTDIR)/gensrc/$1.interim/module-info.java, \
COPY := .gif .png .xml .css .js .txt javax.tools.JavaCompilerTool, \ COPY := .gif .png .xml .css .js .js.template .txt javax.tools.JavaCompilerTool, \
BIN := $(BUILDTOOLS_OUTPUTDIR)/interim_langtools_modules/$1.interim, \ BIN := $(BUILDTOOLS_OUTPUTDIR)/interim_langtools_modules/$1.interim, \
DISABLED_WARNINGS := module options, \ DISABLED_WARNINGS := module options, \
JAVAC_FLAGS := \ JAVAC_FLAGS := \

View file

@ -339,7 +339,7 @@ jdk.dynalink_CLEAN += .properties
################################################################################ ################################################################################
jdk.javadoc_COPY += .xml .css .js .png .txt jdk.javadoc_COPY += .xml .css .js .js.template .png .txt
################################################################################ ################################################################################

View file

@ -35,6 +35,7 @@
#include "logging/log.hpp" #include "logging/log.hpp"
#include "oops/oop.inline.hpp" #include "oops/oop.inline.hpp"
#include "runtime/java.hpp" #include "runtime/java.hpp"
#include "runtime/orderAccess.hpp"
#include "utilities/align.hpp" #include "utilities/align.hpp"
PSOldGen::PSOldGen(ReservedSpace rs, size_t initial_size, size_t min_size, PSOldGen::PSOldGen(ReservedSpace rs, size_t initial_size, size_t min_size,
@ -380,7 +381,9 @@ void PSOldGen::post_resize() {
WorkGang* workers = Thread::current()->is_VM_thread() ? WorkGang* workers = Thread::current()->is_VM_thread() ?
&ParallelScavengeHeap::heap()->workers() : NULL; &ParallelScavengeHeap::heap()->workers() : NULL;
// ALWAYS do this last!! // Ensure the space bounds are updated and made visible to other
// threads after the other data structures have been resized.
OrderAccess::storestore();
object_space()->initialize(new_memregion, object_space()->initialize(new_memregion,
SpaceDecorator::DontClear, SpaceDecorator::DontClear,
SpaceDecorator::DontMangle, SpaceDecorator::DontMangle,

View file

@ -160,10 +160,6 @@ NO_TRANSITION(jboolean, jfr_is_available(JNIEnv* env, jclass jvm))
return !Jfr::is_disabled() ? JNI_TRUE : JNI_FALSE; return !Jfr::is_disabled() ? JNI_TRUE : JNI_FALSE;
NO_TRANSITION_END NO_TRANSITION_END
NO_TRANSITION(jlong, jfr_get_epoch_address(JNIEnv* env, jobject jvm))
return JfrTraceIdEpoch::epoch_address();
NO_TRANSITION_END
NO_TRANSITION(jlong, jfr_get_unloaded_event_classes_count(JNIEnv* env, jobject jvm)) NO_TRANSITION(jlong, jfr_get_unloaded_event_classes_count(JNIEnv* env, jobject jvm))
return JfrKlassUnloading::event_class_count(); return JfrKlassUnloading::event_class_count();
NO_TRANSITION_END NO_TRANSITION_END
@ -327,8 +323,8 @@ JVM_ENTRY_NO_ENV(jlong, jfr_type_id(JNIEnv* env, jobject jvm, jclass jc))
return JfrTraceId::load_raw(jc); return JfrTraceId::load_raw(jc);
JVM_END JVM_END
JVM_ENTRY_NO_ENV(jboolean, jfr_add_string_constant(JNIEnv* env, jclass jvm, jboolean epoch, jlong id, jstring string)) JVM_ENTRY_NO_ENV(jboolean, jfr_add_string_constant(JNIEnv* env, jclass jvm, jlong id, jstring string))
return JfrStringPool::add(epoch == JNI_TRUE, id, string, thread) ? JNI_TRUE : JNI_FALSE; return JfrStringPool::add(id, string, thread);
JVM_END JVM_END
JVM_ENTRY_NO_ENV(void, jfr_set_force_instrumentation(JNIEnv* env, jobject jvm, jboolean force_instrumentation)) JVM_ENTRY_NO_ENV(void, jfr_set_force_instrumentation(JNIEnv* env, jobject jvm, jboolean force_instrumentation))

View file

@ -120,9 +120,7 @@ jboolean JNICALL jfr_event_writer_flush(JNIEnv* env, jclass cls, jobject writer,
void JNICALL jfr_flush(JNIEnv* env, jobject jvm); void JNICALL jfr_flush(JNIEnv* env, jobject jvm);
void JNICALL jfr_abort(JNIEnv* env, jobject jvm, jstring errorMsg); void JNICALL jfr_abort(JNIEnv* env, jobject jvm, jstring errorMsg);
jlong JNICALL jfr_get_epoch_address(JNIEnv* env, jobject jvm); jboolean JNICALL jfr_add_string_constant(JNIEnv* env, jclass jvm, jlong id, jstring string);
jboolean JNICALL jfr_add_string_constant(JNIEnv* env, jclass jvm, jboolean epoch, jlong id, jstring string);
void JNICALL jfr_uncaught_exception(JNIEnv* env, jobject jvm, jobject thread, jthrowable throwable); void JNICALL jfr_uncaught_exception(JNIEnv* env, jobject jvm, jobject thread, jthrowable throwable);

View file

@ -75,8 +75,7 @@ JfrJniMethodRegistration::JfrJniMethodRegistration(JNIEnv* env) {
(char*)"flush", (char*)"()V", (void*)jfr_flush, (char*)"flush", (char*)"()V", (void*)jfr_flush,
(char*)"setRepositoryLocation", (char*)"(Ljava/lang/String;)V", (void*)jfr_set_repository_location, (char*)"setRepositoryLocation", (char*)"(Ljava/lang/String;)V", (void*)jfr_set_repository_location,
(char*)"abort", (char*)"(Ljava/lang/String;)V", (void*)jfr_abort, (char*)"abort", (char*)"(Ljava/lang/String;)V", (void*)jfr_abort,
(char*)"getEpochAddress", (char*)"()J",(void*)jfr_get_epoch_address, (char*)"addStringConstant", (char*)"(JLjava/lang/String;)Z", (void*)jfr_add_string_constant,
(char*)"addStringConstant", (char*)"(ZJLjava/lang/String;)Z", (void*)jfr_add_string_constant,
(char*)"uncaughtException", (char*)"(Ljava/lang/Thread;Ljava/lang/Throwable;)V", (void*)jfr_uncaught_exception, (char*)"uncaughtException", (char*)"(Ljava/lang/Thread;Ljava/lang/Throwable;)V", (void*)jfr_uncaught_exception,
(char*)"setForceInstrumentation", (char*)"(Z)V", (void*)jfr_set_force_instrumentation, (char*)"setForceInstrumentation", (char*)"(Z)V", (void*)jfr_set_force_instrumentation,
(char*)"getUnloadedEventClassCount", (char*)"()J", (void*)jfr_get_unloaded_event_classes_count, (char*)"getUnloadedEventClassCount", (char*)"()J", (void*)jfr_get_unloaded_event_classes_count,

View file

@ -42,6 +42,7 @@
#include "jfr/utilities/jfrBigEndian.hpp" #include "jfr/utilities/jfrBigEndian.hpp"
#include "jfr/utilities/jfrIterator.hpp" #include "jfr/utilities/jfrIterator.hpp"
#include "jfr/utilities/jfrLinkedList.inline.hpp" #include "jfr/utilities/jfrLinkedList.inline.hpp"
#include "jfr/utilities/jfrSignal.hpp"
#include "jfr/utilities/jfrThreadIterator.hpp" #include "jfr/utilities/jfrThreadIterator.hpp"
#include "jfr/utilities/jfrTypes.hpp" #include "jfr/utilities/jfrTypes.hpp"
#include "jfr/writers/jfrJavaEventWriter.hpp" #include "jfr/writers/jfrJavaEventWriter.hpp"
@ -57,22 +58,7 @@
typedef JfrCheckpointManager::BufferPtr BufferPtr; typedef JfrCheckpointManager::BufferPtr BufferPtr;
static volatile bool constant_pending = false; static JfrSignal _new_checkpoint;
static bool is_constant_pending() {
if (Atomic::load_acquire(&constant_pending)) {
Atomic::release_store(&constant_pending, false); // reset
return true;
}
return false;
}
static void set_constant_pending() {
if (!Atomic::load_acquire(&constant_pending)) {
Atomic::release_store(&constant_pending, true);
}
}
static JfrCheckpointManager* _instance = NULL; static JfrCheckpointManager* _instance = NULL;
JfrCheckpointManager& JfrCheckpointManager::instance() { JfrCheckpointManager& JfrCheckpointManager::instance() {
@ -231,7 +217,7 @@ BufferPtr JfrCheckpointManager::flush(BufferPtr old, size_t used, size_t request
// indicates a lease is being returned // indicates a lease is being returned
release(old); release(old);
// signal completion of a new checkpoint // signal completion of a new checkpoint
set_constant_pending(); _new_checkpoint.signal();
return NULL; return NULL;
} }
BufferPtr new_buffer = lease(old, thread, used + requested); BufferPtr new_buffer = lease(old, thread, used + requested);
@ -474,7 +460,7 @@ size_t JfrCheckpointManager::flush_type_set() {
elements = ::flush_type_set(thread); elements = ::flush_type_set(thread);
} }
} }
if (is_constant_pending()) { if (_new_checkpoint.is_signaled()) {
WriteOperation wo(_chunkwriter); WriteOperation wo(_chunkwriter);
MutexedWriteOperation mwo(wo); MutexedWriteOperation mwo(wo);
_thread_local_mspace->iterate(mwo); // current epoch list _thread_local_mspace->iterate(mwo); // current epoch list

View file

@ -26,9 +26,9 @@
#include "jfr/recorder/checkpoint/types/traceid/jfrTraceIdEpoch.hpp" #include "jfr/recorder/checkpoint/types/traceid/jfrTraceIdEpoch.hpp"
#include "runtime/safepoint.hpp" #include "runtime/safepoint.hpp"
JfrSignal JfrTraceIdEpoch::_tag_state;
bool JfrTraceIdEpoch::_epoch_state = false; bool JfrTraceIdEpoch::_epoch_state = false;
bool JfrTraceIdEpoch::_synchronizing = false; bool JfrTraceIdEpoch::_synchronizing = false;
volatile bool JfrTraceIdEpoch::_changed_tag_state = false;
void JfrTraceIdEpoch::begin_epoch_shift() { void JfrTraceIdEpoch::begin_epoch_shift() {
assert(SafepointSynchronize::is_at_safepoint(), "invariant"); assert(SafepointSynchronize::is_at_safepoint(), "invariant");
@ -43,3 +43,4 @@ void JfrTraceIdEpoch::end_epoch_shift() {
OrderAccess::storestore(); OrderAccess::storestore();
_synchronizing = false; _synchronizing = false;
} }

View file

@ -25,6 +25,7 @@
#ifndef SHARE_JFR_RECORDER_CHECKPOINT_TYPES_TRACEID_JFRTRACEIDEPOCH_HPP #ifndef SHARE_JFR_RECORDER_CHECKPOINT_TYPES_TRACEID_JFRTRACEIDEPOCH_HPP
#define SHARE_JFR_RECORDER_CHECKPOINT_TYPES_TRACEID_JFRTRACEIDEPOCH_HPP #define SHARE_JFR_RECORDER_CHECKPOINT_TYPES_TRACEID_JFRTRACEIDEPOCH_HPP
#include "jfr/utilities/jfrSignal.hpp"
#include "jfr/utilities/jfrTypes.hpp" #include "jfr/utilities/jfrTypes.hpp"
#include "memory/allocation.hpp" #include "memory/allocation.hpp"
#include "runtime/atomic.hpp" #include "runtime/atomic.hpp"
@ -54,21 +55,13 @@
class JfrTraceIdEpoch : AllStatic { class JfrTraceIdEpoch : AllStatic {
friend class JfrCheckpointManager; friend class JfrCheckpointManager;
private: private:
static JfrSignal _tag_state;
static bool _epoch_state; static bool _epoch_state;
static bool _synchronizing; static bool _synchronizing;
static volatile bool _changed_tag_state;
static void begin_epoch_shift(); static void begin_epoch_shift();
static void end_epoch_shift(); static void end_epoch_shift();
static bool changed_tag_state() {
return Atomic::load_acquire(&_changed_tag_state);
}
static void set_tag_state(bool value) {
Atomic::release_store(&_changed_tag_state, value);
}
public: public:
static bool epoch() { static bool epoch() {
return _epoch_state; return _epoch_state;
@ -115,17 +108,11 @@ class JfrTraceIdEpoch : AllStatic {
} }
static bool has_changed_tag_state() { static bool has_changed_tag_state() {
if (changed_tag_state()) { return _tag_state.is_signaled();
set_tag_state(false);
return true;
}
return false;
} }
static void set_changed_tag_state() { static void set_changed_tag_state() {
if (!changed_tag_state()) { _tag_state.signal();
set_tag_state(true);
}
} }
}; };

View file

@ -314,9 +314,7 @@ static size_t write_storage(JfrStorage& storage, JfrChunkWriter& chunkwriter) {
} }
typedef Content<JfrStringPool, &JfrStringPool::write> StringPool; typedef Content<JfrStringPool, &JfrStringPool::write> StringPool;
typedef Content<JfrStringPool, &JfrStringPool::write_at_safepoint> StringPoolSafepoint;
typedef WriteCheckpointEvent<StringPool> WriteStringPool; typedef WriteCheckpointEvent<StringPool> WriteStringPool;
typedef WriteCheckpointEvent<StringPoolSafepoint> WriteStringPoolSafepoint;
static u4 flush_stringpool(JfrStringPool& string_pool, JfrChunkWriter& chunkwriter) { static u4 flush_stringpool(JfrStringPool& string_pool, JfrChunkWriter& chunkwriter) {
StringPool sp(string_pool); StringPool sp(string_pool);
@ -330,12 +328,6 @@ static u4 write_stringpool(JfrStringPool& string_pool, JfrChunkWriter& chunkwrit
return invoke(wsp); return invoke(wsp);
} }
static u4 write_stringpool_safepoint(JfrStringPool& string_pool, JfrChunkWriter& chunkwriter) {
StringPoolSafepoint sps(string_pool);
WriteStringPoolSafepoint wsps(chunkwriter, sps, TYPE_STRING);
return invoke(wsps);
}
typedef Content<JfrCheckpointManager, &JfrCheckpointManager::flush_type_set> FlushTypeSetFunctor; typedef Content<JfrCheckpointManager, &JfrCheckpointManager::flush_type_set> FlushTypeSetFunctor;
typedef WriteContent<FlushTypeSetFunctor> FlushTypeSet; typedef WriteContent<FlushTypeSetFunctor> FlushTypeSet;
@ -569,7 +561,7 @@ void JfrRecorderService::safepoint_write() {
assert(SafepointSynchronize::is_at_safepoint(), "invariant"); assert(SafepointSynchronize::is_at_safepoint(), "invariant");
_checkpoint_manager.begin_epoch_shift(); _checkpoint_manager.begin_epoch_shift();
if (_string_pool.is_modified()) { if (_string_pool.is_modified()) {
write_stringpool_safepoint(_string_pool, _chunkwriter); write_stringpool(_string_pool, _chunkwriter);
} }
_checkpoint_manager.on_rotation(); _checkpoint_manager.on_rotation();
_storage.write_at_safepoint(); _storage.write_at_safepoint();

View file

@ -32,6 +32,7 @@
#include "jfr/recorder/stringpool/jfrStringPool.hpp" #include "jfr/recorder/stringpool/jfrStringPool.hpp"
#include "jfr/recorder/stringpool/jfrStringPoolWriter.hpp" #include "jfr/recorder/stringpool/jfrStringPoolWriter.hpp"
#include "jfr/utilities/jfrLinkedList.inline.hpp" #include "jfr/utilities/jfrLinkedList.inline.hpp"
#include "jfr/utilities/jfrSignal.hpp"
#include "jfr/utilities/jfrTypes.hpp" #include "jfr/utilities/jfrTypes.hpp"
#include "logging/log.hpp" #include "logging/log.hpp"
#include "runtime/atomic.hpp" #include "runtime/atomic.hpp"
@ -40,44 +41,19 @@
typedef JfrStringPool::BufferPtr BufferPtr; typedef JfrStringPool::BufferPtr BufferPtr;
static JfrStringPool* _instance = NULL; static JfrSignal _new_string;
static uint64_t store_generation = 0;
static uint64_t serialized_generation = 0;
inline void set_generation(uint64_t value, uint64_t* const dest) {
assert(dest != NULL, "invariant");
Atomic::release_store(dest, value);
}
static void increment_store_generation() {
const uint64_t current_serialized = Atomic::load_acquire(&serialized_generation);
const uint64_t current_stored = Atomic::load_acquire(&store_generation);
if (current_serialized == current_stored) {
set_generation(current_serialized + 1, &store_generation);
}
}
static bool increment_serialized_generation() {
const uint64_t current_stored = Atomic::load_acquire(&store_generation);
const uint64_t current_serialized = Atomic::load_acquire(&serialized_generation);
if (current_stored != current_serialized) {
set_generation(current_stored, &serialized_generation);
return true;
}
return false;
}
bool JfrStringPool::is_modified() { bool JfrStringPool::is_modified() {
return increment_serialized_generation(); return _new_string.is_signaled();
} }
static JfrStringPool* _instance = NULL;
JfrStringPool& JfrStringPool::instance() { JfrStringPool& JfrStringPool::instance() {
return *_instance; return *_instance;
} }
JfrStringPool* JfrStringPool::create(JfrChunkWriter& cw) { JfrStringPool* JfrStringPool::create(JfrChunkWriter& cw) {
store_generation = 0;
serialized_generation = 0;
assert(_instance == NULL, "invariant"); assert(_instance == NULL, "invariant");
_instance = new JfrStringPool(cw); _instance = new JfrStringPool(cw);
return _instance; return _instance;
@ -155,20 +131,16 @@ BufferPtr JfrStringPool::lease(Thread* thread, size_t size /* 0 */) {
return buffer; return buffer;
} }
bool JfrStringPool::add(bool epoch, jlong id, jstring string, JavaThread* jt) { jboolean JfrStringPool::add(jlong id, jstring string, JavaThread* jt) {
assert(jt != NULL, "invariant"); assert(jt != NULL, "invariant");
const bool current_epoch = JfrTraceIdEpoch::epoch();
if (current_epoch != epoch) {
return current_epoch;
}
{ {
JfrStringPoolWriter writer(jt); JfrStringPoolWriter writer(jt);
writer.write(id); writer.write(id);
writer.write(string); writer.write(string);
writer.inc_nof_strings(); writer.inc_nof_strings();
} }
increment_store_generation(); _new_string.signal();
return current_epoch; return JNI_TRUE;
} }
template <template <typename> class Operation> template <template <typename> class Operation>
@ -224,13 +196,7 @@ size_t JfrStringPool::write() {
return wo.processed(); return wo.processed();
} }
size_t JfrStringPool::write_at_safepoint() {
assert(SafepointSynchronize::is_at_safepoint(), "invariant");
return write();
}
size_t JfrStringPool::clear() { size_t JfrStringPool::clear() {
increment_serialized_generation();
DiscardOperation discard_operation; DiscardOperation discard_operation;
ExclusiveDiscardOperation edo(discard_operation); ExclusiveDiscardOperation edo(discard_operation);
assert(_mspace->free_list_is_empty(), "invariant"); assert(_mspace->free_list_is_empty(), "invariant");

View file

@ -45,10 +45,10 @@ typedef JfrMemorySpace<JfrStringPool, JfrMspaceRetrieval, JfrLinkedList<JfrStrin
// //
class JfrStringPool : public JfrCHeapObj { class JfrStringPool : public JfrCHeapObj {
public: public:
static bool add(bool epoch, jlong id, jstring string, JavaThread* jt);
size_t write(); size_t write();
size_t write_at_safepoint();
size_t clear(); size_t clear();
static jboolean add(jlong id, jstring string, JavaThread* jt);
typedef JfrStringPoolMspace::Node Buffer; typedef JfrStringPoolMspace::Node Buffer;
typedef JfrStringPoolMspace::NodePtr BufferPtr; typedef JfrStringPoolMspace::NodePtr BufferPtr;

View file

@ -0,0 +1,51 @@
/*
* Copyright (c) 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
* 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.
*
*/
#ifndef SHARE_JFR_UTILITIES_JFRSIGNAL_HPP
#define SHARE_JFR_UTILITIES_JFRSIGNAL_HPP
#include "runtime/atomic.hpp"
class JfrSignal {
private:
mutable volatile bool _signaled;
public:
JfrSignal() : _signaled(false) {}
void signal() const {
if (!Atomic::load_acquire(&_signaled)) {
Atomic::release_store(&_signaled, true);
}
}
bool is_signaled() const {
if (Atomic::load_acquire(&_signaled)) {
Atomic::release_store(&_signaled, false); // auto-reset
return true;
}
return false;
}
};
#endif // SHARE_JFR_UTILITIES_JFRSIGNAL_HPP

View file

@ -91,8 +91,8 @@ import sun.reflect.misc.ReflectUtil;
/** /**
* Instances of the class {@code Class} represent classes and * Instances of the class {@code Class} represent classes and
* interfaces in a running Java application. An enum type and a record * interfaces in a running Java application. An enum class and a record
* type are kinds of class; an annotation type is a kind of * class are kinds of class; an annotation interface is a kind of
* interface. Every array also belongs to a class that is reflected as * interface. Every array also belongs to a class that is reflected as
* a {@code Class} object that is shared by all arrays with the same * a {@code Class} object that is shared by all arrays with the same
* element type and number of dimensions. The primitive Java types * element type and number of dimensions. The primitive Java types
@ -131,7 +131,7 @@ import sun.reflect.misc.ReflectUtil;
* </pre></blockquote> * </pre></blockquote>
* *
* It is also possible to get the {@code Class} object for a named * It is also possible to get the {@code Class} object for a named
* type (or for {@code void}) using a <i>class literal</i>. * class or interface (or for {@code void}) using a <i>class literal</i>.
* For example: * For example:
* *
* <blockquote> * <blockquote>
@ -159,8 +159,8 @@ import sun.reflect.misc.ReflectUtil;
* {@link java.lang.invoke.MethodHandles.Lookup#defineHiddenClass(byte[], boolean, MethodHandles.Lookup.ClassOption...) * {@link java.lang.invoke.MethodHandles.Lookup#defineHiddenClass(byte[], boolean, MethodHandles.Lookup.ClassOption...)
* Lookup::defineHiddenClass} is a {@linkplain Class#isHidden() <em>hidden</em>} * Lookup::defineHiddenClass} is a {@linkplain Class#isHidden() <em>hidden</em>}
* class or interface. * class or interface.
* All kinds of class, including enum types and record types, may be * All kinds of class, including enum classes and record classes, may be
* hidden classes; all kinds of interface, including annotation types, * hidden classes; all kinds of interface, including annotation interfaces,
* may be hidden interfaces. * may be hidden interfaces.
* *
* The {@linkplain #getName() name of a hidden class or interface} is * The {@linkplain #getName() name of a hidden class or interface} is
@ -294,7 +294,7 @@ public final class Class<T> implements java.io.Serializable,
if (isAnnotation()) { if (isAnnotation()) {
sb.append('@'); sb.append('@');
} }
if (isInterface()) { // Note: all annotation types are interfaces if (isInterface()) { // Note: all annotation interfaces are interfaces
sb.append("interface"); sb.append("interface");
} else { } else {
if (isEnum()) if (isEnum())
@ -767,11 +767,11 @@ public final class Class<T> implements java.io.Serializable,
/** /**
* Returns true if this {@code Class} object represents an annotation * Returns true if this {@code Class} object represents an annotation
* type. Note that if this method returns true, {@link #isInterface()} * interface. Note that if this method returns true, {@link #isInterface()}
* would also return true, as all annotation types are also interfaces. * would also return true, as all annotation interfaces are also interfaces.
* *
* @return {@code true} if this {@code Class} object represents an annotation * @return {@code true} if this {@code Class} object represents an annotation
* type; {@code false} otherwise * interface; {@code false} otherwise
* @since 1.5 * @since 1.5
*/ */
public boolean isAnnotation() { public boolean isAnnotation() {
@ -1298,8 +1298,8 @@ public final class Class<T> implements java.io.Serializable,
* {@code null} otherwise. * {@code null} otherwise.
* *
* In particular, this method returns {@code null} if the underlying * In particular, this method returns {@code null} if the underlying
* class is a local or anonymous class immediately enclosed by a type * class is a local or anonymous class immediately enclosed by a class or
* declaration, instance initializer or static initializer. * interface declaration, instance initializer or static initializer.
* *
* @return the immediately enclosing method of the underlying class, if * @return the immediately enclosing method of the underlying class, if
* that class is a local or anonymous class; otherwise {@code null}. * that class is a local or anonymous class; otherwise {@code null}.
@ -1456,8 +1456,8 @@ public final class Class<T> implements java.io.Serializable,
* the immediately enclosing constructor of the underlying * the immediately enclosing constructor of the underlying
* class. Returns {@code null} otherwise. In particular, this * class. Returns {@code null} otherwise. In particular, this
* method returns {@code null} if the underlying class is a local * method returns {@code null} if the underlying class is a local
* or anonymous class immediately enclosed by a type declaration, * or anonymous class immediately enclosed by a class or
* instance initializer or static initializer. * interface declaration, instance initializer or static initializer.
* *
* @return the immediately enclosing constructor of the underlying class, if * @return the immediately enclosing constructor of the underlying class, if
* that class is a local or anonymous class; otherwise {@code null}. * that class is a local or anonymous class; otherwise {@code null}.
@ -1650,9 +1650,9 @@ public final class Class<T> implements java.io.Serializable,
} }
/** /**
* Return an informative string for the name of this type. * Return an informative string for the name of this class or interface.
* *
* @return an informative string for the name of this type * @return an informative string for the name of this class or interface
* @since 1.8 * @since 1.8
*/ */
public String getTypeName() { public String getTypeName() {
@ -2371,7 +2371,7 @@ public final class Class<T> implements java.io.Serializable,
* *
* </ul> * </ul>
* *
* @jls 8.10 Record Types * @jls 8.10 Record Classes
* @since 16 * @since 16
*/ */
@CallerSensitive @CallerSensitive
@ -2392,14 +2392,14 @@ public final class Class<T> implements java.io.Serializable,
* Class} object, including public, protected, default (package) * Class} object, including public, protected, default (package)
* access, and private methods, but excluding inherited methods. * access, and private methods, but excluding inherited methods.
* *
* <p> If this {@code Class} object represents a type that has multiple * <p> If this {@code Class} object represents a class or interface that
* declared methods with the same name and parameter types, but different * has multiple declared methods with the same name and parameter types,
* return types, then the returned array has a {@code Method} object for * but different return types, then the returned array has a {@code Method}
* each such method. * object for each such method.
* *
* <p> If this {@code Class} object represents a type that has a class * <p> If this {@code Class} object represents a class or interface that
* initialization method {@code <clinit>}, then the returned array does * has a class initialization method {@code <clinit>}, then the returned
* <em>not</em> have a corresponding {@code Method} object. * array does <em>not</em> have a corresponding {@code Method} object.
* *
* <p> If this {@code Class} object represents a class or interface with no * <p> If this {@code Class} object represents a class or interface with no
* declared methods, then the returned array has length 0. * declared methods, then the returned array has length 0.
@ -3671,13 +3671,13 @@ public final class Class<T> implements java.io.Serializable,
* Returns true if and only if this class was declared as an enum in the * Returns true if and only if this class was declared as an enum in the
* source code. * source code.
* *
* Note that {@link java.lang.Enum} is not itself an enum type. * Note that {@link java.lang.Enum} is not itself an enum class.
* *
* Also note that if an enum constant is declared with a class body, * Also note that if an enum constant is declared with a class body,
* the class of that enum constant object is an anonymous class * the class of that enum constant object is an anonymous class
* and <em>not</em> the class of the declaring enum type. The * and <em>not</em> the class of the declaring enum class. The
* {@link Enum#getDeclaringClass} method of an enum constant can * {@link Enum#getDeclaringClass} method of an enum constant can
* be used to get the class of the enum type declaring the * be used to get the class of the enum class declaring the
* constant. * constant.
* *
* @return true if and only if this class was declared as an enum in the * @return true if and only if this class was declared as an enum in the
@ -3702,11 +3702,11 @@ public final class Class<T> implements java.io.Serializable,
* components; {@link #getRecordComponents()} returns a non-null but * components; {@link #getRecordComponents()} returns a non-null but
* possibly empty value for a record. * possibly empty value for a record.
* *
* <p> Note that class {@link Record} is not a record type and thus invoking * <p> Note that class {@link Record} is not a record class and thus
* this method on class {@code Record} returns {@code false}. * invoking this method on class {@code Record} returns {@code false}.
* *
* @return true if and only if this class is a record class, otherwise false * @return true if and only if this class is a record class, otherwise false
* @jls 8.10 Record Types * @jls 8.10 Record Classes
* @since 16 * @since 16
*/ */
public boolean isRecord() { public boolean isRecord() {
@ -3730,12 +3730,12 @@ public final class Class<T> implements java.io.Serializable,
/** /**
* Returns the elements of this enum class or null if this * Returns the elements of this enum class or null if this
* Class object does not represent an enum type. * Class object does not represent an enum class.
* *
* @return an array containing the values comprising the enum class * @return an array containing the values comprising the enum class
* represented by this {@code Class} object in the order they're * represented by this {@code Class} object in the order they're
* declared, or null if this {@code Class} object does not * declared, or null if this {@code Class} object does not
* represent an enum type * represent an enum class
* @since 1.5 * @since 1.5
*/ */
public T[] getEnumConstants() { public T[] getEnumConstants() {
@ -3745,7 +3745,7 @@ public final class Class<T> implements java.io.Serializable,
/** /**
* Returns the elements of this enum class or null if this * Returns the elements of this enum class or null if this
* Class object does not represent an enum type; * Class object does not represent an enum class;
* identical to getEnumConstants except that the result is * identical to getEnumConstants except that the result is
* uncloned, cached, and shared by all callers. * uncloned, cached, and shared by all callers.
*/ */
@ -3788,7 +3788,7 @@ public final class Class<T> implements java.io.Serializable,
T[] universe = getEnumConstantsShared(); T[] universe = getEnumConstantsShared();
if (universe == null) if (universe == null)
throw new IllegalArgumentException( throw new IllegalArgumentException(
getName() + " is not an enum type"); getName() + " is not an enum class");
directory = new HashMap<>((int)(universe.length / 0.75f) + 1); directory = new HashMap<>((int)(universe.length / 0.75f) + 1);
for (T constant : universe) { for (T constant : universe) {
directory.put(((Enum<?>)constant).name(), constant); directory.put(((Enum<?>)constant).name(), constant);
@ -4024,7 +4024,7 @@ public final class Class<T> implements java.io.Serializable,
return new AnnotationData(annotations, declaredAnnotations, classRedefinedCount); return new AnnotationData(annotations, declaredAnnotations, classRedefinedCount);
} }
// Annotation types cache their internal (AnnotationType) form // Annotation interfaces cache their internal (AnnotationType) form
@SuppressWarnings("UnusedDeclaration") @SuppressWarnings("UnusedDeclaration")
private transient volatile AnnotationType annotationType; private transient volatile AnnotationType annotationType;
@ -4050,10 +4050,10 @@ public final class Class<T> implements java.io.Serializable,
* Returns an {@code AnnotatedType} object that represents the use of a * Returns an {@code AnnotatedType} object that represents the use of a
* type to specify the superclass of the entity represented by this {@code * type to specify the superclass of the entity represented by this {@code
* Class} object. (The <em>use</em> of type Foo to specify the superclass * Class} object. (The <em>use</em> of type Foo to specify the superclass
* in '... extends Foo' is distinct from the <em>declaration</em> of type * in '... extends Foo' is distinct from the <em>declaration</em> of class
* Foo.) * Foo.)
* *
* <p> If this {@code Class} object represents a type whose declaration * <p> If this {@code Class} object represents a class whose declaration
* does not explicitly indicate an annotated superclass, then the return * does not explicitly indicate an annotated superclass, then the return
* value is an {@code AnnotatedType} object representing an element with no * value is an {@code AnnotatedType} object representing an element with no
* annotations. * annotations.
@ -4082,7 +4082,7 @@ public final class Class<T> implements java.io.Serializable,
* of types to specify superinterfaces of the entity represented by this * of types to specify superinterfaces of the entity represented by this
* {@code Class} object. (The <em>use</em> of type Foo to specify a * {@code Class} object. (The <em>use</em> of type Foo to specify a
* superinterface in '... implements Foo' is distinct from the * superinterface in '... implements Foo' is distinct from the
* <em>declaration</em> of type Foo.) * <em>declaration</em> of interface Foo.)
* *
* <p> If this {@code Class} object represents a class, the return value is * <p> If this {@code Class} object represents a class, the return value is
* an array containing objects representing the uses of interface types to * an array containing objects representing the uses of interface types to

View file

@ -46,8 +46,8 @@ public interface AnnotatedArrayType extends AnnotatedType {
/** /**
* Returns the potentially annotated type that this type is a member of, if * Returns the potentially annotated type that this type is a member of, if
* this type represents a nested type. For example, if this type is * this type represents a nested class or interface. For example, if this
* {@code @TA O<T>.I<S>}, return a representation of {@code @TA O<T>}. * type is {@code @TA O<T>.I<S>}, return a representation of {@code @TA O<T>}.
* *
* <p>Returns {@code null} for an {@code AnnotatedType} that is an instance * <p>Returns {@code null} for an {@code AnnotatedType} that is an instance
* of {@code AnnotatedArrayType}. * of {@code AnnotatedArrayType}.

View file

@ -248,7 +248,7 @@ import sun.reflect.annotation.AnnotationType;
* *
* <p>Similarly, attempting to read an enum-valued member will result in * <p>Similarly, attempting to read an enum-valued member will result in
* a {@link EnumConstantNotPresentException} if the enum constant in the * a {@link EnumConstantNotPresentException} if the enum constant in the
* annotation is no longer present in the enum type. * annotation is no longer present in the enum class.
* *
* <p>If an annotation type <i>T</i> is (meta-)annotated with an * <p>If an annotation type <i>T</i> is (meta-)annotated with an
* {@code @Repeatable} annotation whose value element indicates a type * {@code @Repeatable} annotation whose value element indicates a type

View file

@ -49,13 +49,13 @@ public interface AnnotatedParameterizedType extends AnnotatedType {
* {@code @TA O<T>.I<S>}, return a representation of {@code @TA O<T>}. * {@code @TA O<T>.I<S>}, return a representation of {@code @TA O<T>}.
* *
* <p>Returns {@code null} if this {@code AnnotatedType} represents a * <p>Returns {@code null} if this {@code AnnotatedType} represents a
* top-level type, or a local or anonymous class, or a primitive type, or * top-level class or interface, or a local or anonymous class, or
* void. * a primitive type, or void.
* *
* @return an {@code AnnotatedType} object representing the potentially * @return an {@code AnnotatedType} object representing the potentially
* annotated type that this type is a member of, or {@code null} * annotated type that this type is a member of, or {@code null}
* @throws TypeNotPresentException if the owner type * @throws TypeNotPresentException if the owner type
* refers to a non-existent type declaration * refers to a non-existent class or interface declaration
* @throws MalformedParameterizedTypeException if the owner type * @throws MalformedParameterizedTypeException if the owner type
* refers to a parameterized type that cannot be instantiated * refers to a parameterized type that cannot be instantiated
* for any reason * for any reason

View file

@ -55,8 +55,8 @@ public interface AnnotatedType extends AnnotatedElement {
* {@code @TA O<T>.I<S>}, return a representation of {@code @TA O<T>}. * {@code @TA O<T>.I<S>}, return a representation of {@code @TA O<T>}.
* *
* <p>Returns {@code null} if this {@code AnnotatedType} represents a * <p>Returns {@code null} if this {@code AnnotatedType} represents a
* top-level type, or a local or anonymous class, or a primitive type, or * top-level class or interface, or a local or anonymous class, or
* void. * a primitive type, or void.
* *
* <p>Returns {@code null} if this {@code AnnotatedType} is an instance of * <p>Returns {@code null} if this {@code AnnotatedType} is an instance of
* {@code AnnotatedArrayType}, {@code AnnotatedTypeVariable}, or * {@code AnnotatedArrayType}, {@code AnnotatedTypeVariable}, or
@ -69,7 +69,7 @@ public interface AnnotatedType extends AnnotatedElement {
* @return an {@code AnnotatedType} object representing the potentially * @return an {@code AnnotatedType} object representing the potentially
* annotated type that this type is a member of, or {@code null} * annotated type that this type is a member of, or {@code null}
* @throws TypeNotPresentException if the owner type * @throws TypeNotPresentException if the owner type
* refers to a non-existent type declaration * refers to a non-existent class or interface declaration
* @throws MalformedParameterizedTypeException if the owner type * @throws MalformedParameterizedTypeException if the owner type
* refers to a parameterized type that cannot be instantiated * refers to a parameterized type that cannot be instantiated
* for any reason * for any reason

View file

@ -462,7 +462,7 @@ public final class Constructor<T> extends Executable {
* after possible unwrapping, a parameter value * after possible unwrapping, a parameter value
* cannot be converted to the corresponding formal * cannot be converted to the corresponding formal
* parameter type by a method invocation conversion; if * parameter type by a method invocation conversion; if
* this constructor pertains to an enum type. * this constructor pertains to an enum class.
* @throws InstantiationException if the class that declares the * @throws InstantiationException if the class that declares the
* underlying constructor represents an abstract class. * underlying constructor represents an abstract class.
* @throws InvocationTargetException if the underlying constructor * @throws InvocationTargetException if the underlying constructor

View file

@ -206,10 +206,10 @@ class Field extends AccessibleObject implements Member {
/** /**
* Returns {@code true} if this field represents an element of * Returns {@code true} if this field represents an element of
* an enumerated type; returns {@code false} otherwise. * an enumerated class; returns {@code false} otherwise.
* *
* @return {@code true} if and only if this field represents an element of * @return {@code true} if and only if this field represents an element of
* an enumerated type. * an enumerated class.
* @since 1.5 * @since 1.5
*/ */
public boolean isEnumConstant() { public boolean isEnumConstant() {
@ -258,7 +258,7 @@ class Field extends AccessibleObject implements Member {
* <cite>The Java Virtual Machine Specification</cite> * <cite>The Java Virtual Machine Specification</cite>
* @throws TypeNotPresentException if the generic type * @throws TypeNotPresentException if the generic type
* signature of the underlying field refers to a non-existent * signature of the underlying field refers to a non-existent
* type declaration * class or interface declaration
* @throws MalformedParameterizedTypeException if the generic * @throws MalformedParameterizedTypeException if the generic
* signature of the underlying field refers to a parameterized type * signature of the underlying field refers to a parameterized type
* that cannot be instantiated for any reason * that cannot be instantiated for any reason

View file

@ -44,8 +44,8 @@ public interface GenericArrayType extends Type {
* *
* @return a {@code Type} object representing the component type * @return a {@code Type} object representing the component type
* of this array * of this array
* @throws TypeNotPresentException if the underlying array type's * @throws TypeNotPresentException if the underlying array type's component
* component type refers to a non-existent type declaration * type refers to a non-existent class or interface declaration
* @throws MalformedParameterizedTypeException if the * @throws MalformedParameterizedTypeException if the
* underlying array type's component type refers to a * underlying array type's component type refers to a
* parameterized type that cannot be instantiated for any reason * parameterized type that cannot be instantiated for any reason

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2019, 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -28,8 +28,8 @@ package java.lang.reflect;
/** /**
* Thrown when a syntactically malformed signature attribute is * Thrown when a syntactically malformed signature attribute is
* encountered by a reflective method that needs to interpret the * encountered by a reflective method that needs to interpret the generic
* generic signature information for a type, method or constructor. * signature information for a class or interface, method or constructor.
* *
* @since 1.5 * @since 1.5
*/ */

View file

@ -282,9 +282,9 @@ public final class Method extends Executable {
* specified in * specified in
* <cite>The Java Virtual Machine Specification</cite> * <cite>The Java Virtual Machine Specification</cite>
* @throws TypeNotPresentException if the underlying method's * @throws TypeNotPresentException if the underlying method's
* return type refers to a non-existent type declaration * return type refers to a non-existent class or interface declaration
* @throws MalformedParameterizedTypeException if the * @throws MalformedParameterizedTypeException if the
* underlying method's return typed refers to a parameterized * underlying method's return type refers to a parameterized
* type that cannot be instantiated for any reason * type that cannot be instantiated for any reason
* @since 1.5 * @since 1.5
*/ */
@ -603,8 +603,7 @@ public final class Method extends Executable {
* method; returns {@code false} otherwise. * method; returns {@code false} otherwise.
* *
* A default method is a public non-abstract instance method, that * A default method is a public non-abstract instance method, that
* is, a non-static method with a body, declared in an interface * is, a non-static method with a body, declared in an interface.
* type.
* *
* @return true if and only if this method is a default * @return true if and only if this method is a default
* method as defined by the Java Language Specification. * method as defined by the Java Language Specification.

View file

@ -32,15 +32,15 @@ package java.lang.reflect;
* *
* <p>A parameterized type is created the first time it is needed by a * <p>A parameterized type is created the first time it is needed by a
* reflective method, as specified in this package. When a * reflective method, as specified in this package. When a
* parameterized type p is created, the generic type declaration that * parameterized type p is created, the generic class or interface declaration
* p instantiates is resolved, and all type arguments of p are created * that p instantiates is resolved, and all type arguments of p are created
* recursively. See {@link java.lang.reflect.TypeVariable * recursively. See {@link java.lang.reflect.TypeVariable
* TypeVariable} for details on the creation process for type * TypeVariable} for details on the creation process for type
* variables. Repeated creation of a parameterized type has no effect. * variables. Repeated creation of a parameterized type has no effect.
* *
* <p>Instances of classes that implement this interface must implement * <p>Instances of classes that implement this interface must implement
* an equals() method that equates any two instances that share the * an equals() method that equates any two instances that share the
* same generic type declaration and have equal type parameters. * same generic class or interface declaration and have equal type parameters.
* *
* @jls 4.5 Parameterized Types * @jls 4.5 Parameterized Types
* @since 1.5 * @since 1.5
@ -56,8 +56,8 @@ public interface ParameterizedType extends Type {
* *
* @return an array of {@code Type} objects representing the actual type * @return an array of {@code Type} objects representing the actual type
* arguments to this type * arguments to this type
* @throws TypeNotPresentException if any of the * @throws TypeNotPresentException if any of the actual type arguments
* actual type arguments refers to a non-existent type declaration * refers to a non-existent class or interface declaration
* @throws MalformedParameterizedTypeException if any of the * @throws MalformedParameterizedTypeException if any of the
* actual type parameters refer to a parameterized type that cannot * actual type parameters refer to a parameterized type that cannot
* be instantiated for any reason * be instantiated for any reason
@ -86,7 +86,7 @@ public interface ParameterizedType extends Type {
* this type is a member of. If this type is a top-level type, * this type is a member of. If this type is a top-level type,
* {@code null} is returned * {@code null} is returned
* @throws TypeNotPresentException if the owner type * @throws TypeNotPresentException if the owner type
* refers to a non-existent type declaration * refers to a non-existent class or interface declaration
* @throws MalformedParameterizedTypeException if the owner type * @throws MalformedParameterizedTypeException if the owner type
* refers to a parameterized type that cannot be instantiated * refers to a parameterized type that cannot be instantiated
* for any reason * for any reason

View file

@ -240,10 +240,11 @@ import static java.lang.module.ModuleDescriptor.Modifier.SYNTHETIC;
* *
* <p> * <p>
* A dynamic module can read the modules of all of the superinterfaces of a proxy * A dynamic module can read the modules of all of the superinterfaces of a proxy
* class and the modules of the types referenced by all public method signatures * class and the modules of the classes and interfaces referenced by
* of a proxy class. If a superinterface or a referenced type, say {@code T}, * all public method signatures of a proxy class. If a superinterface or
* is in a non-exported package, the {@linkplain Module module} of {@code T} is * a referenced class or interface, say {@code T}, is in a non-exported package,
* updated to export the package of {@code T} to the dynamic module. * the {@linkplain Module module} of {@code T} is updated to export the
* package of {@code T} to the dynamic module.
* *
* <h3>Methods Duplicated in Multiple Proxy Interfaces</h3> * <h3>Methods Duplicated in Multiple Proxy Interfaces</h3>
* *

View file

@ -203,10 +203,11 @@ final class ProxyGenerator extends ClassWriter {
} }
/** /**
* Return an array of the type names from an array of Classes. * Return an array of the class and interface names from an array of Classes.
* *
* @param classes an array of classes or interfaces * @param classes an array of classes or interfaces
* @return the array of class names; or null if there are no classes * @return the array of class and interface names; or null if classes is
* null or empty
*/ */
private static String[] typeNames(List<Class<?>> classes) { private static String[] typeNames(List<Class<?>> classes) {
if (classes == null || classes.size() == 0) if (classes == null || classes.size() == 0)

View file

@ -43,7 +43,7 @@ import java.util.Objects;
* *
* @see Class#getRecordComponents() * @see Class#getRecordComponents()
* @see java.lang.Record * @see java.lang.Record
* @jls 8.10 Record Types * @jls 8.10 Record Classes
* @since 16 * @since 16
*/ */
public final class RecordComponent implements AnnotatedElement { public final class RecordComponent implements AnnotatedElement {
@ -83,7 +83,7 @@ public final class RecordComponent implements AnnotatedElement {
} }
/** /**
* Returns a {@code String} that describes the generic type signature for * Returns a {@code String} that describes the generic type signature for
* this record component. * this record component.
* *
* @return a {@code String} that describes the generic type signature for * @return a {@code String} that describes the generic type signature for

View file

@ -439,10 +439,10 @@ public abstract class Symbol extends AnnoConstruct implements PoolConstant, Elem
* Also includes fields of inner classes which are in * Also includes fields of inner classes which are in
* turn local to a method or variable initializer. * turn local to a method or variable initializer.
*/ */
public boolean isLocal() { public boolean isDirectlyOrIndirectlyLocal() {
return return
(owner.kind.matches(KindSelector.VAL_MTH) || (owner.kind.matches(KindSelector.VAL_MTH) ||
(owner.kind == TYP && owner.isLocal())); (owner.kind == TYP && owner.isDirectlyOrIndirectlyLocal()));
} }
/** Has this symbol an empty name? This includes anonymous /** Has this symbol an empty name? This includes anonymous
@ -760,7 +760,7 @@ public abstract class Symbol extends AnnoConstruct implements PoolConstant, Elem
public Symbol baseSymbol() { return other; } public Symbol baseSymbol() { return other; }
public Type erasure(Types types) { return other.erasure(types); } public Type erasure(Types types) { return other.erasure(types); }
public Type externalType(Types types) { return other.externalType(types); } public Type externalType(Types types) { return other.externalType(types); }
public boolean isLocal() { return other.isLocal(); } public boolean isDirectlyOrIndirectlyLocal() { return other.isDirectlyOrIndirectlyLocal(); }
public boolean isConstructor() { return other.isConstructor(); } public boolean isConstructor() { return other.isConstructor(); }
public Name getQualifiedName() { return other.getQualifiedName(); } public Name getQualifiedName() { return other.getQualifiedName(); }
public Name flatName() { return other.flatName(); } public Name flatName() { return other.flatName(); }

View file

@ -5165,7 +5165,7 @@ public class Attr extends JCTree.Visitor {
} }
} }
} else { } else {
if (c.isLocal() && !c.isEnum()) { if (c.isDirectlyOrIndirectlyLocal() && !c.isEnum()) {
log.error(TreeInfo.diagnosticPositionFor(c, env.tree), Errors.LocalClassesCantExtendSealed(c.isAnonymous() ? Fragments.Anonymous : Fragments.Local)); log.error(TreeInfo.diagnosticPositionFor(c, env.tree), Errors.LocalClassesCantExtendSealed(c.isAnonymous() ? Fragments.Anonymous : Fragments.Local));
} }

View file

@ -119,7 +119,7 @@ public class Check {
names = Names.instance(context); names = Names.instance(context);
dfltTargetMeta = new Name[] { names.PACKAGE, names.TYPE, dfltTargetMeta = new Name[] { names.PACKAGE, names.TYPE,
names.FIELD, names.RECORD_COMPONENT, names.METHOD, names.CONSTRUCTOR, names.FIELD, names.RECORD_COMPONENT, names.METHOD, names.CONSTRUCTOR,
names.ANNOTATION_TYPE, names.LOCAL_VARIABLE, names.PARAMETER}; names.ANNOTATION_TYPE, names.LOCAL_VARIABLE, names.PARAMETER, names.MODULE };
log = Log.instance(context); log = Log.instance(context);
rs = Resolve.instance(context); rs = Resolve.instance(context);
syms = Symtab.instance(context); syms = Symtab.instance(context);
@ -1216,7 +1216,8 @@ public class Check {
implicit |= sym.owner.flags_field & STRICTFP; implicit |= sym.owner.flags_field & STRICTFP;
break; break;
case TYP: case TYP:
if (sym.owner.kind.matches(KindSelector.VAL_MTH)) { if (sym.owner.kind.matches(KindSelector.VAL_MTH) ||
(sym.isDirectlyOrIndirectlyLocal() && (flags & ANNOTATION) != 0)) {
boolean implicitlyStatic = !sym.isAnonymous() && boolean implicitlyStatic = !sym.isAnonymous() &&
((flags & RECORD) != 0 || (flags & ENUM) != 0 || (flags & INTERFACE) != 0); ((flags & RECORD) != 0 || (flags & ENUM) != 0 || (flags & INTERFACE) != 0);
boolean staticOrImplicitlyStatic = (flags & STATIC) != 0 || implicitlyStatic; boolean staticOrImplicitlyStatic = (flags & STATIC) != 0 || implicitlyStatic;
@ -1225,7 +1226,7 @@ public class Check {
implicit = implicitlyStatic ? STATIC : implicit; implicit = implicitlyStatic ? STATIC : implicit;
} else if (sym.owner.kind == TYP) { } else if (sym.owner.kind == TYP) {
// statics in inner classes are allowed only if records are allowed too // statics in inner classes are allowed only if records are allowed too
mask = ((flags & STATIC) != 0) && allowRecords ? ExtendedMemberStaticClassFlags : ExtendedMemberClassFlags; mask = ((flags & STATIC) != 0) && allowRecords && (flags & ANNOTATION) == 0 ? ExtendedMemberStaticClassFlags : ExtendedMemberClassFlags;
if (sym.owner.owner.kind == PCK || if (sym.owner.owner.kind == PCK ||
(sym.owner.flags_field & STATIC) != 0) { (sym.owner.flags_field & STATIC) != 0) {
mask |= STATIC; mask |= STATIC;
@ -2729,7 +2730,7 @@ public class Check {
if (sym.kind == VAR) { if (sym.kind == VAR) {
if ((sym.flags() & PARAMETER) != 0 || if ((sym.flags() & PARAMETER) != 0 ||
sym.isLocal() || sym.isDirectlyOrIndirectlyLocal() ||
sym.name == names._this || sym.name == names._this ||
sym.name == names._super) { sym.name == names._super) {
return; return;

View file

@ -498,7 +498,7 @@ public class Enter extends JCTree.Visitor {
// Add non-local class to uncompleted, to make sure it will be // Add non-local class to uncompleted, to make sure it will be
// completed later. // completed later.
if (!c.isLocal() && uncompleted != null) uncompleted.append(c); if (!c.isDirectlyOrIndirectlyLocal() && uncompleted != null) uncompleted.append(c);
// System.err.println("entering " + c.fullname + " in " + c.owner);//DEBUG // System.err.println("entering " + c.fullname + " in " + c.owner);//DEBUG
// Recursively enter all member classes. // Recursively enter all member classes.

View file

@ -2904,7 +2904,7 @@ public class Flow {
public void visitClassDef(JCClassDecl tree) { public void visitClassDef(JCClassDecl tree) {
JCTree prevTree = currentTree; JCTree prevTree = currentTree;
try { try {
currentTree = tree.sym.isLocal() ? tree : null; currentTree = tree.sym.isDirectlyOrIndirectlyLocal() ? tree : null;
super.visitClassDef(tree); super.visitClassDef(tree);
} finally { } finally {
currentTree = prevTree; currentTree = prevTree;

View file

@ -1438,7 +1438,7 @@ public class LambdaToMethod extends TreeTranslator {
public void visitNewClass(JCNewClass tree) { public void visitNewClass(JCNewClass tree) {
TypeSymbol def = tree.type.tsym; TypeSymbol def = tree.type.tsym;
boolean inReferencedClass = currentlyInClass(def); boolean inReferencedClass = currentlyInClass(def);
boolean isLocal = def.isLocal(); boolean isLocal = def.isDirectlyOrIndirectlyLocal();
if ((inReferencedClass && isLocal || lambdaNewClassFilter(context(), tree))) { if ((inReferencedClass && isLocal || lambdaNewClassFilter(context(), tree))) {
TranslationContext<?> localContext = context(); TranslationContext<?> localContext = context();
final TypeSymbol outerInstanceSymbol = tree.type.getEnclosingType().tsym; final TypeSymbol outerInstanceSymbol = tree.type.getEnclosingType().tsym;
@ -1592,7 +1592,7 @@ public class LambdaToMethod extends TreeTranslator {
while (frameStack2.nonEmpty()) { while (frameStack2.nonEmpty()) {
switch (frameStack2.head.tree.getTag()) { switch (frameStack2.head.tree.getTag()) {
case VARDEF: case VARDEF:
if (((JCVariableDecl)frameStack2.head.tree).sym.isLocal()) { if (((JCVariableDecl)frameStack2.head.tree).sym.isDirectlyOrIndirectlyLocal()) {
frameStack2 = frameStack2.tail; frameStack2 = frameStack2.tail;
break; break;
} }
@ -2313,7 +2313,7 @@ public class LambdaToMethod extends TreeTranslator {
!receiverAccessible() || !receiverAccessible() ||
(tree.getMode() == ReferenceMode.NEW && (tree.getMode() == ReferenceMode.NEW &&
tree.kind != ReferenceKind.ARRAY_CTOR && tree.kind != ReferenceKind.ARRAY_CTOR &&
(tree.sym.owner.isLocal() || tree.sym.owner.isInner())); (tree.sym.owner.isDirectlyOrIndirectlyLocal() || tree.sym.owner.isInner()));
} }
Type generatedRefSig() { Type generatedRefSig() {

View file

@ -378,11 +378,11 @@ public class Lower extends TreeTranslator {
} }
ClassSymbol ownerToCopyFreeVarsFrom(ClassSymbol c) { ClassSymbol ownerToCopyFreeVarsFrom(ClassSymbol c) {
if (!c.isLocal()) { if (!c.isDirectlyOrIndirectlyLocal()) {
return null; return null;
} }
Symbol currentOwner = c.owner; Symbol currentOwner = c.owner;
while (currentOwner.owner.kind.matches(KindSelector.TYP) && currentOwner.isLocal()) { while (currentOwner.owner.kind.matches(KindSelector.TYP) && currentOwner.isDirectlyOrIndirectlyLocal()) {
currentOwner = currentOwner.owner; currentOwner = currentOwner.owner;
} }
if (currentOwner.owner.kind.matches(KindSelector.VAL_MTH) && c.isSubClass(currentOwner, types)) { if (currentOwner.owner.kind.matches(KindSelector.VAL_MTH) && c.isSubClass(currentOwner, types)) {
@ -1049,7 +1049,7 @@ public class Lower extends TreeTranslator {
} }
if ((sym.flags() & PRIVATE) == 0 || sym.owner == currentClass) { if ((sym.flags() & PRIVATE) == 0 || sym.owner == currentClass) {
return false; return false;
} else if (sym.name == names.init && sym.owner.isLocal()) { } else if (sym.name == names.init && sym.owner.isDirectlyOrIndirectlyLocal()) {
// private constructor in local class: relax protection // private constructor in local class: relax protection
sym.flags_field &= ~PRIVATE; sym.flags_field &= ~PRIVATE;
return false; return false;
@ -2203,7 +2203,7 @@ public class Lower extends TreeTranslator {
tree.extending = translate(tree.extending); tree.extending = translate(tree.extending);
tree.implementing = translate(tree.implementing); tree.implementing = translate(tree.implementing);
if (currentClass.isLocal()) { if (currentClass.isDirectlyOrIndirectlyLocal()) {
ClassSymbol encl = currentClass.owner.enclClass(); ClassSymbol encl = currentClass.owner.enclClass();
if (encl.trans_local == null) { if (encl.trans_local == null) {
encl.trans_local = List.nil(); encl.trans_local = List.nil();
@ -2654,7 +2654,7 @@ public class Lower extends TreeTranslator {
private void visitMethodDefInternal(JCMethodDecl tree) { private void visitMethodDefInternal(JCMethodDecl tree) {
if (tree.name == names.init && if (tree.name == names.init &&
(currentClass.isInner() || currentClass.isLocal())) { (currentClass.isInner() || currentClass.isDirectlyOrIndirectlyLocal())) {
// We are seeing a constructor of an inner class. // We are seeing a constructor of an inner class.
MethodSymbol m = tree.sym; MethodSymbol m = tree.sym;
@ -2794,7 +2794,7 @@ public class Lower extends TreeTranslator {
// If created class is local, add free variables after // If created class is local, add free variables after
// explicit constructor arguments. // explicit constructor arguments.
if (c.isLocal()) { if (c.isDirectlyOrIndirectlyLocal()) {
tree.args = tree.args.appendList(loadFreevars(tree.pos(), freevars(c))); tree.args = tree.args.appendList(loadFreevars(tree.pos(), freevars(c)));
} }
@ -2813,7 +2813,7 @@ public class Lower extends TreeTranslator {
if (tree.encl != null) { if (tree.encl != null) {
thisArg = attr.makeNullCheck(translate(tree.encl)); thisArg = attr.makeNullCheck(translate(tree.encl));
thisArg.type = tree.encl.type; thisArg.type = tree.encl.type;
} else if (c.isLocal()) { } else if (c.isDirectlyOrIndirectlyLocal()) {
// local class // local class
thisArg = makeThis(tree.pos(), c.type.getEnclosingType().tsym); thisArg = makeThis(tree.pos(), c.type.getEnclosingType().tsym);
} else { } else {
@ -2996,7 +2996,7 @@ public class Lower extends TreeTranslator {
// If we are calling a constructor of a local class, add // If we are calling a constructor of a local class, add
// free variables after explicit constructor arguments. // free variables after explicit constructor arguments.
ClassSymbol c = (ClassSymbol)constructor.owner; ClassSymbol c = (ClassSymbol)constructor.owner;
if (c.isLocal()) { if (c.isDirectlyOrIndirectlyLocal()) {
tree.args = tree.args.appendList(loadFreevars(tree.pos(), freevars(c))); tree.args = tree.args.appendList(loadFreevars(tree.pos(), freevars(c)));
} }
@ -3024,7 +3024,7 @@ public class Lower extends TreeTranslator {
makeNullCheck(translate(((JCFieldAccess) tree.meth).selected)); makeNullCheck(translate(((JCFieldAccess) tree.meth).selected));
tree.meth = make.Ident(constructor); tree.meth = make.Ident(constructor);
((JCIdent) tree.meth).name = methName; ((JCIdent) tree.meth).name = methName;
} else if (c.isLocal() || methName == names._this){ } else if (c.isDirectlyOrIndirectlyLocal() || methName == names._this){
// local class or this() call // local class or this() call
thisArg = makeThis(tree.meth.pos(), c.type.getEnclosingType().tsym); thisArg = makeThis(tree.meth.pos(), c.type.getEnclosingType().tsym);
} else { } else {

View file

@ -521,7 +521,7 @@ public class TypeEnter implements Completer {
WriteableScope baseScope = WriteableScope.create(tree.sym); WriteableScope baseScope = WriteableScope.create(tree.sym);
//import already entered local classes into base scope //import already entered local classes into base scope
for (Symbol sym : env.outer.info.scope.getSymbols(NON_RECURSIVE)) { for (Symbol sym : env.outer.info.scope.getSymbols(NON_RECURSIVE)) {
if (sym.isLocal()) { if (sym.isDirectlyOrIndirectlyLocal()) {
baseScope.enter(sym); baseScope.enter(sym);
} }
} }

View file

@ -143,7 +143,7 @@ public class JNIWriter {
public boolean needsHeader(ClassSymbol c) { public boolean needsHeader(ClassSymbol c) {
lazyInit(); lazyInit();
if (c.isLocal() || isSynthetic(c)) if (c.isDirectlyOrIndirectlyLocal() || isSynthetic(c))
return false; return false;
return (checkAll) return (checkAll)
? needsHeader(c.outermostClass(), true) ? needsHeader(c.outermostClass(), true)
@ -151,7 +151,7 @@ public class JNIWriter {
} }
private boolean needsHeader(ClassSymbol c, boolean checkNestedClasses) { private boolean needsHeader(ClassSymbol c, boolean checkNestedClasses) {
if (c.isLocal() || isSynthetic(c)) if (c.isDirectlyOrIndirectlyLocal() || isSynthetic(c))
return false; return false;
for (Symbol sym : c.members_field.getSymbols(NON_RECURSIVE)) { for (Symbol sym : c.members_field.getSymbols(NON_RECURSIVE)) {

View file

@ -32,7 +32,6 @@ import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeElement;
import jdk.javadoc.doclet.Doclet; import jdk.javadoc.doclet.Doclet;
import jdk.javadoc.doclet.DocletEnvironment;
import jdk.javadoc.doclet.Reporter; import jdk.javadoc.doclet.Reporter;
import jdk.javadoc.internal.doclets.toolkit.AbstractDoclet; import jdk.javadoc.internal.doclets.toolkit.AbstractDoclet;
import jdk.javadoc.internal.doclets.toolkit.DocletException; import jdk.javadoc.internal.doclets.toolkit.DocletException;
@ -216,7 +215,7 @@ public class HtmlDoclet extends AbstractDoclet {
f.copyResource(DocPaths.RESOURCES.resolve(DocPaths.JAVASCRIPT), true, true); f.copyResource(DocPaths.RESOURCES.resolve(DocPaths.JAVASCRIPT), true, true);
if (options.createIndex()) { if (options.createIndex()) {
f = DocFile.createFileForOutput(configuration, DocPaths.SEARCH_JS); f = DocFile.createFileForOutput(configuration, DocPaths.SEARCH_JS);
f.copyResource(DOCLET_RESOURCES.resolve(DocPaths.SEARCH_JS), true, true); f.copyResource(DOCLET_RESOURCES.resolve(DocPaths.SEARCH_JS_TEMPLATE), configuration.docResources);
f = DocFile.createFileForOutput(configuration, DocPaths.RESOURCES.resolve(DocPaths.GLASS_IMG)); f = DocFile.createFileForOutput(configuration, DocPaths.RESOURCES.resolve(DocPaths.GLASS_IMG));
f.copyResource(DOCLET_RESOURCES.resolve(DocPaths.GLASS_IMG), true, false); f.copyResource(DOCLET_RESOURCES.resolve(DocPaths.GLASS_IMG), true, false);

View file

@ -23,13 +23,13 @@
* questions. * questions.
*/ */
var noResult = {l: "No results found"}; var noResult = {l: "##REPLACE:doclet.search.no_results##"};
var loading = {l: "Loading search index..."}; var loading = {l: "##REPLACE:doclet.search.loading##"};
var catModules = "Modules"; var catModules = "##REPLACE:doclet.search.modules##";
var catPackages = "Packages"; var catPackages = "##REPLACE:doclet.search.packages##";
var catTypes = "Types"; var catTypes = "##REPLACE:doclet.search.types##";
var catMembers = "Members"; var catMembers = "##REPLACE:doclet.search.members##";
var catSearchTags = "SearchTags"; var catSearchTags = "##REPLACE:doclet.search.search_tags##";
var highlight = "<span class=\"result-highlight\">$&</span>"; var highlight = "<span class=\"result-highlight\">$&</span>";
var searchPattern = ""; var searchPattern = "";
var fallbackPattern = ""; var fallbackPattern = "";

View file

@ -333,3 +333,11 @@ doclet.record_field_doc.fullbody=\
doclet.platform.docs.old=https://docs.oracle.com/javase/{0}/docs/api/ doclet.platform.docs.old=https://docs.oracle.com/javase/{0}/docs/api/
doclet.platform.docs.new=https://docs.oracle.com/en/java/javase/{0}/docs/api/ doclet.platform.docs.new=https://docs.oracle.com/en/java/javase/{0}/docs/api/
doclet.platform.docs.ea=https://download.java.net/java/early_access/jdk{0}/docs/api/ doclet.platform.docs.ea=https://download.java.net/java/early_access/jdk{0}/docs/api/
doclet.search.no_results=No results found
doclet.search.loading=Loading search index...
doclet.search.modules=Modules
doclet.search.packages=Packages
doclet.search.types=Types
doclet.search.members=Members
doclet.search.search_tags=Search Tags

View file

@ -32,12 +32,17 @@ import java.io.InputStreamReader;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.io.Writer; import java.io.Writer;
import java.util.MissingResourceException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.tools.DocumentationTool;
import javax.tools.FileObject; import javax.tools.FileObject;
import javax.tools.JavaFileManager.Location; import javax.tools.JavaFileManager.Location;
import javax.tools.StandardLocation; import javax.tools.StandardLocation;
import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration; import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
import jdk.javadoc.internal.doclets.toolkit.Resources;
/** /**
* Abstraction for handling files, which may be specified directly * Abstraction for handling files, which may be specified directly
@ -175,10 +180,28 @@ public abstract class DocFile {
* @throws ResourceIOException if there is a problem while reading the resource * @throws ResourceIOException if there is a problem while reading the resource
*/ */
public void copyResource(DocPath resource, boolean overwrite, boolean replaceNewLine) public void copyResource(DocPath resource, boolean overwrite, boolean replaceNewLine)
throws DocFileIOException, ResourceIOException { throws DocFileIOException, ResourceIOException {
if (exists() && !overwrite) if (exists() && !overwrite)
return; return;
copyResource(resource, replaceNewLine, null);
}
/**
* Copy the contents of a resource file to this file.
*
* @param resource the path of the resource, relative to the package of this class
* @param resources if not {@code null}, substitute occurrences of {@code ##REPLACE:key##}
*
* @throws DocFileIOException if there is a problem while writing the copy
* @throws ResourceIOException if there is a problem while reading the resource
*/
public void copyResource(DocPath resource, Resources resources) throws DocFileIOException, ResourceIOException {
copyResource(resource, true, resources);
}
private void copyResource(DocPath resource, boolean replaceNewLine, Resources resources)
throws DocFileIOException, ResourceIOException {
try { try {
InputStream in = BaseConfiguration.class.getResourceAsStream(resource.getPath()); InputStream in = BaseConfiguration.class.getResourceAsStream(resource.getPath());
if (in == null) if (in == null)
@ -190,7 +213,7 @@ public abstract class DocFile {
try (Writer writer = openWriter()) { try (Writer writer = openWriter()) {
String line; String line;
while ((line = readResourceLine(resource, reader)) != null) { while ((line = readResourceLine(resource, reader)) != null) {
write(this, writer, line); write(this, writer, resources == null ? line : localize(line, resources));
write(this, writer, DocletConstants.NL); write(this, writer, DocletConstants.NL);
} }
} catch (IOException e) { } catch (IOException e) {
@ -216,6 +239,32 @@ public abstract class DocFile {
} }
} }
private static final Pattern replacePtn = Pattern.compile("##REPLACE:(?<key>[A-Za-z0-9._]+)##");
private String localize(String line, Resources resources) {
Matcher m = replacePtn.matcher(line);
StringBuilder sb = null;
int start = 0;
while (m.find()) {
if (sb == null) {
sb = new StringBuilder();
}
sb.append(line, start, m.start());
try {
sb.append(resources.getText(m.group("key")));
} catch (MissingResourceException e) {
sb.append(m.group());
}
start = m.end();
}
if (sb == null) {
return line;
} else {
sb.append(line.substring(start));
return sb.toString();
}
}
/** Return true if the file can be read. */ /** Return true if the file can be read. */
public abstract boolean canRead(); public abstract boolean canRead();
@ -279,11 +328,12 @@ public abstract class DocFile {
/** /**
* Reads from an input stream opened from a given file into a given buffer. * Reads from an input stream opened from a given file into a given buffer.
* If an IOException occurs, it is wrapped in a DocFileIOException. * If an {@code IOException} occurs, it is wrapped in a {@code DocFileIOException}.
* *
* @param inFile the file for the stream * @param inFile the file for the stream
* @param input the stream * @param input the stream
* @param buf the buffer * @param buf the buffer
*
* @return the number of bytes read, or -1 if at end of file * @return the number of bytes read, or -1 if at end of file
* @throws DocFileIOException if an exception occurred while reading the stream * @throws DocFileIOException if an exception occurred while reading the stream
*/ */
@ -297,11 +347,12 @@ public abstract class DocFile {
/** /**
* Writes to an output stream for a given file from a given buffer. * Writes to an output stream for a given file from a given buffer.
* If an IOException occurs, it is wrapped in a DocFileIOException. * If an {@code IOException} occurs, it is wrapped in a {@code DocFileIOException}.
* *
* @param outFile the file for the stream * @param outFile the file for the stream
* @param out the stream * @param out the stream
* @param buf the buffer * @param buf the buffer
*
* @throws DocFileIOException if an exception occurred while writing the stream * @throws DocFileIOException if an exception occurred while writing the stream
*/ */
private static void write(DocFile outFile, OutputStream out, byte[] buf, int len) throws DocFileIOException { private static void write(DocFile outFile, OutputStream out, byte[] buf, int len) throws DocFileIOException {
@ -314,11 +365,12 @@ public abstract class DocFile {
/** /**
* Writes text to an output stream for a given file from a given buffer. * Writes text to an output stream for a given file from a given buffer.
* If an IOException occurs, it is wrapped in a DocFileIOException. * If an {@code IOException} occurs, it is wrapped in a {@code DocFileIOException}.
* *
* @param outFile the file for the stream * @param outFile the file for the stream
* @param out the stream * @param out the stream
* @param text the text to be written * @param text the text to be written
*
* @throws DocFileIOException if an exception occurred while writing the stream * @throws DocFileIOException if an exception occurred while writing the stream
*/ */
private static void write(DocFile outFile, Writer out, String text) throws DocFileIOException { private static void write(DocFile outFile, Writer out, String text) throws DocFileIOException {
@ -331,28 +383,30 @@ public abstract class DocFile {
/** /**
* Reads from an input stream opened from a given resource into a given buffer. * Reads from an input stream opened from a given resource into a given buffer.
* If an IOException occurs, it is wrapped in a ResourceIOException. * If an {@code IOException} occurs, it is wrapped in a {@code ResourceIOException}.
*
* @param docPath the resource for the stream
* @param in the stream
* @param buf the buffer
* *
* @param resource the resource for the stream
* @param in the stream
* @param buf the buffer
* @return the number of bytes read, or -1 if at end of file * @return the number of bytes read, or -1 if at end of file
* @throws ResourceIOException if an exception occurred while reading the stream * @throws ResourceIOException if an exception occurred while reading the stream
*/ */
private static int readResource(DocPath resource, InputStream in, byte[] buf) throws ResourceIOException { private static int readResource(DocPath docPath, InputStream in, byte[] buf) throws ResourceIOException {
try { try {
return in.read(buf); return in.read(buf);
} catch (IOException e) { } catch (IOException e) {
throw new ResourceIOException(resource, e); throw new ResourceIOException(docPath, e);
} }
} }
/** /**
* Reads a line of characters from an input stream opened from a given resource. * Reads a line of characters from an input stream opened from a given resource.
* If an IOException occurs, it is wrapped in a ResourceIOException. * If an {@code IOException} occurs, it is wrapped in a {@code ResourceIOException}.
*
* @param docPath the resource for the stream
* @param in the stream
* *
* @param resource the resource for the stream
* @param in the stream
* @return the line of text, or {@code null} if at end of stream * @return the line of text, or {@code null} if at end of stream
* @throws ResourceIOException if an exception occurred while reading the stream * @throws ResourceIOException if an exception occurred while reading the stream
*/ */

View file

@ -275,6 +275,9 @@ public class DocPaths {
/** The name of the search javascript file. */ /** The name of the search javascript file. */
public static final DocPath SEARCH_JS = DocPath.create("search.js"); public static final DocPath SEARCH_JS = DocPath.create("search.js");
/** The name of the template for the search javascript file. */
public static final DocPath SEARCH_JS_TEMPLATE = DocPath.create("search.js.template");
/** The name of the file for the serialized form info. */ /** The name of the file for the serialized form info. */
public static final DocPath SERIALIZED_FORM = DocPath.create("serialized-form.html"); public static final DocPath SERIALIZED_FORM = DocPath.create("serialized-form.html");

View file

@ -222,6 +222,10 @@ public final class EventWriter {
notified = false; notified = false;
} }
private void resetStringPool() {
StringPool.reset();
}
private int usedSize() { private int usedSize() {
return (int) (currentPosition - startPosition); return (int) (currentPosition - startPosition);
} }
@ -273,6 +277,7 @@ public final class EventWriter {
if (isNotified()) { if (isNotified()) {
resetNotified(); resetNotified();
resetStringPool();
reset(); reset();
// returning false will trigger restart of the event write attempt // returning false will trigger restart of the event write attempt
return false; return false;

View file

@ -488,18 +488,9 @@ public final class JVM {
* *
* @param s string constant to be added, not null * @param s string constant to be added, not null
* *
* @return the current epoch of this insertion attempt * @return true, if the string was successfully added.
*/ */
public static native boolean addStringConstant(boolean epoch, long id, String s); public static native boolean addStringConstant(long id, String s);
/**
* Gets the address of the jboolean epoch.
*
* The epoch alternates every checkpoint.
*
* @return The address of the jboolean.
*/
public native long getEpochAddress();
public native void uncaughtException(Thread thread, Throwable t); public native void uncaughtException(Thread thread, Throwable t);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -27,31 +27,23 @@ package jdk.jfr.internal;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import jdk.internal.misc.Unsafe;
public final class StringPool { public final class StringPool {
private static final Unsafe unsafe = Unsafe.getUnsafe();
static final int MIN_LIMIT = 16; static final int MIN_LIMIT = 16;
static final int MAX_LIMIT = 128; /* 0 MAX means disabled */ static final int MAX_LIMIT = 128; /* 0 MAX means disabled */
private static final long epochAddress; private static final long DO_NOT_POOL = -1;
private static final SimpleStringIdPool sp = new SimpleStringIdPool(); private static final SimpleStringIdPool sp = new SimpleStringIdPool();
static {
epochAddress = JVM.getJVM().getEpochAddress(); static long addString(String s) {
sp.reset();
}
public static long addString(String s) {
return sp.addString(s); return sp.addString(s);
} }
private static boolean getCurrentEpoch() {
return unsafe.getByte(epochAddress) == 1; static void reset() {
sp.reset();
} }
private static class SimpleStringIdPool { private static class SimpleStringIdPool {
/* string id index */ /* string id index */
private final AtomicLong sidIdx = new AtomicLong(1); private final AtomicLong sidIdx = new AtomicLong(1);
/* epoch of cached strings */
private boolean poolEpoch;
/* the cache */ /* the cache */
private final ConcurrentHashMap<String, Long> cache; private final ConcurrentHashMap<String, Long> cache;
/* max size */ /* max size */
@ -60,7 +52,6 @@ public final class StringPool {
private final long MAX_SIZE_UTF16 = 16*1024*1024; private final long MAX_SIZE_UTF16 = 16*1024*1024;
/* max size bytes*/ /* max size bytes*/
private long currentSizeUTF16; private long currentSizeUTF16;
/* looking at a biased data set 4 is a good value */ /* looking at a biased data set 4 is a good value */
private final String[] preCache = new String[]{"", "" , "" ,""}; private final String[] preCache = new String[]{"", "" , "" ,""};
/* index of oldest */ /* index of oldest */
@ -69,35 +60,28 @@ public final class StringPool {
private static final int preCacheMask = 0x03; private static final int preCacheMask = 0x03;
SimpleStringIdPool() { SimpleStringIdPool() {
cache = new ConcurrentHashMap<>(MAX_SIZE, 0.75f); this.cache = new ConcurrentHashMap<>(MAX_SIZE, 0.75f);
} }
void reset() {
reset(getCurrentEpoch()); private void reset() {
}
private void reset(boolean epoch) {
this.cache.clear(); this.cache.clear();
this.poolEpoch = epoch; synchronized(SimpleStringIdPool.class) {
this.currentSizeUTF16 = 0; this.currentSizeUTF16 = 0;
}
} }
private long addString(String s) { private long addString(String s) {
boolean currentEpoch = getCurrentEpoch(); Long lsid = this.cache.get(s);
if (poolEpoch == currentEpoch) { if (lsid != null) {
/* pool is for current chunk */ return lsid.longValue();
Long lsid = this.cache.get(s);
if (lsid != null) {
return lsid.longValue();
}
} else {
/* pool is for an old chunk */
reset(currentEpoch);
} }
if (!preCache(s)) { if (!preCache(s)) {
/* we should not pool this string */ /* we should not pool this string */
return -1; return DO_NOT_POOL;
} }
if (cache.size() > MAX_SIZE || currentSizeUTF16 > MAX_SIZE_UTF16) { if (cache.size() > MAX_SIZE || currentSizeUTF16 > MAX_SIZE_UTF16) {
/* pool was full */ /* pool was full */
reset(currentEpoch); reset();
} }
return storeString(s); return storeString(s);
} }
@ -106,14 +90,13 @@ public final class StringPool {
long sid = this.sidIdx.getAndIncrement(); long sid = this.sidIdx.getAndIncrement();
/* we can race but it is ok */ /* we can race but it is ok */
this.cache.put(s, sid); this.cache.put(s, sid);
boolean currentEpoch;
synchronized(SimpleStringIdPool.class) { synchronized(SimpleStringIdPool.class) {
currentEpoch = JVM.addStringConstant(poolEpoch, sid, s); JVM.addStringConstant(sid, s);
currentSizeUTF16 += s.length(); currentSizeUTF16 += s.length();
} }
/* did we write in chunk that this pool represent */ return sid;
return currentEpoch == poolEpoch ? sid : -1;
} }
private boolean preCache(String s) { private boolean preCache(String s) {
if (preCache[0].equals(s)) { if (preCache[0].equals(s)) {
return true; return true;

View file

@ -26,10 +26,10 @@
* @bug 6340864 * @bug 6340864
* @summary Implement vectorization optimizations in hotspot-server * @summary Implement vectorization optimizations in hotspot-server
* *
* @run main/othervm/timeout=400 -Xbatch -Xmx128m compiler.c2.cr6340864.TestByteVect * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m compiler.c2.cr6340864.TestByteVect
* @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=8 compiler.c2.cr6340864.TestByteVect * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=8 compiler.c2.cr6340864.TestByteVect
* @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=16 compiler.c2.cr6340864.TestByteVect * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=16 compiler.c2.cr6340864.TestByteVect
* @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=32 compiler.c2.cr6340864.TestByteVect * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=32 compiler.c2.cr6340864.TestByteVect
*/ */
package compiler.c2.cr6340864; package compiler.c2.cr6340864;

View file

@ -26,10 +26,10 @@
* @bug 6340864 * @bug 6340864
* @summary Implement vectorization optimizations in hotspot-server * @summary Implement vectorization optimizations in hotspot-server
* *
* @run main/othervm/timeout=400 -Xbatch -Xmx128m compiler.c2.cr6340864.TestDoubleVect * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m compiler.c2.cr6340864.TestDoubleVect
* @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=8 compiler.c2.cr6340864.TestDoubleVect * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=8 compiler.c2.cr6340864.TestDoubleVect
* @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=16 compiler.c2.cr6340864.TestDoubleVect * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=16 compiler.c2.cr6340864.TestDoubleVect
* @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=32 compiler.c2.cr6340864.TestDoubleVect * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=32 compiler.c2.cr6340864.TestDoubleVect
*/ */
package compiler.c2.cr6340864; package compiler.c2.cr6340864;

View file

@ -26,10 +26,10 @@
* @bug 6340864 * @bug 6340864
* @summary Implement vectorization optimizations in hotspot-server * @summary Implement vectorization optimizations in hotspot-server
* *
* @run main/othervm/timeout=400 -Xbatch -Xmx128m compiler.c2.cr6340864.TestFloatVect * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m compiler.c2.cr6340864.TestFloatVect
* @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=8 compiler.c2.cr6340864.TestFloatVect * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=8 compiler.c2.cr6340864.TestFloatVect
* @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=16 compiler.c2.cr6340864.TestFloatVect * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=16 compiler.c2.cr6340864.TestFloatVect
* @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=32 compiler.c2.cr6340864.TestFloatVect * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=32 compiler.c2.cr6340864.TestFloatVect
*/ */
package compiler.c2.cr6340864; package compiler.c2.cr6340864;

View file

@ -26,11 +26,11 @@
* @bug 6340864 * @bug 6340864
* @summary Implement vectorization optimizations in hotspot-server * @summary Implement vectorization optimizations in hotspot-server
* *
* @run main/othervm/timeout=400 -Xbatch -Xmx128m compiler.c2.cr6340864.TestIntVect * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m compiler.c2.cr6340864.TestIntVect
* @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=8 compiler.c2.cr6340864.TestIntVect * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=8 compiler.c2.cr6340864.TestIntVect
* @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=16 compiler.c2.cr6340864.TestIntVect * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=16 compiler.c2.cr6340864.TestIntVect
* @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=32 compiler.c2.cr6340864.TestIntVect * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=32 compiler.c2.cr6340864.TestIntVect
* @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:+IgnoreUnrecognizedVMOptions -XX:UseAVX=3 compiler.c2.cr6340864.TestIntVect * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:+IgnoreUnrecognizedVMOptions -XX:UseAVX=3 compiler.c2.cr6340864.TestIntVect
*/ */
package compiler.c2.cr6340864; package compiler.c2.cr6340864;

View file

@ -26,11 +26,11 @@
* @bug 8248830 * @bug 8248830
* @summary Implement Rotate vectorization optimizations in hotspot-server * @summary Implement Rotate vectorization optimizations in hotspot-server
* *
* @run main/othervm/timeout=400 -Xbatch -Xmx128m compiler.c2.cr6340864.TestIntVectRotate * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m compiler.c2.cr6340864.TestIntVectRotate
* @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=8 compiler.c2.cr6340864.TestIntVectRotate * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=8 compiler.c2.cr6340864.TestIntVectRotate
* @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=16 compiler.c2.cr6340864.TestIntVectRotate * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=16 compiler.c2.cr6340864.TestIntVectRotate
* @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=32 compiler.c2.cr6340864.TestIntVectRotate * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=32 compiler.c2.cr6340864.TestIntVectRotate
* @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:+IgnoreUnrecognizedVMOptions -XX:UseAVX=3 compiler.c2.cr6340864.TestIntVectRotate * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:+IgnoreUnrecognizedVMOptions -XX:UseAVX=3 compiler.c2.cr6340864.TestIntVectRotate
*/ */
package compiler.c2.cr6340864; package compiler.c2.cr6340864;

View file

@ -26,11 +26,11 @@
* @bug 6340864 * @bug 6340864
* @summary Implement vectorization optimizations in hotspot-server * @summary Implement vectorization optimizations in hotspot-server
* *
* @run main/othervm/timeout=400 -Xbatch -Xmx128m compiler.c2.cr6340864.TestLongVect * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m compiler.c2.cr6340864.TestLongVect
* @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=8 compiler.c2.cr6340864.TestLongVect * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=8 compiler.c2.cr6340864.TestLongVect
* @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=16 compiler.c2.cr6340864.TestLongVect * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=16 compiler.c2.cr6340864.TestLongVect
* @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=32 compiler.c2.cr6340864.TestLongVect * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=32 compiler.c2.cr6340864.TestLongVect
* @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:+IgnoreUnrecognizedVMOptions -XX:UseAVX=3 compiler.c2.cr6340864.TestLongVect * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:+IgnoreUnrecognizedVMOptions -XX:UseAVX=3 compiler.c2.cr6340864.TestLongVect
*/ */
package compiler.c2.cr6340864; package compiler.c2.cr6340864;

View file

@ -26,11 +26,11 @@
* @bug 8248830 * @bug 8248830
* @summary Implement Rotate vectorization optimizations in hotspot-server * @summary Implement Rotate vectorization optimizations in hotspot-server
* *
* @run main/othervm/timeout=400 -Xbatch -Xmx128m compiler.c2.cr6340864.TestLongVectRotate * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m compiler.c2.cr6340864.TestLongVectRotate
* @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=8 compiler.c2.cr6340864.TestLongVectRotate * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=8 compiler.c2.cr6340864.TestLongVectRotate
* @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=16 compiler.c2.cr6340864.TestLongVectRotate * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=16 compiler.c2.cr6340864.TestLongVectRotate
* @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=32 compiler.c2.cr6340864.TestLongVectRotate * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=32 compiler.c2.cr6340864.TestLongVectRotate
* @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:+IgnoreUnrecognizedVMOptions -XX:UseAVX=3 compiler.c2.cr6340864.TestLongVectRotate * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:+IgnoreUnrecognizedVMOptions -XX:UseAVX=3 compiler.c2.cr6340864.TestLongVectRotate
*/ */
package compiler.c2.cr6340864; package compiler.c2.cr6340864;

View file

@ -26,10 +26,10 @@
* @bug 6340864 * @bug 6340864
* @summary Implement vectorization optimizations in hotspot-server * @summary Implement vectorization optimizations in hotspot-server
* *
* @run main/othervm/timeout=400 -Xbatch -Xmx128m compiler.c2.cr6340864.TestShortVect * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m compiler.c2.cr6340864.TestShortVect
* @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=8 compiler.c2.cr6340864.TestShortVect * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=8 compiler.c2.cr6340864.TestShortVect
* @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=16 compiler.c2.cr6340864.TestShortVect * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=16 compiler.c2.cr6340864.TestShortVect
* @run main/othervm/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=32 compiler.c2.cr6340864.TestShortVect * @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=32 compiler.c2.cr6340864.TestShortVect
*/ */
package compiler.c2.cr6340864; package compiler.c2.cr6340864;

View file

@ -28,7 +28,7 @@
* @summary Verify that zero check is executed before division/modulo operation. * @summary Verify that zero check is executed before division/modulo operation.
* @requires vm.compiler2.enabled * @requires vm.compiler2.enabled
* @run main/othervm -Xcomp -XX:-TieredCompilation -XX:CompileOnly=compiler/loopopts/TestDivZeroWithSplitIf::test * @run main/othervm -Xcomp -XX:-TieredCompilation -XX:CompileOnly=compiler/loopopts/TestDivZeroWithSplitIf::test
* -XX:+StressGCM -XX:StressSeed=873732072 compiler.loopopts.TestDivZeroWithSplitIf * -XX:+UnlockDiagnosticVMOptions -XX:+StressGCM -XX:StressSeed=873732072 compiler.loopopts.TestDivZeroWithSplitIf
*/ */
package compiler.loopopts; package compiler.loopopts;

View file

@ -832,7 +832,6 @@ javax/script/Test7.java 8239361 generic-
# jdk_jfr # jdk_jfr
jdk/jfr/api/recording/event/TestReEnableName.java 8256482 windows-all
jdk/jfr/event/runtime/TestNetworkUtilizationEvent.java 8228990,8229370 generic-all jdk/jfr/event/runtime/TestNetworkUtilizationEvent.java 8228990,8229370 generic-all
jdk/jfr/event/compiler/TestCodeSweeper.java 8225209 generic-all jdk/jfr/event/compiler/TestCodeSweeper.java 8225209 generic-all
jdk/jfr/event/os/TestThreadContextSwitches.java 8247776 windows-all jdk/jfr/event/os/TestThreadContextSwitches.java 8247776 windows-all

View file

@ -126,7 +126,11 @@ public class RuntimePackageTest {
private static Set<Path> listFiles(Path root) throws IOException { private static Set<Path> listFiles(Path root) throws IOException {
try (var files = Files.walk(root)) { try (var files = Files.walk(root)) {
return files.map(root::relativize).collect(Collectors.toSet()); // Ignore files created by system prefs if any.
final Path prefsDir = Path.of(".systemPrefs");
return files.map(root::relativize)
.filter(x -> !x.startsWith(prefsDir))
.collect(Collectors.toSet());
} }
} }

View file

@ -25,7 +25,7 @@
* @test * @test
* @bug 8141492 8071982 8141636 8147890 8166175 8168965 8176794 8175218 8147881 * @bug 8141492 8071982 8141636 8147890 8166175 8168965 8176794 8175218 8147881
* 8181622 8182263 8074407 8187521 8198522 8182765 8199278 8196201 8196202 * 8181622 8182263 8074407 8187521 8198522 8182765 8199278 8196201 8196202
* 8184205 8214468 8222548 8223378 8234746 8241219 8254627 * 8184205 8214468 8222548 8223378 8234746 8241219 8254627 8247994
* @summary Test the search feature of javadoc. * @summary Test the search feature of javadoc.
* @library ../../lib * @library ../../lib
* @modules jdk.javadoc/jdk.javadoc.internal.tool * @modules jdk.javadoc/jdk.javadoc.internal.tool
@ -711,6 +711,10 @@ public class TestSearch extends JavadocTester {
} }
void checkSearchJS() { void checkSearchJS() {
// ensure all resource keys were resolved
checkOutput("search.js", false,
"##REPLACE:");
checkOutput("search.js", true, checkOutput("search.js", true,
"function searchIndexWithMatcher(indexArray, matcher, category, nameFunc) {", "function searchIndexWithMatcher(indexArray, matcher, category, nameFunc) {",
""" """

View file

@ -23,7 +23,7 @@
/* /*
* @test * @test
* @bug 8000612 8254627 * @bug 8000612 8254627 8247994
* @summary need test program to validate javadoc resource bundles * @summary need test program to validate javadoc resource bundles
* @modules jdk.javadoc/jdk.javadoc.internal.tool * @modules jdk.javadoc/jdk.javadoc.internal.tool
* jdk.javadoc/jdk.javadoc.internal.doclets.formats.html.resources:open * jdk.javadoc/jdk.javadoc.internal.doclets.formats.html.resources:open
@ -34,6 +34,8 @@
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.tools.*; import javax.tools.*;
import com.sun.tools.classfile.*; import com.sun.tools.classfile.*;
@ -200,6 +202,17 @@ public class CheckResourceKeys {
} }
} }
// special handling for strings in search.js.template
FileObject fo = fm.getFileForInput(javadocLoc,
"jdk.javadoc.internal.doclets.formats.html",
"resources/search.js.template");
CharSequence search_js = fo.getCharContent(true);
Pattern p = Pattern.compile("##REPLACE:(?<key>[A-Za-z0-9._]+)##");
Matcher m = p.matcher(search_js);
while (m.find()) {
results.add(m.group("key"));
}
// special handling for code strings synthesized in // special handling for code strings synthesized in
// jdk.javadoc.internal.doclets.toolkit.util.Utils.getTypeName // jdk.javadoc.internal.doclets.toolkit.util.Utils.getTypeName
String[] extras = { String[] extras = {

View file

@ -0,0 +1,29 @@
/*
* Copyright (c) 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
* 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 8254023
* @summary A module declaration is not allowed to be a target of an annotation that lacks an (at)Target meta-annotation
* @compile module-info.java test/A.java
*/

View file

@ -0,0 +1,25 @@
/*
* Copyright (c) 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
* 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.A
module test { }

View file

@ -0,0 +1,26 @@
/*
* Copyright (c) 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
* 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.
*/
package test;
public @interface A { }

View file

@ -23,7 +23,7 @@
/** /**
* @test * @test
* @bug 8133884 8162711 8133896 8172158 8172262 8173636 8175119 8189747 8236842 * @bug 8133884 8162711 8133896 8172158 8172262 8173636 8175119 8189747 8236842 8254023
* @summary Verify that annotation processing works. * @summary Verify that annotation processing works.
* @library /tools/lib * @library /tools/lib
* @modules * @modules
@ -517,6 +517,66 @@ public class AnnotationProcessing extends ModuleTestBase {
} }
@Test
public void testAnnotationsWithoutTargetInModuleInfo(Path base) throws Exception {
Path moduleSrc = base.resolve("module-src");
Path m1 = moduleSrc.resolve("m1");
tb.writeJavaFiles(m1,
"@test.A module m1x { exports test; }",
"package test; public @interface A { }",
"package test; public @interface B { }");
Path classes = base.resolve("classes");
Files.createDirectories(classes);
List<String> expectedLog = List.of("Note: m1x/test.A AP Invoked",
"Note: m1x/test.A AP Invoked");
List<String> actualLog = new JavacTask(tb)
.options("-processor", AnnotationsWithoutTargetInModuleInfo.class.getName()
+ "," + AnnotationsWithoutTargetNotInModuleInfo.class.getName())
.outdir(classes)
.files(findJavaFiles(m1))
.run()
.writeAll()
.getOutputLines(Task.OutputKind.DIRECT);
tb.checkEqual(expectedLog, actualLog);
}
@SupportedAnnotationTypes("m1x/test.A")
public static final class AnnotationsWithoutTargetInModuleInfo extends AbstractProcessor {
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
processingEnv.getMessager().printMessage(Kind.NOTE, "m1x/test.A AP Invoked");
return false;
}
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latest();
}
}
@SupportedAnnotationTypes("m1x/test.B")
public static final class AnnotationsWithoutTargetNotInModuleInfo extends AbstractProcessor {
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
processingEnv.getMessager().printMessage(Kind.NOTE, "m1x/test.B AP Invoked");
return false;
}
@Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latest();
}
}
@Test @Test
public void testGenerateInMultiModeAPI(Path base) throws Exception { public void testGenerateInMultiModeAPI(Path base) throws Exception {
Path moduleSrc = base.resolve("module-src"); Path moduleSrc = base.resolve("module-src");

View file

@ -23,7 +23,7 @@
/* /*
* @test * @test
* @bug 8159602 8170549 8171255 8171322 * @bug 8159602 8170549 8171255 8171322 8254023
* @summary Test annotations on module declaration. * @summary Test annotations on module declaration.
* @library /tools/lib * @library /tools/lib
* @modules jdk.compiler/com.sun.tools.javac.api * @modules jdk.compiler/com.sun.tools.javac.api
@ -51,6 +51,7 @@ import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.ModuleElement; import javax.lang.model.element.ModuleElement;
import javax.lang.model.element.TypeElement; import javax.lang.model.element.TypeElement;
import com.sun.tools.classfile.Annotation;
import com.sun.tools.classfile.Attribute; import com.sun.tools.classfile.Attribute;
import com.sun.tools.classfile.ClassFile; import com.sun.tools.classfile.ClassFile;
import com.sun.tools.classfile.RuntimeInvisibleAnnotations_attribute; import com.sun.tools.classfile.RuntimeInvisibleAnnotations_attribute;
@ -410,6 +411,42 @@ public class AnnotationsOnModules extends ModuleTestBase {
} }
@Test
public void testAnnotationWithoutTarget(Path base) throws Exception {
Path moduleSrc = base.resolve("module-src");
Path m1 = moduleSrc.resolve("m1x");
tb.writeJavaFiles(m1,
"@test.A module m1x { exports test; }",
"package test; public @interface A { }");
Path classes = base.resolve("classes");
Files.createDirectories(classes);
new JavacTask(tb)
.options("--module-source-path", moduleSrc.toString())
.outdir(classes)
.files(findJavaFiles(m1))
.run()
.writeAll();
ClassFile cf = ClassFile.read(classes.resolve("m1x").resolve("module-info.class"));
var invisibleAnnotations = (RuntimeInvisibleAnnotations_attribute) cf.attributes.map.get(Attribute.RuntimeInvisibleAnnotations);
if (invisibleAnnotations == null) {
throw new AssertionError("Annotations not found!");
}
int length = invisibleAnnotations.annotations.length;
if (length != 1) {
throw new AssertionError("Incorrect number of annotations: " + length);
}
Annotation annotation = invisibleAnnotations.annotations[0];
String annotationName = cf.constant_pool.getUTF8Value(annotation.type_index).toString();
if (!"Ltest/A;".equals(annotationName)) {
throw new AssertionError("Incorrect annotation name: " + annotationName);
}
}
@Test @Test
public void testModuleInfoAnnotationsInAPI(Path base) throws Exception { public void testModuleInfoAnnotationsInAPI(Path base) throws Exception {
Path moduleSrc = base.resolve("module-src"); Path moduleSrc = base.resolve("module-src");

View file

@ -1027,6 +1027,110 @@ public class RecordCompilationTests extends CompilationTestCase {
"""); """);
} }
public void testAnnoInsideLocalOrAnonymous() {
assertFail("compiler.err.annotation.decl.not.allowed.here",
"""
class Outer {
public void test() {
class Local {
@interface A {}
}
}
}
""");
assertFail("compiler.err.annotation.decl.not.allowed.here",
"""
class Outer {
public void test() {
interface I {
@interface A {}
}
}
}
""");
assertFail("compiler.err.annotation.decl.not.allowed.here",
"""
class Outer {
public void test() {
record R() {
@interface A {}
}
}
}
""");
assertFail("compiler.err.annotation.decl.not.allowed.here",
"""
class Outer {
public void test() {
enum E {
E1;
@interface A {}
}
}
}
""");
assertFail("compiler.err.annotation.decl.not.allowed.here",
"""
class Outer {
public void test() {
class Local1 {
class Local2 {
@interface A {}
}
}
}
}
""");
assertFail("compiler.err.annotation.decl.not.allowed.here",
"""
class Outer {
public void test() {
class Local {
interface I {
@interface A {}
}
}
}
}
""");
assertFail("compiler.err.annotation.decl.not.allowed.here",
"""
class Outer {
public void test() {
class Local {
record R() {
@interface A {}
}
}
}
}
""");
assertFail("compiler.err.annotation.decl.not.allowed.here",
"""
class Outer {
public void test() {
class Local {
enum E {
E1;
@interface A {}
}
}
}
}
""");
assertFail("compiler.err.annotation.decl.not.allowed.here",
"""
class Outer {
Runnable run = new Runnable() {
@interface A {}
public void run() {}
};
}
""");
}
public void testReceiverParameter() { public void testReceiverParameter() {
assertFail("compiler.err.receiver.parameter.not.applicable.constructor.toplevel.class", assertFail("compiler.err.receiver.parameter.not.applicable.constructor.toplevel.class",
""" """