Merge
This commit is contained in:
commit
f15528eb64
@ -74,7 +74,7 @@ define SetupInterimModule
|
||||
EXCLUDE_FILES := $(TOPDIR)/src/$1/share/classes/module-info.java \
|
||||
Standard.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, \
|
||||
DISABLED_WARNINGS := module options, \
|
||||
JAVAC_FLAGS := \
|
||||
|
@ -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
|
||||
|
||||
################################################################################
|
||||
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "logging/log.hpp"
|
||||
#include "oops/oop.inline.hpp"
|
||||
#include "runtime/java.hpp"
|
||||
#include "runtime/orderAccess.hpp"
|
||||
#include "utilities/align.hpp"
|
||||
|
||||
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() ?
|
||||
&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,
|
||||
SpaceDecorator::DontClear,
|
||||
SpaceDecorator::DontMangle,
|
||||
|
@ -160,10 +160,6 @@ NO_TRANSITION(jboolean, jfr_is_available(JNIEnv* env, jclass jvm))
|
||||
return !Jfr::is_disabled() ? JNI_TRUE : JNI_FALSE;
|
||||
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))
|
||||
return JfrKlassUnloading::event_class_count();
|
||||
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);
|
||||
JVM_END
|
||||
|
||||
JVM_ENTRY_NO_ENV(jboolean, jfr_add_string_constant(JNIEnv* env, jclass jvm, jboolean epoch, jlong id, jstring string))
|
||||
return JfrStringPool::add(epoch == JNI_TRUE, id, string, thread) ? JNI_TRUE : JNI_FALSE;
|
||||
JVM_ENTRY_NO_ENV(jboolean, jfr_add_string_constant(JNIEnv* env, jclass jvm, jlong id, jstring string))
|
||||
return JfrStringPool::add(id, string, thread);
|
||||
JVM_END
|
||||
|
||||
JVM_ENTRY_NO_ENV(void, jfr_set_force_instrumentation(JNIEnv* env, jobject jvm, jboolean force_instrumentation))
|
||||
|
@ -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_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, jboolean epoch, jlong id, jstring string);
|
||||
jboolean JNICALL jfr_add_string_constant(JNIEnv* env, jclass jvm, jlong id, jstring string);
|
||||
|
||||
void JNICALL jfr_uncaught_exception(JNIEnv* env, jobject jvm, jobject thread, jthrowable throwable);
|
||||
|
||||
|
@ -75,8 +75,7 @@ JfrJniMethodRegistration::JfrJniMethodRegistration(JNIEnv* env) {
|
||||
(char*)"flush", (char*)"()V", (void*)jfr_flush,
|
||||
(char*)"setRepositoryLocation", (char*)"(Ljava/lang/String;)V", (void*)jfr_set_repository_location,
|
||||
(char*)"abort", (char*)"(Ljava/lang/String;)V", (void*)jfr_abort,
|
||||
(char*)"getEpochAddress", (char*)"()J",(void*)jfr_get_epoch_address,
|
||||
(char*)"addStringConstant", (char*)"(ZJLjava/lang/String;)Z", (void*)jfr_add_string_constant,
|
||||
(char*)"addStringConstant", (char*)"(JLjava/lang/String;)Z", (void*)jfr_add_string_constant,
|
||||
(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*)"getUnloadedEventClassCount", (char*)"()J", (void*)jfr_get_unloaded_event_classes_count,
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "jfr/utilities/jfrBigEndian.hpp"
|
||||
#include "jfr/utilities/jfrIterator.hpp"
|
||||
#include "jfr/utilities/jfrLinkedList.inline.hpp"
|
||||
#include "jfr/utilities/jfrSignal.hpp"
|
||||
#include "jfr/utilities/jfrThreadIterator.hpp"
|
||||
#include "jfr/utilities/jfrTypes.hpp"
|
||||
#include "jfr/writers/jfrJavaEventWriter.hpp"
|
||||
@ -57,22 +58,7 @@
|
||||
|
||||
typedef JfrCheckpointManager::BufferPtr BufferPtr;
|
||||
|
||||
static volatile bool constant_pending = false;
|
||||
|
||||
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 JfrSignal _new_checkpoint;
|
||||
static JfrCheckpointManager* _instance = NULL;
|
||||
|
||||
JfrCheckpointManager& JfrCheckpointManager::instance() {
|
||||
@ -231,7 +217,7 @@ BufferPtr JfrCheckpointManager::flush(BufferPtr old, size_t used, size_t request
|
||||
// indicates a lease is being returned
|
||||
release(old);
|
||||
// signal completion of a new checkpoint
|
||||
set_constant_pending();
|
||||
_new_checkpoint.signal();
|
||||
return NULL;
|
||||
}
|
||||
BufferPtr new_buffer = lease(old, thread, used + requested);
|
||||
@ -474,7 +460,7 @@ size_t JfrCheckpointManager::flush_type_set() {
|
||||
elements = ::flush_type_set(thread);
|
||||
}
|
||||
}
|
||||
if (is_constant_pending()) {
|
||||
if (_new_checkpoint.is_signaled()) {
|
||||
WriteOperation wo(_chunkwriter);
|
||||
MutexedWriteOperation mwo(wo);
|
||||
_thread_local_mspace->iterate(mwo); // current epoch list
|
||||
|
@ -26,9 +26,9 @@
|
||||
#include "jfr/recorder/checkpoint/types/traceid/jfrTraceIdEpoch.hpp"
|
||||
#include "runtime/safepoint.hpp"
|
||||
|
||||
JfrSignal JfrTraceIdEpoch::_tag_state;
|
||||
bool JfrTraceIdEpoch::_epoch_state = false;
|
||||
bool JfrTraceIdEpoch::_synchronizing = false;
|
||||
volatile bool JfrTraceIdEpoch::_changed_tag_state = false;
|
||||
|
||||
void JfrTraceIdEpoch::begin_epoch_shift() {
|
||||
assert(SafepointSynchronize::is_at_safepoint(), "invariant");
|
||||
@ -43,3 +43,4 @@ void JfrTraceIdEpoch::end_epoch_shift() {
|
||||
OrderAccess::storestore();
|
||||
_synchronizing = false;
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
#ifndef 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 "memory/allocation.hpp"
|
||||
#include "runtime/atomic.hpp"
|
||||
@ -54,21 +55,13 @@
|
||||
class JfrTraceIdEpoch : AllStatic {
|
||||
friend class JfrCheckpointManager;
|
||||
private:
|
||||
static JfrSignal _tag_state;
|
||||
static bool _epoch_state;
|
||||
static bool _synchronizing;
|
||||
static volatile bool _changed_tag_state;
|
||||
|
||||
static void begin_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:
|
||||
static bool epoch() {
|
||||
return _epoch_state;
|
||||
@ -115,17 +108,11 @@ class JfrTraceIdEpoch : AllStatic {
|
||||
}
|
||||
|
||||
static bool has_changed_tag_state() {
|
||||
if (changed_tag_state()) {
|
||||
set_tag_state(false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return _tag_state.is_signaled();
|
||||
}
|
||||
|
||||
static void set_changed_tag_state() {
|
||||
if (!changed_tag_state()) {
|
||||
set_tag_state(true);
|
||||
}
|
||||
_tag_state.signal();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -314,9 +314,7 @@ static size_t write_storage(JfrStorage& storage, JfrChunkWriter& chunkwriter) {
|
||||
}
|
||||
|
||||
typedef Content<JfrStringPool, &JfrStringPool::write> StringPool;
|
||||
typedef Content<JfrStringPool, &JfrStringPool::write_at_safepoint> StringPoolSafepoint;
|
||||
typedef WriteCheckpointEvent<StringPool> WriteStringPool;
|
||||
typedef WriteCheckpointEvent<StringPoolSafepoint> WriteStringPoolSafepoint;
|
||||
|
||||
static u4 flush_stringpool(JfrStringPool& string_pool, JfrChunkWriter& chunkwriter) {
|
||||
StringPool sp(string_pool);
|
||||
@ -330,12 +328,6 @@ static u4 write_stringpool(JfrStringPool& string_pool, JfrChunkWriter& chunkwrit
|
||||
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 WriteContent<FlushTypeSetFunctor> FlushTypeSet;
|
||||
|
||||
@ -569,7 +561,7 @@ void JfrRecorderService::safepoint_write() {
|
||||
assert(SafepointSynchronize::is_at_safepoint(), "invariant");
|
||||
_checkpoint_manager.begin_epoch_shift();
|
||||
if (_string_pool.is_modified()) {
|
||||
write_stringpool_safepoint(_string_pool, _chunkwriter);
|
||||
write_stringpool(_string_pool, _chunkwriter);
|
||||
}
|
||||
_checkpoint_manager.on_rotation();
|
||||
_storage.write_at_safepoint();
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "jfr/recorder/stringpool/jfrStringPool.hpp"
|
||||
#include "jfr/recorder/stringpool/jfrStringPoolWriter.hpp"
|
||||
#include "jfr/utilities/jfrLinkedList.inline.hpp"
|
||||
#include "jfr/utilities/jfrSignal.hpp"
|
||||
#include "jfr/utilities/jfrTypes.hpp"
|
||||
#include "logging/log.hpp"
|
||||
#include "runtime/atomic.hpp"
|
||||
@ -40,44 +41,19 @@
|
||||
|
||||
typedef JfrStringPool::BufferPtr BufferPtr;
|
||||
|
||||
static JfrStringPool* _instance = NULL;
|
||||
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;
|
||||
}
|
||||
static JfrSignal _new_string;
|
||||
|
||||
bool JfrStringPool::is_modified() {
|
||||
return increment_serialized_generation();
|
||||
return _new_string.is_signaled();
|
||||
}
|
||||
|
||||
static JfrStringPool* _instance = NULL;
|
||||
|
||||
JfrStringPool& JfrStringPool::instance() {
|
||||
return *_instance;
|
||||
}
|
||||
|
||||
JfrStringPool* JfrStringPool::create(JfrChunkWriter& cw) {
|
||||
store_generation = 0;
|
||||
serialized_generation = 0;
|
||||
assert(_instance == NULL, "invariant");
|
||||
_instance = new JfrStringPool(cw);
|
||||
return _instance;
|
||||
@ -155,20 +131,16 @@ BufferPtr JfrStringPool::lease(Thread* thread, size_t size /* 0 */) {
|
||||
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");
|
||||
const bool current_epoch = JfrTraceIdEpoch::epoch();
|
||||
if (current_epoch != epoch) {
|
||||
return current_epoch;
|
||||
}
|
||||
{
|
||||
JfrStringPoolWriter writer(jt);
|
||||
writer.write(id);
|
||||
writer.write(string);
|
||||
writer.inc_nof_strings();
|
||||
}
|
||||
increment_store_generation();
|
||||
return current_epoch;
|
||||
_new_string.signal();
|
||||
return JNI_TRUE;
|
||||
}
|
||||
|
||||
template <template <typename> class Operation>
|
||||
@ -224,13 +196,7 @@ size_t JfrStringPool::write() {
|
||||
return wo.processed();
|
||||
}
|
||||
|
||||
size_t JfrStringPool::write_at_safepoint() {
|
||||
assert(SafepointSynchronize::is_at_safepoint(), "invariant");
|
||||
return write();
|
||||
}
|
||||
|
||||
size_t JfrStringPool::clear() {
|
||||
increment_serialized_generation();
|
||||
DiscardOperation discard_operation;
|
||||
ExclusiveDiscardOperation edo(discard_operation);
|
||||
assert(_mspace->free_list_is_empty(), "invariant");
|
||||
|
@ -45,10 +45,10 @@ typedef JfrMemorySpace<JfrStringPool, JfrMspaceRetrieval, JfrLinkedList<JfrStrin
|
||||
//
|
||||
class JfrStringPool : public JfrCHeapObj {
|
||||
public:
|
||||
static bool add(bool epoch, jlong id, jstring string, JavaThread* jt);
|
||||
size_t write();
|
||||
size_t write_at_safepoint();
|
||||
size_t clear();
|
||||
static jboolean add(jlong id, jstring string, JavaThread* jt);
|
||||
|
||||
typedef JfrStringPoolMspace::Node Buffer;
|
||||
typedef JfrStringPoolMspace::NodePtr BufferPtr;
|
||||
|
||||
|
51
src/hotspot/share/jfr/utilities/jfrSignal.hpp
Normal file
51
src/hotspot/share/jfr/utilities/jfrSignal.hpp
Normal 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
|
@ -91,8 +91,8 @@ import sun.reflect.misc.ReflectUtil;
|
||||
|
||||
/**
|
||||
* Instances of the class {@code Class} represent classes and
|
||||
* interfaces in a running Java application. An enum type and a record
|
||||
* type are kinds of class; an annotation type is a kind of
|
||||
* interfaces in a running Java application. An enum class and a record
|
||||
* class are kinds of class; an annotation interface is a kind of
|
||||
* 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
|
||||
* element type and number of dimensions. The primitive Java types
|
||||
@ -131,7 +131,7 @@ import sun.reflect.misc.ReflectUtil;
|
||||
* </pre></blockquote>
|
||||
*
|
||||
* 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:
|
||||
*
|
||||
* <blockquote>
|
||||
@ -159,8 +159,8 @@ import sun.reflect.misc.ReflectUtil;
|
||||
* {@link java.lang.invoke.MethodHandles.Lookup#defineHiddenClass(byte[], boolean, MethodHandles.Lookup.ClassOption...)
|
||||
* Lookup::defineHiddenClass} is a {@linkplain Class#isHidden() <em>hidden</em>}
|
||||
* class or interface.
|
||||
* All kinds of class, including enum types and record types, may be
|
||||
* hidden classes; all kinds of interface, including annotation types,
|
||||
* All kinds of class, including enum classes and record classes, may be
|
||||
* hidden classes; all kinds of interface, including annotation interfaces,
|
||||
* may be hidden interfaces.
|
||||
*
|
||||
* 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()) {
|
||||
sb.append('@');
|
||||
}
|
||||
if (isInterface()) { // Note: all annotation types are interfaces
|
||||
if (isInterface()) { // Note: all annotation interfaces are interfaces
|
||||
sb.append("interface");
|
||||
} else {
|
||||
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
|
||||
* type. Note that if this method returns true, {@link #isInterface()}
|
||||
* would also return true, as all annotation types are also interfaces.
|
||||
* interface. Note that if this method returns true, {@link #isInterface()}
|
||||
* would also return true, as all annotation interfaces are also interfaces.
|
||||
*
|
||||
* @return {@code true} if this {@code Class} object represents an annotation
|
||||
* type; {@code false} otherwise
|
||||
* interface; {@code false} otherwise
|
||||
* @since 1.5
|
||||
*/
|
||||
public boolean isAnnotation() {
|
||||
@ -1298,8 +1298,8 @@ public final class Class<T> implements java.io.Serializable,
|
||||
* {@code null} otherwise.
|
||||
*
|
||||
* In particular, this method returns {@code null} if the underlying
|
||||
* class is a local or anonymous class immediately enclosed by a type
|
||||
* declaration, instance initializer or static initializer.
|
||||
* class is a local or anonymous class immediately enclosed by a class or
|
||||
* interface declaration, instance initializer or static initializer.
|
||||
*
|
||||
* @return the immediately enclosing method of the underlying class, if
|
||||
* 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
|
||||
* class. Returns {@code null} otherwise. In particular, this
|
||||
* method returns {@code null} if the underlying class is a local
|
||||
* or anonymous class immediately enclosed by a type declaration,
|
||||
* instance initializer or static initializer.
|
||||
* or anonymous class immediately enclosed by a class or
|
||||
* interface declaration, instance initializer or static initializer.
|
||||
*
|
||||
* @return the immediately enclosing constructor of the underlying class, if
|
||||
* 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
|
||||
*/
|
||||
public String getTypeName() {
|
||||
@ -2371,7 +2371,7 @@ public final class Class<T> implements java.io.Serializable,
|
||||
*
|
||||
* </ul>
|
||||
*
|
||||
* @jls 8.10 Record Types
|
||||
* @jls 8.10 Record Classes
|
||||
* @since 16
|
||||
*/
|
||||
@CallerSensitive
|
||||
@ -2392,14 +2392,14 @@ public final class Class<T> implements java.io.Serializable,
|
||||
* Class} object, including public, protected, default (package)
|
||||
* access, and private methods, but excluding inherited methods.
|
||||
*
|
||||
* <p> If this {@code Class} object represents a type that has multiple
|
||||
* declared methods with the same name and parameter types, but different
|
||||
* return types, then the returned array has a {@code Method} object for
|
||||
* each such method.
|
||||
* <p> If this {@code Class} object represents a class or interface that
|
||||
* has multiple declared methods with the same name and parameter types,
|
||||
* but different return types, then the returned array has a {@code Method}
|
||||
* object for each such method.
|
||||
*
|
||||
* <p> If this {@code Class} object represents a type that has a class
|
||||
* initialization method {@code <clinit>}, then the returned array does
|
||||
* <em>not</em> have a corresponding {@code Method} object.
|
||||
* <p> If this {@code Class} object represents a class or interface that
|
||||
* has a class initialization method {@code <clinit>}, then the returned
|
||||
* array does <em>not</em> have a corresponding {@code Method} object.
|
||||
*
|
||||
* <p> If this {@code Class} object represents a class or interface with no
|
||||
* 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
|
||||
* 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,
|
||||
* 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
|
||||
* 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.
|
||||
*
|
||||
* @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
|
||||
* possibly empty value for a record.
|
||||
*
|
||||
* <p> Note that class {@link Record} is not a record type and thus invoking
|
||||
* this method on class {@code Record} returns {@code false}.
|
||||
* <p> Note that class {@link Record} is not a record class and thus
|
||||
* invoking this method on class {@code Record} returns {@code 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
|
||||
*/
|
||||
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
|
||||
* 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
|
||||
* represented by this {@code Class} object in the order they're
|
||||
* declared, or null if this {@code Class} object does not
|
||||
* represent an enum type
|
||||
* represent an enum class
|
||||
* @since 1.5
|
||||
*/
|
||||
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
|
||||
* Class object does not represent an enum type;
|
||||
* Class object does not represent an enum class;
|
||||
* identical to getEnumConstants except that the result is
|
||||
* uncloned, cached, and shared by all callers.
|
||||
*/
|
||||
@ -3788,7 +3788,7 @@ public final class Class<T> implements java.io.Serializable,
|
||||
T[] universe = getEnumConstantsShared();
|
||||
if (universe == null)
|
||||
throw new IllegalArgumentException(
|
||||
getName() + " is not an enum type");
|
||||
getName() + " is not an enum class");
|
||||
directory = new HashMap<>((int)(universe.length / 0.75f) + 1);
|
||||
for (T constant : universe) {
|
||||
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);
|
||||
}
|
||||
|
||||
// Annotation types cache their internal (AnnotationType) form
|
||||
// Annotation interfaces cache their internal (AnnotationType) form
|
||||
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
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
|
||||
* 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
|
||||
* 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.)
|
||||
*
|
||||
* <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
|
||||
* value is an {@code AnnotatedType} object representing an element with no
|
||||
* 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
|
||||
* {@code Class} object. (The <em>use</em> of type Foo to specify a
|
||||
* 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
|
||||
* an array containing objects representing the uses of interface types to
|
||||
|
@ -46,8 +46,8 @@ public interface AnnotatedArrayType extends AnnotatedType {
|
||||
|
||||
/**
|
||||
* 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
|
||||
* {@code @TA O<T>.I<S>}, return a representation of {@code @TA O<T>}.
|
||||
* this type represents a nested class or interface. For example, if this
|
||||
* 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
|
||||
* of {@code AnnotatedArrayType}.
|
||||
|
@ -248,7 +248,7 @@ import sun.reflect.annotation.AnnotationType;
|
||||
*
|
||||
* <p>Similarly, attempting to read an enum-valued member will result in
|
||||
* 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
|
||||
* {@code @Repeatable} annotation whose value element indicates a type
|
||||
|
@ -49,13 +49,13 @@ public interface AnnotatedParameterizedType extends AnnotatedType {
|
||||
* {@code @TA O<T>.I<S>}, return a representation of {@code @TA O<T>}.
|
||||
*
|
||||
* <p>Returns {@code null} if this {@code AnnotatedType} represents a
|
||||
* top-level type, or a local or anonymous class, or a primitive type, or
|
||||
* void.
|
||||
* top-level class or interface, or a local or anonymous class, or
|
||||
* a primitive type, or void.
|
||||
*
|
||||
* @return an {@code AnnotatedType} object representing the potentially
|
||||
* annotated type that this type is a member of, or {@code null}
|
||||
* @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
|
||||
* refers to a parameterized type that cannot be instantiated
|
||||
* for any reason
|
||||
|
@ -55,8 +55,8 @@ public interface AnnotatedType extends AnnotatedElement {
|
||||
* {@code @TA O<T>.I<S>}, return a representation of {@code @TA O<T>}.
|
||||
*
|
||||
* <p>Returns {@code null} if this {@code AnnotatedType} represents a
|
||||
* top-level type, or a local or anonymous class, or a primitive type, or
|
||||
* void.
|
||||
* top-level class or interface, or a local or anonymous class, or
|
||||
* a primitive type, or void.
|
||||
*
|
||||
* <p>Returns {@code null} if this {@code AnnotatedType} is an instance of
|
||||
* {@code AnnotatedArrayType}, {@code AnnotatedTypeVariable}, or
|
||||
@ -69,7 +69,7 @@ public interface AnnotatedType extends AnnotatedElement {
|
||||
* @return an {@code AnnotatedType} object representing the potentially
|
||||
* annotated type that this type is a member of, or {@code null}
|
||||
* @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
|
||||
* refers to a parameterized type that cannot be instantiated
|
||||
* for any reason
|
||||
|
@ -462,7 +462,7 @@ public final class Constructor<T> extends Executable {
|
||||
* after possible unwrapping, a parameter value
|
||||
* cannot be converted to the corresponding formal
|
||||
* 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
|
||||
* underlying constructor represents an abstract class.
|
||||
* @throws InvocationTargetException if the underlying constructor
|
||||
|
@ -206,10 +206,10 @@ class Field extends AccessibleObject implements Member {
|
||||
|
||||
/**
|
||||
* 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
|
||||
* an enumerated type.
|
||||
* an enumerated class.
|
||||
* @since 1.5
|
||||
*/
|
||||
public boolean isEnumConstant() {
|
||||
@ -258,7 +258,7 @@ class Field extends AccessibleObject implements Member {
|
||||
* <cite>The Java Virtual Machine Specification</cite>
|
||||
* @throws TypeNotPresentException if the generic type
|
||||
* signature of the underlying field refers to a non-existent
|
||||
* type declaration
|
||||
* class or interface declaration
|
||||
* @throws MalformedParameterizedTypeException if the generic
|
||||
* signature of the underlying field refers to a parameterized type
|
||||
* that cannot be instantiated for any reason
|
||||
|
@ -44,8 +44,8 @@ public interface GenericArrayType extends Type {
|
||||
*
|
||||
* @return a {@code Type} object representing the component type
|
||||
* of this array
|
||||
* @throws TypeNotPresentException if the underlying array type's
|
||||
* component type refers to a non-existent type declaration
|
||||
* @throws TypeNotPresentException if the underlying array type's component
|
||||
* type refers to a non-existent class or interface declaration
|
||||
* @throws MalformedParameterizedTypeException if the
|
||||
* underlying array type's component type refers to a
|
||||
* parameterized type that cannot be instantiated for any reason
|
||||
|
@ -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.
|
||||
*
|
||||
* 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
|
||||
* encountered by a reflective method that needs to interpret the
|
||||
* generic signature information for a type, method or constructor.
|
||||
* encountered by a reflective method that needs to interpret the generic
|
||||
* signature information for a class or interface, method or constructor.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
|
@ -282,9 +282,9 @@ public final class Method extends Executable {
|
||||
* specified in
|
||||
* <cite>The Java Virtual Machine Specification</cite>
|
||||
* @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
|
||||
* 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
|
||||
* @since 1.5
|
||||
*/
|
||||
@ -603,8 +603,7 @@ public final class Method extends Executable {
|
||||
* method; returns {@code false} otherwise.
|
||||
*
|
||||
* A default method is a public non-abstract instance method, that
|
||||
* is, a non-static method with a body, declared in an interface
|
||||
* type.
|
||||
* is, a non-static method with a body, declared in an interface.
|
||||
*
|
||||
* @return true if and only if this method is a default
|
||||
* method as defined by the Java Language Specification.
|
||||
|
@ -32,15 +32,15 @@ package java.lang.reflect;
|
||||
*
|
||||
* <p>A parameterized type is created the first time it is needed by a
|
||||
* reflective method, as specified in this package. When a
|
||||
* parameterized type p is created, the generic type declaration that
|
||||
* p instantiates is resolved, and all type arguments of p are created
|
||||
* parameterized type p is created, the generic class or interface declaration
|
||||
* that p instantiates is resolved, and all type arguments of p are created
|
||||
* recursively. See {@link java.lang.reflect.TypeVariable
|
||||
* TypeVariable} for details on the creation process for type
|
||||
* variables. Repeated creation of a parameterized type has no effect.
|
||||
*
|
||||
* <p>Instances of classes that implement this interface must implement
|
||||
* 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
|
||||
* @since 1.5
|
||||
@ -56,8 +56,8 @@ public interface ParameterizedType extends Type {
|
||||
*
|
||||
* @return an array of {@code Type} objects representing the actual type
|
||||
* arguments to this type
|
||||
* @throws TypeNotPresentException if any of the
|
||||
* actual type arguments refers to a non-existent type declaration
|
||||
* @throws TypeNotPresentException if any of the actual type arguments
|
||||
* refers to a non-existent class or interface declaration
|
||||
* @throws MalformedParameterizedTypeException if any of the
|
||||
* actual type parameters refer to a parameterized type that cannot
|
||||
* 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,
|
||||
* {@code null} is returned
|
||||
* @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
|
||||
* refers to a parameterized type that cannot be instantiated
|
||||
* for any reason
|
||||
|
@ -240,10 +240,11 @@ import static java.lang.module.ModuleDescriptor.Modifier.SYNTHETIC;
|
||||
*
|
||||
* <p>
|
||||
* 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
|
||||
* of a proxy class. If a superinterface or a referenced type, say {@code T},
|
||||
* is in a non-exported package, the {@linkplain Module module} of {@code T} is
|
||||
* updated to export the package of {@code T} to the dynamic module.
|
||||
* class and the modules of the classes and interfaces referenced by
|
||||
* all public method signatures of a proxy class. If a superinterface or
|
||||
* a referenced class or interface, say {@code T}, is in a non-exported package,
|
||||
* 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>
|
||||
*
|
||||
|
@ -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
|
||||
* @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) {
|
||||
if (classes == null || classes.size() == 0)
|
||||
|
@ -43,7 +43,7 @@ import java.util.Objects;
|
||||
*
|
||||
* @see Class#getRecordComponents()
|
||||
* @see java.lang.Record
|
||||
* @jls 8.10 Record Types
|
||||
* @jls 8.10 Record Classes
|
||||
* @since 16
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @return a {@code String} that describes the generic type signature for
|
||||
|
@ -439,10 +439,10 @@ public abstract class Symbol extends AnnoConstruct implements PoolConstant, Elem
|
||||
* Also includes fields of inner classes which are in
|
||||
* turn local to a method or variable initializer.
|
||||
*/
|
||||
public boolean isLocal() {
|
||||
public boolean isDirectlyOrIndirectlyLocal() {
|
||||
return
|
||||
(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
|
||||
@ -760,7 +760,7 @@ public abstract class Symbol extends AnnoConstruct implements PoolConstant, Elem
|
||||
public Symbol baseSymbol() { return other; }
|
||||
public Type erasure(Types types) { return other.erasure(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 Name getQualifiedName() { return other.getQualifiedName(); }
|
||||
public Name flatName() { return other.flatName(); }
|
||||
|
@ -5165,7 +5165,7 @@ public class Attr extends JCTree.Visitor {
|
||||
}
|
||||
}
|
||||
} 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));
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ public class Check {
|
||||
names = Names.instance(context);
|
||||
dfltTargetMeta = new Name[] { names.PACKAGE, names.TYPE,
|
||||
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);
|
||||
rs = Resolve.instance(context);
|
||||
syms = Symtab.instance(context);
|
||||
@ -1216,7 +1216,8 @@ public class Check {
|
||||
implicit |= sym.owner.flags_field & STRICTFP;
|
||||
break;
|
||||
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() &&
|
||||
((flags & RECORD) != 0 || (flags & ENUM) != 0 || (flags & INTERFACE) != 0);
|
||||
boolean staticOrImplicitlyStatic = (flags & STATIC) != 0 || implicitlyStatic;
|
||||
@ -1225,7 +1226,7 @@ public class Check {
|
||||
implicit = implicitlyStatic ? STATIC : implicit;
|
||||
} else if (sym.owner.kind == TYP) {
|
||||
// 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 ||
|
||||
(sym.owner.flags_field & STATIC) != 0) {
|
||||
mask |= STATIC;
|
||||
@ -2729,7 +2730,7 @@ public class Check {
|
||||
|
||||
if (sym.kind == VAR) {
|
||||
if ((sym.flags() & PARAMETER) != 0 ||
|
||||
sym.isLocal() ||
|
||||
sym.isDirectlyOrIndirectlyLocal() ||
|
||||
sym.name == names._this ||
|
||||
sym.name == names._super) {
|
||||
return;
|
||||
|
@ -498,7 +498,7 @@ public class Enter extends JCTree.Visitor {
|
||||
|
||||
// Add non-local class to uncompleted, to make sure it will be
|
||||
// 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
|
||||
|
||||
// Recursively enter all member classes.
|
||||
|
@ -2904,7 +2904,7 @@ public class Flow {
|
||||
public void visitClassDef(JCClassDecl tree) {
|
||||
JCTree prevTree = currentTree;
|
||||
try {
|
||||
currentTree = tree.sym.isLocal() ? tree : null;
|
||||
currentTree = tree.sym.isDirectlyOrIndirectlyLocal() ? tree : null;
|
||||
super.visitClassDef(tree);
|
||||
} finally {
|
||||
currentTree = prevTree;
|
||||
|
@ -1438,7 +1438,7 @@ public class LambdaToMethod extends TreeTranslator {
|
||||
public void visitNewClass(JCNewClass tree) {
|
||||
TypeSymbol def = tree.type.tsym;
|
||||
boolean inReferencedClass = currentlyInClass(def);
|
||||
boolean isLocal = def.isLocal();
|
||||
boolean isLocal = def.isDirectlyOrIndirectlyLocal();
|
||||
if ((inReferencedClass && isLocal || lambdaNewClassFilter(context(), tree))) {
|
||||
TranslationContext<?> localContext = context();
|
||||
final TypeSymbol outerInstanceSymbol = tree.type.getEnclosingType().tsym;
|
||||
@ -1592,7 +1592,7 @@ public class LambdaToMethod extends TreeTranslator {
|
||||
while (frameStack2.nonEmpty()) {
|
||||
switch (frameStack2.head.tree.getTag()) {
|
||||
case VARDEF:
|
||||
if (((JCVariableDecl)frameStack2.head.tree).sym.isLocal()) {
|
||||
if (((JCVariableDecl)frameStack2.head.tree).sym.isDirectlyOrIndirectlyLocal()) {
|
||||
frameStack2 = frameStack2.tail;
|
||||
break;
|
||||
}
|
||||
@ -2313,7 +2313,7 @@ public class LambdaToMethod extends TreeTranslator {
|
||||
!receiverAccessible() ||
|
||||
(tree.getMode() == ReferenceMode.NEW &&
|
||||
tree.kind != ReferenceKind.ARRAY_CTOR &&
|
||||
(tree.sym.owner.isLocal() || tree.sym.owner.isInner()));
|
||||
(tree.sym.owner.isDirectlyOrIndirectlyLocal() || tree.sym.owner.isInner()));
|
||||
}
|
||||
|
||||
Type generatedRefSig() {
|
||||
|
@ -378,11 +378,11 @@ public class Lower extends TreeTranslator {
|
||||
}
|
||||
|
||||
ClassSymbol ownerToCopyFreeVarsFrom(ClassSymbol c) {
|
||||
if (!c.isLocal()) {
|
||||
if (!c.isDirectlyOrIndirectlyLocal()) {
|
||||
return null;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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) {
|
||||
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
|
||||
sym.flags_field &= ~PRIVATE;
|
||||
return false;
|
||||
@ -2203,7 +2203,7 @@ public class Lower extends TreeTranslator {
|
||||
tree.extending = translate(tree.extending);
|
||||
tree.implementing = translate(tree.implementing);
|
||||
|
||||
if (currentClass.isLocal()) {
|
||||
if (currentClass.isDirectlyOrIndirectlyLocal()) {
|
||||
ClassSymbol encl = currentClass.owner.enclClass();
|
||||
if (encl.trans_local == null) {
|
||||
encl.trans_local = List.nil();
|
||||
@ -2654,7 +2654,7 @@ public class Lower extends TreeTranslator {
|
||||
|
||||
private void visitMethodDefInternal(JCMethodDecl tree) {
|
||||
if (tree.name == names.init &&
|
||||
(currentClass.isInner() || currentClass.isLocal())) {
|
||||
(currentClass.isInner() || currentClass.isDirectlyOrIndirectlyLocal())) {
|
||||
// We are seeing a constructor of an inner class.
|
||||
MethodSymbol m = tree.sym;
|
||||
|
||||
@ -2794,7 +2794,7 @@ public class Lower extends TreeTranslator {
|
||||
|
||||
// If created class is local, add free variables after
|
||||
// explicit constructor arguments.
|
||||
if (c.isLocal()) {
|
||||
if (c.isDirectlyOrIndirectlyLocal()) {
|
||||
tree.args = tree.args.appendList(loadFreevars(tree.pos(), freevars(c)));
|
||||
}
|
||||
|
||||
@ -2813,7 +2813,7 @@ public class Lower extends TreeTranslator {
|
||||
if (tree.encl != null) {
|
||||
thisArg = attr.makeNullCheck(translate(tree.encl));
|
||||
thisArg.type = tree.encl.type;
|
||||
} else if (c.isLocal()) {
|
||||
} else if (c.isDirectlyOrIndirectlyLocal()) {
|
||||
// local class
|
||||
thisArg = makeThis(tree.pos(), c.type.getEnclosingType().tsym);
|
||||
} else {
|
||||
@ -2996,7 +2996,7 @@ public class Lower extends TreeTranslator {
|
||||
// If we are calling a constructor of a local class, add
|
||||
// free variables after explicit constructor arguments.
|
||||
ClassSymbol c = (ClassSymbol)constructor.owner;
|
||||
if (c.isLocal()) {
|
||||
if (c.isDirectlyOrIndirectlyLocal()) {
|
||||
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));
|
||||
tree.meth = make.Ident(constructor);
|
||||
((JCIdent) tree.meth).name = methName;
|
||||
} else if (c.isLocal() || methName == names._this){
|
||||
} else if (c.isDirectlyOrIndirectlyLocal() || methName == names._this){
|
||||
// local class or this() call
|
||||
thisArg = makeThis(tree.meth.pos(), c.type.getEnclosingType().tsym);
|
||||
} else {
|
||||
|
@ -521,7 +521,7 @@ public class TypeEnter implements Completer {
|
||||
WriteableScope baseScope = WriteableScope.create(tree.sym);
|
||||
//import already entered local classes into base scope
|
||||
for (Symbol sym : env.outer.info.scope.getSymbols(NON_RECURSIVE)) {
|
||||
if (sym.isLocal()) {
|
||||
if (sym.isDirectlyOrIndirectlyLocal()) {
|
||||
baseScope.enter(sym);
|
||||
}
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ public class JNIWriter {
|
||||
|
||||
public boolean needsHeader(ClassSymbol c) {
|
||||
lazyInit();
|
||||
if (c.isLocal() || isSynthetic(c))
|
||||
if (c.isDirectlyOrIndirectlyLocal() || isSynthetic(c))
|
||||
return false;
|
||||
return (checkAll)
|
||||
? needsHeader(c.outermostClass(), true)
|
||||
@ -151,7 +151,7 @@ public class JNIWriter {
|
||||
}
|
||||
|
||||
private boolean needsHeader(ClassSymbol c, boolean checkNestedClasses) {
|
||||
if (c.isLocal() || isSynthetic(c))
|
||||
if (c.isDirectlyOrIndirectlyLocal() || isSynthetic(c))
|
||||
return false;
|
||||
|
||||
for (Symbol sym : c.members_field.getSymbols(NON_RECURSIVE)) {
|
||||
|
@ -32,7 +32,6 @@ import javax.lang.model.element.PackageElement;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
|
||||
import jdk.javadoc.doclet.Doclet;
|
||||
import jdk.javadoc.doclet.DocletEnvironment;
|
||||
import jdk.javadoc.doclet.Reporter;
|
||||
import jdk.javadoc.internal.doclets.toolkit.AbstractDoclet;
|
||||
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);
|
||||
if (options.createIndex()) {
|
||||
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.copyResource(DOCLET_RESOURCES.resolve(DocPaths.GLASS_IMG), true, false);
|
||||
|
@ -23,13 +23,13 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
var noResult = {l: "No results found"};
|
||||
var loading = {l: "Loading search index..."};
|
||||
var catModules = "Modules";
|
||||
var catPackages = "Packages";
|
||||
var catTypes = "Types";
|
||||
var catMembers = "Members";
|
||||
var catSearchTags = "SearchTags";
|
||||
var noResult = {l: "##REPLACE:doclet.search.no_results##"};
|
||||
var loading = {l: "##REPLACE:doclet.search.loading##"};
|
||||
var catModules = "##REPLACE:doclet.search.modules##";
|
||||
var catPackages = "##REPLACE:doclet.search.packages##";
|
||||
var catTypes = "##REPLACE:doclet.search.types##";
|
||||
var catMembers = "##REPLACE:doclet.search.members##";
|
||||
var catSearchTags = "##REPLACE:doclet.search.search_tags##";
|
||||
var highlight = "<span class=\"result-highlight\">$&</span>";
|
||||
var searchPattern = "";
|
||||
var fallbackPattern = "";
|
@ -333,3 +333,11 @@ doclet.record_field_doc.fullbody=\
|
||||
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.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
|
@ -32,12 +32,17 @@ import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
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.JavaFileManager.Location;
|
||||
import javax.tools.StandardLocation;
|
||||
|
||||
import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
|
||||
import jdk.javadoc.internal.doclets.toolkit.Resources;
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public void copyResource(DocPath resource, boolean overwrite, boolean replaceNewLine)
|
||||
throws DocFileIOException, ResourceIOException {
|
||||
throws DocFileIOException, ResourceIOException {
|
||||
if (exists() && !overwrite)
|
||||
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 {
|
||||
InputStream in = BaseConfiguration.class.getResourceAsStream(resource.getPath());
|
||||
if (in == null)
|
||||
@ -190,7 +213,7 @@ public abstract class DocFile {
|
||||
try (Writer writer = openWriter()) {
|
||||
String line;
|
||||
while ((line = readResourceLine(resource, reader)) != null) {
|
||||
write(this, writer, line);
|
||||
write(this, writer, resources == null ? line : localize(line, resources));
|
||||
write(this, writer, DocletConstants.NL);
|
||||
}
|
||||
} 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. */
|
||||
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.
|
||||
* 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 input the stream
|
||||
* @param buf the buffer
|
||||
* @param input the stream
|
||||
* @param buf the buffer
|
||||
*
|
||||
* @return the number of bytes read, or -1 if at end of file
|
||||
* @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.
|
||||
* 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 out the stream
|
||||
* @param buf the buffer
|
||||
* @param out the stream
|
||||
* @param buf the buffer
|
||||
*
|
||||
* @throws DocFileIOException if an exception occurred while writing the stream
|
||||
*/
|
||||
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.
|
||||
* 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 out the stream
|
||||
* @param text the text to be written
|
||||
* @param out the stream
|
||||
* @param text the text to be written
|
||||
*
|
||||
* @throws DocFileIOException if an exception occurred while writing the stream
|
||||
*/
|
||||
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.
|
||||
* 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
|
||||
* @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 {
|
||||
return in.read(buf);
|
||||
} 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.
|
||||
* 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
|
||||
* @throws ResourceIOException if an exception occurred while reading the stream
|
||||
*/
|
||||
|
@ -275,6 +275,9 @@ public class DocPaths {
|
||||
/** The name of the search javascript file. */
|
||||
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. */
|
||||
public static final DocPath SERIALIZED_FORM = DocPath.create("serialized-form.html");
|
||||
|
||||
|
@ -222,6 +222,10 @@ public final class EventWriter {
|
||||
notified = false;
|
||||
}
|
||||
|
||||
private void resetStringPool() {
|
||||
StringPool.reset();
|
||||
}
|
||||
|
||||
private int usedSize() {
|
||||
return (int) (currentPosition - startPosition);
|
||||
}
|
||||
@ -273,6 +277,7 @@ public final class EventWriter {
|
||||
|
||||
if (isNotified()) {
|
||||
resetNotified();
|
||||
resetStringPool();
|
||||
reset();
|
||||
// returning false will trigger restart of the event write attempt
|
||||
return false;
|
||||
|
@ -488,18 +488,9 @@ public final class JVM {
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* Gets the address of the jboolean epoch.
|
||||
*
|
||||
* The epoch alternates every checkpoint.
|
||||
*
|
||||
* @return The address of the jboolean.
|
||||
*/
|
||||
public native long getEpochAddress();
|
||||
public static native boolean addStringConstant(long id, String s);
|
||||
|
||||
public native void uncaughtException(Thread thread, Throwable t);
|
||||
|
||||
|
@ -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.
|
||||
*
|
||||
* 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.atomic.AtomicLong;
|
||||
|
||||
import jdk.internal.misc.Unsafe;
|
||||
|
||||
public final class StringPool {
|
||||
|
||||
private static final Unsafe unsafe = Unsafe.getUnsafe();
|
||||
|
||||
static final int MIN_LIMIT = 16;
|
||||
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();
|
||||
static {
|
||||
epochAddress = JVM.getJVM().getEpochAddress();
|
||||
sp.reset();
|
||||
}
|
||||
public static long addString(String s) {
|
||||
|
||||
static long addString(String s) {
|
||||
return sp.addString(s);
|
||||
}
|
||||
private static boolean getCurrentEpoch() {
|
||||
return unsafe.getByte(epochAddress) == 1;
|
||||
|
||||
static void reset() {
|
||||
sp.reset();
|
||||
}
|
||||
|
||||
private static class SimpleStringIdPool {
|
||||
/* string id index */
|
||||
private final AtomicLong sidIdx = new AtomicLong(1);
|
||||
/* epoch of cached strings */
|
||||
private boolean poolEpoch;
|
||||
/* the cache */
|
||||
private final ConcurrentHashMap<String, Long> cache;
|
||||
/* max size */
|
||||
@ -60,7 +52,6 @@ public final class StringPool {
|
||||
private final long MAX_SIZE_UTF16 = 16*1024*1024;
|
||||
/* max size bytes*/
|
||||
private long currentSizeUTF16;
|
||||
|
||||
/* looking at a biased data set 4 is a good value */
|
||||
private final String[] preCache = new String[]{"", "" , "" ,""};
|
||||
/* index of oldest */
|
||||
@ -69,35 +60,28 @@ public final class StringPool {
|
||||
private static final int preCacheMask = 0x03;
|
||||
|
||||
SimpleStringIdPool() {
|
||||
cache = new ConcurrentHashMap<>(MAX_SIZE, 0.75f);
|
||||
this.cache = new ConcurrentHashMap<>(MAX_SIZE, 0.75f);
|
||||
}
|
||||
void reset() {
|
||||
reset(getCurrentEpoch());
|
||||
}
|
||||
private void reset(boolean epoch) {
|
||||
|
||||
private void reset() {
|
||||
this.cache.clear();
|
||||
this.poolEpoch = epoch;
|
||||
this.currentSizeUTF16 = 0;
|
||||
synchronized(SimpleStringIdPool.class) {
|
||||
this.currentSizeUTF16 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private long addString(String s) {
|
||||
boolean currentEpoch = getCurrentEpoch();
|
||||
if (poolEpoch == currentEpoch) {
|
||||
/* pool is for current chunk */
|
||||
Long lsid = this.cache.get(s);
|
||||
if (lsid != null) {
|
||||
return lsid.longValue();
|
||||
}
|
||||
} else {
|
||||
/* pool is for an old chunk */
|
||||
reset(currentEpoch);
|
||||
Long lsid = this.cache.get(s);
|
||||
if (lsid != null) {
|
||||
return lsid.longValue();
|
||||
}
|
||||
if (!preCache(s)) {
|
||||
/* we should not pool this string */
|
||||
return -1;
|
||||
return DO_NOT_POOL;
|
||||
}
|
||||
if (cache.size() > MAX_SIZE || currentSizeUTF16 > MAX_SIZE_UTF16) {
|
||||
/* pool was full */
|
||||
reset(currentEpoch);
|
||||
reset();
|
||||
}
|
||||
return storeString(s);
|
||||
}
|
||||
@ -106,14 +90,13 @@ public final class StringPool {
|
||||
long sid = this.sidIdx.getAndIncrement();
|
||||
/* we can race but it is ok */
|
||||
this.cache.put(s, sid);
|
||||
boolean currentEpoch;
|
||||
synchronized(SimpleStringIdPool.class) {
|
||||
currentEpoch = JVM.addStringConstant(poolEpoch, sid, s);
|
||||
JVM.addStringConstant(sid, s);
|
||||
currentSizeUTF16 += s.length();
|
||||
}
|
||||
/* did we write in chunk that this pool represent */
|
||||
return currentEpoch == poolEpoch ? sid : -1;
|
||||
return sid;
|
||||
}
|
||||
|
||||
private boolean preCache(String s) {
|
||||
if (preCache[0].equals(s)) {
|
||||
return true;
|
||||
|
@ -26,10 +26,10 @@
|
||||
* @bug 6340864
|
||||
* @summary Implement vectorization optimizations in hotspot-server
|
||||
*
|
||||
* @run main/othervm/timeout=400 -Xbatch -Xmx128m compiler.c2.cr6340864.TestByteVect
|
||||
* @run main/othervm/timeout=400 -Xbatch -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/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=32 compiler.c2.cr6340864.TestByteVect
|
||||
* @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m compiler.c2.cr6340864.TestByteVect
|
||||
* @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=8 compiler.c2.cr6340864.TestByteVect
|
||||
* @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=16 compiler.c2.cr6340864.TestByteVect
|
||||
* @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=32 compiler.c2.cr6340864.TestByteVect
|
||||
*/
|
||||
|
||||
package compiler.c2.cr6340864;
|
||||
|
@ -26,10 +26,10 @@
|
||||
* @bug 6340864
|
||||
* @summary Implement vectorization optimizations in hotspot-server
|
||||
*
|
||||
* @run main/othervm/timeout=400 -Xbatch -Xmx128m compiler.c2.cr6340864.TestDoubleVect
|
||||
* @run main/othervm/timeout=400 -Xbatch -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/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=32 compiler.c2.cr6340864.TestDoubleVect
|
||||
* @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m compiler.c2.cr6340864.TestDoubleVect
|
||||
* @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=8 compiler.c2.cr6340864.TestDoubleVect
|
||||
* @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=16 compiler.c2.cr6340864.TestDoubleVect
|
||||
* @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=32 compiler.c2.cr6340864.TestDoubleVect
|
||||
*/
|
||||
|
||||
package compiler.c2.cr6340864;
|
||||
|
@ -26,10 +26,10 @@
|
||||
* @bug 6340864
|
||||
* @summary Implement vectorization optimizations in hotspot-server
|
||||
*
|
||||
* @run main/othervm/timeout=400 -Xbatch -Xmx128m compiler.c2.cr6340864.TestFloatVect
|
||||
* @run main/othervm/timeout=400 -Xbatch -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/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=32 compiler.c2.cr6340864.TestFloatVect
|
||||
* @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m compiler.c2.cr6340864.TestFloatVect
|
||||
* @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=8 compiler.c2.cr6340864.TestFloatVect
|
||||
* @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=16 compiler.c2.cr6340864.TestFloatVect
|
||||
* @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=32 compiler.c2.cr6340864.TestFloatVect
|
||||
*/
|
||||
|
||||
package compiler.c2.cr6340864;
|
||||
|
@ -26,11 +26,11 @@
|
||||
* @bug 6340864
|
||||
* @summary Implement vectorization optimizations in hotspot-server
|
||||
*
|
||||
* @run main/othervm/timeout=400 -Xbatch -Xmx128m compiler.c2.cr6340864.TestIntVect
|
||||
* @run main/othervm/timeout=400 -Xbatch -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/timeout=400 -Xbatch -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 compiler.c2.cr6340864.TestIntVect
|
||||
* @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=8 compiler.c2.cr6340864.TestIntVect
|
||||
* @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=16 compiler.c2.cr6340864.TestIntVect
|
||||
* @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=32 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;
|
||||
|
@ -26,11 +26,11 @@
|
||||
* @bug 8248830
|
||||
* @summary Implement Rotate vectorization optimizations in hotspot-server
|
||||
*
|
||||
* @run main/othervm/timeout=400 -Xbatch -Xmx128m compiler.c2.cr6340864.TestIntVectRotate
|
||||
* @run main/othervm/timeout=400 -Xbatch -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/timeout=400 -Xbatch -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 compiler.c2.cr6340864.TestIntVectRotate
|
||||
* @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=8 compiler.c2.cr6340864.TestIntVectRotate
|
||||
* @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=16 compiler.c2.cr6340864.TestIntVectRotate
|
||||
* @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=32 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;
|
||||
|
@ -26,11 +26,11 @@
|
||||
* @bug 6340864
|
||||
* @summary Implement vectorization optimizations in hotspot-server
|
||||
*
|
||||
* @run main/othervm/timeout=400 -Xbatch -Xmx128m compiler.c2.cr6340864.TestLongVect
|
||||
* @run main/othervm/timeout=400 -Xbatch -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/timeout=400 -Xbatch -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 compiler.c2.cr6340864.TestLongVect
|
||||
* @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=8 compiler.c2.cr6340864.TestLongVect
|
||||
* @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=16 compiler.c2.cr6340864.TestLongVect
|
||||
* @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=32 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;
|
||||
|
@ -26,11 +26,11 @@
|
||||
* @bug 8248830
|
||||
* @summary Implement Rotate vectorization optimizations in hotspot-server
|
||||
*
|
||||
* @run main/othervm/timeout=400 -Xbatch -Xmx128m compiler.c2.cr6340864.TestLongVectRotate
|
||||
* @run main/othervm/timeout=400 -Xbatch -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/timeout=400 -Xbatch -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 compiler.c2.cr6340864.TestLongVectRotate
|
||||
* @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=8 compiler.c2.cr6340864.TestLongVectRotate
|
||||
* @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=16 compiler.c2.cr6340864.TestLongVectRotate
|
||||
* @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=32 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;
|
||||
|
@ -26,10 +26,10 @@
|
||||
* @bug 6340864
|
||||
* @summary Implement vectorization optimizations in hotspot-server
|
||||
*
|
||||
* @run main/othervm/timeout=400 -Xbatch -Xmx128m compiler.c2.cr6340864.TestShortVect
|
||||
* @run main/othervm/timeout=400 -Xbatch -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/timeout=400 -Xbatch -Xmx128m -XX:MaxVectorSize=32 compiler.c2.cr6340864.TestShortVect
|
||||
* @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m compiler.c2.cr6340864.TestShortVect
|
||||
* @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=8 compiler.c2.cr6340864.TestShortVect
|
||||
* @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=16 compiler.c2.cr6340864.TestShortVect
|
||||
* @run main/othervm -Xbatch -XX:CompileCommand=exclude,*::test() -Xmx128m -XX:MaxVectorSize=32 compiler.c2.cr6340864.TestShortVect
|
||||
*/
|
||||
|
||||
package compiler.c2.cr6340864;
|
||||
|
@ -28,7 +28,7 @@
|
||||
* @summary Verify that zero check is executed before division/modulo operation.
|
||||
* @requires vm.compiler2.enabled
|
||||
* @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;
|
||||
|
@ -832,7 +832,6 @@ javax/script/Test7.java 8239361 generic-
|
||||
|
||||
# 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/compiler/TestCodeSweeper.java 8225209 generic-all
|
||||
jdk/jfr/event/os/TestThreadContextSwitches.java 8247776 windows-all
|
||||
|
@ -126,7 +126,11 @@ public class RuntimePackageTest {
|
||||
|
||||
private static Set<Path> listFiles(Path root) throws IOException {
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
* @test
|
||||
* @bug 8141492 8071982 8141636 8147890 8166175 8168965 8176794 8175218 8147881
|
||||
* 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.
|
||||
* @library ../../lib
|
||||
* @modules jdk.javadoc/jdk.javadoc.internal.tool
|
||||
@ -711,6 +711,10 @@ public class TestSearch extends JavadocTester {
|
||||
}
|
||||
|
||||
void checkSearchJS() {
|
||||
// ensure all resource keys were resolved
|
||||
checkOutput("search.js", false,
|
||||
"##REPLACE:");
|
||||
|
||||
checkOutput("search.js", true,
|
||||
"function searchIndexWithMatcher(indexArray, matcher, category, nameFunc) {",
|
||||
"""
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8000612 8254627
|
||||
* @bug 8000612 8254627 8247994
|
||||
* @summary need test program to validate javadoc resource bundles
|
||||
* @modules jdk.javadoc/jdk.javadoc.internal.tool
|
||||
* jdk.javadoc/jdk.javadoc.internal.doclets.formats.html.resources:open
|
||||
@ -34,6 +34,8 @@
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.tools.*;
|
||||
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
|
||||
// jdk.javadoc.internal.doclets.toolkit.util.Utils.getTypeName
|
||||
String[] extras = {
|
||||
|
29
test/langtools/tools/javac/annotations/8254023/T8254023.java
Normal file
29
test/langtools/tools/javac/annotations/8254023/T8254023.java
Normal 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
|
||||
*/
|
@ -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 { }
|
26
test/langtools/tools/javac/annotations/8254023/test/A.java
Normal file
26
test/langtools/tools/javac/annotations/8254023/test/A.java
Normal 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 { }
|
@ -23,7 +23,7 @@
|
||||
|
||||
/**
|
||||
* @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.
|
||||
* @library /tools/lib
|
||||
* @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
|
||||
public void testGenerateInMultiModeAPI(Path base) throws Exception {
|
||||
Path moduleSrc = base.resolve("module-src");
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8159602 8170549 8171255 8171322
|
||||
* @bug 8159602 8170549 8171255 8171322 8254023
|
||||
* @summary Test annotations on module declaration.
|
||||
* @library /tools/lib
|
||||
* @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.TypeElement;
|
||||
|
||||
import com.sun.tools.classfile.Annotation;
|
||||
import com.sun.tools.classfile.Attribute;
|
||||
import com.sun.tools.classfile.ClassFile;
|
||||
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
|
||||
public void testModuleInfoAnnotationsInAPI(Path base) throws Exception {
|
||||
Path moduleSrc = base.resolve("module-src");
|
||||
|
@ -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() {
|
||||
assertFail("compiler.err.receiver.parameter.not.applicable.constructor.toplevel.class",
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user