This commit is contained in:
Prasanta Sadhukhan 2020-06-10 12:43:22 +05:30
commit a6df9ae23a
66 changed files with 1507 additions and 381 deletions
make/conf
src
test
hotspot/jtreg/runtime/CompressedOops
jaxp/javax/xml/jaxp/unittest/transform
jdk/java
net
time/test/java/time/format
langtools
micro/org/openjdk/bench/javax/crypto/full

@ -426,7 +426,10 @@ var getJibProfilesProfiles = function (input, common, data) {
target_cpu: "x64",
dependencies: ["devkit", "gtest", "pandoc", "graalunit_lib"],
configure_args: concat(common.configure_args_64bit, "--with-zlib=system",
"--with-macosx-version-max=10.9.0"),
"--with-macosx-version-max=10.9.0",
// Use system SetFile instead of the one in the devkit as the
// devkit one may not work on Catalina.
"SETFILE=/usr/bin/SetFile"),
},
"windows-x64": {

@ -56,6 +56,6 @@ const bool CCallingConventionRequiresIntsAsLongs = false;
#define SUPPORT_RESERVED_STACK_AREA
#define COMPRESSED_CLASS_POINTERS_DEPENDS_ON_COMPRESSED_OOPS true
#define COMPRESSED_CLASS_POINTERS_DEPENDS_ON_COMPRESSED_OOPS false
#endif // CPU_AARCH64_GLOBALDEFINITIONS_AARCH64_HPP

@ -93,4 +93,6 @@
return byte_offset_of(JavaFrameAnchor, _last_Java_fp);
}
void set_last_Java_sp(intptr_t* sp) { _last_Java_sp = sp; }
#endif // CPU_ZERO_JAVAFRAMEANCHOR_ZERO_HPP

@ -487,7 +487,7 @@ void ClassLoaderData::add_class(Klass* k, bool publicize /* true */) {
void ClassLoaderData::initialize_holder(Handle loader_or_mirror) {
if (loader_or_mirror() != NULL) {
assert(_holder.is_null(), "never replace holders");
_holder = WeakHandle<vm_class_loader_data>::create(loader_or_mirror);
_holder = WeakHandle<vm_weak_data>::create(loader_or_mirror);
}
}

@ -109,9 +109,9 @@ class ClassLoaderData : public CHeapObj<mtClass> {
static ClassLoaderData * _the_null_class_loader_data;
WeakHandle<vm_class_loader_data> _holder; // The oop that determines lifetime of this class loader
OopHandle _class_loader; // The instance of java/lang/ClassLoader associated with
// this ClassLoaderData
WeakHandle<vm_weak_data> _holder; // The oop that determines lifetime of this class loader
OopHandle _class_loader; // The instance of java/lang/ClassLoader associated with
// this ClassLoaderData
ClassLoaderMetaspace * volatile _metaspace; // Meta-space where meta-data defined by the
// classes in the class loader are allocated.

@ -45,7 +45,7 @@ int ProtectionDomainCacheTable::index_for(Handle protection_domain) {
}
ProtectionDomainCacheTable::ProtectionDomainCacheTable(int table_size)
: Hashtable<WeakHandle<vm_class_loader_data>, mtClass>(table_size, sizeof(ProtectionDomainCacheEntry))
: Hashtable<WeakHandle<vm_weak_data>, mtClass>(table_size, sizeof(ProtectionDomainCacheEntry))
{ _dead_entries = false;
_total_oops_removed = 0;
}
@ -180,8 +180,8 @@ ProtectionDomainCacheEntry* ProtectionDomainCacheTable::add_entry(int index, uns
protection_domain->print_value_on(&ls);
ls.cr();
}
WeakHandle<vm_class_loader_data> w = WeakHandle<vm_class_loader_data>::create(protection_domain);
WeakHandle<vm_weak_data> w = WeakHandle<vm_weak_data>::create(protection_domain);
ProtectionDomainCacheEntry* p = new_entry(hash, w);
Hashtable<WeakHandle<vm_class_loader_data>, mtClass>::add_entry(index, p);
Hashtable<WeakHandle<vm_weak_data>, mtClass>::add_entry(index, p);
return p;
}

@ -35,18 +35,18 @@
// to dictionary.hpp pd_set for more information about how protection domain entries
// are used.
// This table is walked during GC, rather than the class loader data graph dictionaries.
class ProtectionDomainCacheEntry : public HashtableEntry<WeakHandle<vm_class_loader_data>, mtClass> {
class ProtectionDomainCacheEntry : public HashtableEntry<WeakHandle<vm_weak_data>, mtClass> {
friend class VMStructs;
public:
oop object();
oop object_no_keepalive();
ProtectionDomainCacheEntry* next() {
return (ProtectionDomainCacheEntry*)HashtableEntry<WeakHandle<vm_class_loader_data>, mtClass>::next();
return (ProtectionDomainCacheEntry*)HashtableEntry<WeakHandle<vm_weak_data>, mtClass>::next();
}
ProtectionDomainCacheEntry** next_addr() {
return (ProtectionDomainCacheEntry**)HashtableEntry<WeakHandle<vm_class_loader_data>, mtClass>::next_addr();
return (ProtectionDomainCacheEntry**)HashtableEntry<WeakHandle<vm_weak_data>, mtClass>::next_addr();
}
void verify();
@ -61,21 +61,21 @@ class ProtectionDomainCacheEntry : public HashtableEntry<WeakHandle<vm_class_loa
// we only need to iterate over this set.
// The amount of different protection domains used is typically magnitudes smaller
// than the number of system dictionary entries (loaded classes).
class ProtectionDomainCacheTable : public Hashtable<WeakHandle<vm_class_loader_data>, mtClass> {
class ProtectionDomainCacheTable : public Hashtable<WeakHandle<vm_weak_data>, mtClass> {
friend class VMStructs;
private:
ProtectionDomainCacheEntry* bucket(int i) const {
return (ProtectionDomainCacheEntry*) Hashtable<WeakHandle<vm_class_loader_data>, mtClass>::bucket(i);
return (ProtectionDomainCacheEntry*) Hashtable<WeakHandle<vm_weak_data>, mtClass>::bucket(i);
}
// The following method is not MT-safe and must be done under lock.
ProtectionDomainCacheEntry** bucket_addr(int i) {
return (ProtectionDomainCacheEntry**) Hashtable<WeakHandle<vm_class_loader_data>, mtClass>::bucket_addr(i);
return (ProtectionDomainCacheEntry**) Hashtable<WeakHandle<vm_weak_data>, mtClass>::bucket_addr(i);
}
ProtectionDomainCacheEntry* new_entry(unsigned int hash, WeakHandle<vm_class_loader_data> protection_domain) {
ProtectionDomainCacheEntry* new_entry(unsigned int hash, WeakHandle<vm_weak_data> protection_domain) {
ProtectionDomainCacheEntry* entry = (ProtectionDomainCacheEntry*)
Hashtable<WeakHandle<vm_class_loader_data>, mtClass>::new_entry(hash, protection_domain);
Hashtable<WeakHandle<vm_weak_data>, mtClass>::new_entry(hash, protection_domain);
return entry;
}

@ -99,7 +99,6 @@ class PSPromotionManager {
static MutableSpace* young_space() { return _young_space; }
inline static PSPromotionManager* manager_array(uint index);
template <class T> inline void claim_or_forward_internal_depth(T* p);
template <class T> void process_array_chunk_work(oop obj,
int start, int end);

@ -36,6 +36,7 @@
#include "memory/iterator.inline.hpp"
#include "oops/access.inline.hpp"
#include "oops/oop.inline.hpp"
#include "runtime/prefetch.inline.hpp"
inline PSPromotionManager* PSPromotionManager::manager_array(uint index) {
assert(_manager_array != NULL, "access of NULL manager_array");
@ -47,29 +48,13 @@ inline void PSPromotionManager::push_depth(ScannerTask task) {
claimed_stack_depth()->push(task);
}
template <class T>
inline void PSPromotionManager::claim_or_forward_internal_depth(T* p) {
if (p != NULL) { // XXX: error if p != NULL here
oop o = RawAccess<IS_NOT_NULL>::oop_load(p);
if (o->is_forwarded()) {
o = o->forwardee();
// Card mark
if (PSScavenge::is_obj_in_young(o)) {
PSScavenge::card_table()->inline_write_ref_field_gc(p, o);
}
RawAccess<IS_NOT_NULL>::oop_store(p, o);
} else {
push_depth(ScannerTask(p));
}
}
}
template <class T>
inline void PSPromotionManager::claim_or_forward_depth(T* p) {
assert(should_scavenge(p, true), "revisiting object?");
assert(ParallelScavengeHeap::heap()->is_in(p), "pointer outside heap");
claim_or_forward_internal_depth(p);
oop obj = RawAccess<IS_NOT_NULL>::oop_load(p);
Prefetch::write(obj->mark_addr_raw(), 0);
push_depth(ScannerTask(p));
}
inline void PSPromotionManager::promotion_trace_event(oop new_obj, oop old_obj,

@ -31,7 +31,7 @@
#include "utilities/debug.hpp"
#include "utilities/ostream.hpp"
template <> OopStorage* WeakHandle<vm_class_loader_data>::get_storage() {
template <> OopStorage* WeakHandle<vm_weak_data>::get_storage() {
return OopStorageSet::vm_weak();
}
@ -77,6 +77,6 @@ void WeakHandle<T>::print_on(outputStream* st) const {
}
// Provide instantiation.
template class WeakHandle<vm_class_loader_data>;
template class WeakHandle<vm_weak_data>;
template class WeakHandle<vm_string_table_data>;
template class WeakHandle<vm_resolved_method_table_data>;

@ -39,7 +39,11 @@ class OopStorage;
// This is the vm version of jweak but has different GC lifetimes and policies,
// depending on the type.
enum WeakHandleType { vm_class_loader_data, vm_string_table_data, vm_resolved_method_table_data };
enum WeakHandleType {
vm_weak_data,
vm_string_table_data,
vm_resolved_method_table_data
};
template <WeakHandleType T>
class WeakHandle {

@ -664,9 +664,17 @@ JRT_LEAF(BasicType, Deoptimization::unpack_frames(JavaThread* thread, int exec_m
UnrollBlock* info = array->unroll_block();
// We set the last_Java frame. But the stack isn't really parsable here. So we
// clear it to make sure JFR understands not to try and walk stacks from events
// in here.
intptr_t* sp = thread->frame_anchor()->last_Java_sp();
thread->frame_anchor()->set_last_Java_sp(NULL);
// Unpack the interpreter frames and any adapter frame (c2 only) we might create.
array->unpack_to_stack(stub_frame, exec_mode, info->caller_actual_parameters());
thread->frame_anchor()->set_last_Java_sp(sp);
BasicType bt = info->return_type();
// If we have an exception pending, claim that the return type is an oop
@ -802,7 +810,6 @@ JRT_LEAF(BasicType, Deoptimization::unpack_frames(JavaThread* thread, int exec_m
}
#endif /* !PRODUCT */
return bt;
JRT_END

@ -322,7 +322,7 @@ void mutex_init() {
def(JfrMsg_lock , PaddedMonitor, leaf, true, _safepoint_check_always);
def(JfrBuffer_lock , PaddedMutex , leaf, true, _safepoint_check_never);
def(JfrStream_lock , PaddedMutex , nonleaf + 1, false, _safepoint_check_never);
def(JfrStacktrace_lock , PaddedMutex , special, true, _safepoint_check_never);
def(JfrStacktrace_lock , PaddedMutex , special - 1, true, _safepoint_check_never);
def(JfrThreadSampler_lock , PaddedMonitor, leaf, true, _safepoint_check_never);
#endif

@ -128,7 +128,7 @@ static int literal_size(oop obj) {
}
}
static int literal_size(WeakHandle<vm_class_loader_data> v) {
static int literal_size(WeakHandle<vm_weak_data> v) {
return literal_size(v.peek());
}
@ -223,7 +223,7 @@ template <class T> void print_literal(T l) {
l->print();
}
static void print_literal(WeakHandle<vm_class_loader_data> l) {
static void print_literal(WeakHandle<vm_weak_data> l) {
l.print();
}
@ -287,14 +287,14 @@ template class Hashtable<ConstantPool*, mtClass>;
template class Hashtable<Symbol*, mtSymbol>;
template class Hashtable<Klass*, mtClass>;
template class Hashtable<InstanceKlass*, mtClass>;
template class Hashtable<WeakHandle<vm_class_loader_data>, mtClass>;
template class Hashtable<WeakHandle<vm_weak_data>, mtClass>;
template class Hashtable<Symbol*, mtModule>;
template class Hashtable<oop, mtSymbol>;
template class Hashtable<Symbol*, mtClass>;
template class HashtableEntry<Symbol*, mtSymbol>;
template class HashtableEntry<Symbol*, mtClass>;
template class HashtableEntry<oop, mtSymbol>;
template class HashtableEntry<WeakHandle<vm_class_loader_data>, mtClass>;
template class HashtableEntry<WeakHandle<vm_weak_data>, mtClass>;
template class HashtableBucket<mtClass>;
template class BasicHashtableEntry<mtSymbol>;
template class BasicHashtableEntry<mtCode>;

@ -2659,7 +2659,7 @@ public final class Math {
* round it away to zero. This is done by first multiplying
* by 2 ^ (scaleFactor % n) and then multiplying several
* times by 2^n as needed where n is the exponent of number
* that is a covenient power of two. In this way, at most one
* that is a convenient power of two. In this way, at most one
* real rounding error occurs. If the double value set is
* being used exclusively, the rounding will occur on a
* multiply. If the double-extended-exponent value set is

@ -46,20 +46,21 @@ package java.lang;
* record components are declared in the record header. The list of record
* components declared in the record header form the <em>record descriptor</em>.
*
* <p>A record class has the following mandated members: a public <em>canonical
* constructor</em>, whose descriptor is the same as the record descriptor;
* <p>A record class has the following mandated members: a <em>canonical
* constructor</em>, which must provide at least as much access as the record
* class and whose descriptor is the same as the record descriptor;
* a private final field corresponding to each component, whose name and
* type are the same as that of the component; a public accessor method
* corresponding to each component, whose name and return type are the same as
* that of the component. If not explicitly declared in the body of the record,
* implicit implementations for these members are provided.
*
* <p>The implicit declaration of the canonical constructor initializes the
* component fields from the corresponding constructor arguments. The implicit
* declaration of the accessor methods returns the value of the corresponding
* component field. The implicit declaration of the {@link Object#equals(Object)},
* {@link Object#hashCode()}, and {@link Object#toString()} methods are derived
* from all of the component fields.
* <p>The implicit declaration of the canonical constructor has the same accessibility
* as the record class and initializes the component fields from the corresponding
* constructor arguments. The implicit declaration of the accessor methods returns
* the value of the corresponding component field. The implicit declaration of the
* {@link Object#equals(Object)}, {@link Object#hashCode()}, and {@link Object#toString()}
* methods are derived from all of the component fields.
*
* <p>The primary reasons to provide an explicit declaration for the
* canonical constructor or accessor methods are to validate constructor

@ -1046,7 +1046,7 @@ public class Runtime {
} else {
if (optional.isPresent() && !pre.isPresent()) {
throw new IllegalArgumentException("optional component"
+ " must be preceeded by a pre-release component"
+ " must be preceded by a pre-release component"
+ " or '+': '" + s + "'");
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 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
@ -237,7 +237,7 @@ final class StackStreamFactory {
final R walk() {
checkState(NEW);
try {
// VM will need to stablize the stack before walking. It will invoke
// VM will need to stabilize the stack before walking. It will invoke
// the AbstractStackWalker::doStackWalk method once it fetches the first batch.
// the callback will be invoked within the scope of the callStackWalk frame.
return beginStackWalk();

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 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
@ -351,7 +351,7 @@ abstract class ClassSpecializer<T,K,S extends ClassSpecializer<T,K,S>.SpeciesDat
* You can override this to return null or throw if there are no transforms.
* This method exists so that the transforms can be "grown" lazily.
* This is necessary if the transform *adds* a field to an instance,
* which sometimtes requires the creation, on the fly, of an extended species.
* which sometimes requires the creation, on the fly, of an extended species.
* This method is only called once for any particular parameter.
* The species caches the result in a private array.
*

@ -35,7 +35,7 @@ import java.util.function.BiFunction;
/**
* An indirect var handle can be thought of as an aggregate of the method handles implementing its supported access modes.
* Its varform contains no method name table (given that some of the method handles composing a bound var handle might
* not be direct). The set of method handles constituting an inditrect var handle are retrieved lazily, to minimize
* not be direct). The set of method handles constituting an indirect var handle are retrieved lazily, to minimize
* code spinning (since not all the access modes will be used anyway).
* Indirect var handles are useful when constructing var handle adapters - that is, an adapter var handle
* can be constructed by extracting the method handles constituting the target var handle, adapting them

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 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
@ -801,7 +801,7 @@ class LambdaForm {
* (a) redundant compilation work and (b) extra I$ pressure.
* To control repeated versions, we need to be ready to
* erase details from LFs and move them into MH data,
* whevener those details are not relevant to significant
* whenever those details are not relevant to significant
* optimization. "Significant" means optimization of
* code that is actually hot.
*
@ -895,7 +895,7 @@ class LambdaForm {
private static boolean argumentTypesMatch(String sig, Object[] av) {
int arity = signatureArity(sig);
assert(av.length == arity) : "av.length == arity: av.length=" + av.length + ", arity=" + arity;
assert(av[0] instanceof MethodHandle) : "av[0] not instace of MethodHandle: " + av[0];
assert(av[0] instanceof MethodHandle) : "av[0] not instance of MethodHandle: " + av[0];
MethodHandle mh = (MethodHandle) av[0];
MethodType mt = mh.type();
assert(mt.parameterCount() == arity-1);

@ -1685,7 +1685,7 @@ assertEquals("[three, thee, tee]", asListFix.invoke((Object)argv).toString());
if (member != null) {
return MethodHandleImpl.makeWrappedMember(this, member, isInvokeSpecial);
} else if (internalMemberName() == null) {
// The required internaMemberName is null, and this MH (like most) doesn't have one.
// The required internalMemberName is null, and this MH (like most) doesn't have one.
return this;
} else {
// The following case is rare. Mask the internalMemberName by wrapping the MH in a BMH.

@ -33,7 +33,7 @@ import static java.lang.invoke.MethodHandleStatics.*;
/**
* A symbolic reference obtained by cracking a direct method handle
* into its consitutent symbolic parts.
* into its constituent symbolic parts.
* To crack a direct method handle, call {@link Lookup#revealDirect Lookup.revealDirect}.
* <h2><a id="directmh"></a>Direct Method Handles</h2>
* A <em>direct method handle</em> represents a method, constructor, or field without

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 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
@ -510,7 +510,7 @@ class MethodHandleNatives {
/**
* Obtain the method to link to the VarHandle operation.
* This method is located here and not in Invokers to avoid
* intializing that and other classes early on in VM bootup.
* initializing that and other classes early on in VM bootup.
*/
private static MemberName varHandleOperationLinkerMethod(String name,
MethodType mtype,

@ -105,7 +105,7 @@ import static java.lang.invoke.MethodType.fromDescriptor;
* A {@code MethodType} can be described in {@linkplain MethodTypeDesc nominal form}
* if and only if all of the parameter types and return type can be described
* with a {@link Class#describeConstable() nominal descriptor} represented by
* {@link ClassDesc}. If a method type can be described norminally, then:
* {@link ClassDesc}. If a method type can be described nominally, then:
* <ul>
* <li>The method type has a {@link MethodTypeDesc nominal descriptor}
* returned by {@link #describeConstable() MethodType::describeConstable}.</li>

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 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
@ -2031,7 +2031,7 @@ public abstract class VarHandle implements Constable {
insertParameterTypes(0, VarHandle.class);
MemberName mn = vform.getMemberName(mode);
DirectMethodHandle dmh = DirectMethodHandle.make(mn);
// Such a method handle must not be publically exposed directly
// Such a method handle must not be publicly exposed directly
// otherwise it can be cracked, it must be transformed or rebound
// before exposure
MethodHandle mh = dmh.copyWith(mt, dmh.form);
@ -2191,7 +2191,7 @@ public abstract class VarHandle implements Constable {
* Returns a {@linkplain VarHandleDesc} corresponding to a {@link VarHandle}
* for an instance field.
*
* @param name the unqualifed name of the field
* @param name the unqualified name of the field
* @param declaringClass a {@link ClassDesc} describing the declaring class,
* for field var handles
* @param fieldType a {@link ClassDesc} describing the type of the field

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009, 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
@ -68,17 +68,17 @@ import jdk.internal.module.ModuleInfo;
* #read(InputStream,Supplier) read} methods defined here. </p>
*
* <p> A module descriptor describes a <em>normal</em>, open, or automatic
* module. <em>Normal</em> modules and open modules describe their {@link
* module. <em>Normal</em> modules and open modules describe their {@linkplain
* #requires() dependences}, {@link #exports() exported-packages}, the services
* that they {@link #uses() use} or {@link #provides() provide}, and other
* components. <em>Normal</em> modules may {@link #opens() open} specific
* packages. The module descriptor for an open modules does not declare any
* that they {@linkplain #uses() use} or {@linkplain #provides() provide}, and other
* components. <em>Normal</em> modules may {@linkplain #opens() open} specific
* packages. The module descriptor for an open module does not declare any
* open packages (its {@code opens} method returns an empty set) but when
* instantiated in the Java virtual machine then it is treated as if all
* packages are open. The module descriptor for an automatic module does not
* declare any dependences (except for the mandatory dependency on {@code
* java.base}), and does not declare any exported or open packages. Automatic
* module receive special treatment during resolution so that they read all
* modules receive special treatment during resolution so that they read all
* other modules in the configuration. When an automatic module is instantiated
* in the Java virtual machine then it reads every unnamed module and is
* treated as if all packages are exported and open. </p>
@ -131,7 +131,7 @@ public class ModuleDescriptor
/**
* <p> A dependence upon a module </p>
* <p> A dependence upon a module. </p>
*
* @see ModuleDescriptor#requires()
* @since 9
@ -607,7 +607,7 @@ public class ModuleDescriptor
private final Set<String> targets; // empty if unqualified export
/**
* Constructs an Opens
* Constructs an {@code Opens}.
*/
private Opens(Set<Modifier> ms, String source, Set<String> targets) {
this.mods = Set.copyOf(ms);
@ -634,9 +634,9 @@ public class ModuleDescriptor
}
/**
* Returns {@code true} if this is a qualified opens.
* Returns {@code true} if this is a qualified {@code Opens}.
*
* @return {@code true} if this is a qualified opens
* @return {@code true} if this is a qualified {@code Opens}
*/
public boolean isQualified() {
return !targets.isEmpty();
@ -652,19 +652,19 @@ public class ModuleDescriptor
}
/**
* For a qualified opens, returns the non-empty and immutable set
* For a qualified {@code Opens}, returns the non-empty and immutable set
* of the module names to which the package is open. For an
* unqualified opens, returns an empty set.
* unqualified {@code Opens}, returns an empty set.
*
* @return The set of target module names or for an unqualified
* opens, an empty set
* {@code Opens}, an empty set
*/
public Set<String> targets() {
return targets;
}
/**
* Compares this module opens to another.
* Compares this module {@code Opens} to another.
*
* <p> Two {@code Opens} objects are compared by comparing the package
* names lexicographically. Where the packages names are equal then the
@ -680,11 +680,11 @@ public class ModuleDescriptor
* set. </p>
*
* @param that
* The module opens to compare
* The module {@code Opens} to compare
*
* @return A negative integer, zero, or a positive integer if this module
* opens is less than, equal to, or greater than the given
* module opens
* {@code Opens} is less than, equal to, or greater than the given
* module {@code Opens}
*/
@Override
public int compareTo(Opens that) {
@ -710,14 +710,14 @@ public class ModuleDescriptor
}
/**
* Computes a hash code for this module opens.
* Computes a hash code for this module {@code Opens}.
*
* <p> The hash code is based upon the modifiers, the package name,
* and for a qualified opens, the set of modules names to which the
* and for a qualified {@code Opens}, the set of modules names to which the
* package is opened. It satisfies the general contract of the
* {@link Object#hashCode Object.hashCode} method.
*
* @return The hash-code value for this module opens
* @return The hash-code value for this module {@code Opens}
*/
@Override
public int hashCode() {
@ -727,7 +727,7 @@ public class ModuleDescriptor
}
/**
* Tests this module opens for equality with the given object.
* Tests this module {@code Opens} for equality with the given object.
*
* <p> If the given object is not an {@code Opens} then this method
* returns {@code false}. Two {@code Opens} objects are equal if their
@ -810,7 +810,7 @@ public class ModuleDescriptor
public List<String> providers() { return providers; }
/**
* Compares this provides to another.
* Compares this {@code Provides} to another.
*
* <p> Two {@code Provides} objects are compared by comparing the fully
* qualified class name of the service type lexicographically. Where the
@ -824,8 +824,9 @@ public class ModuleDescriptor
* @param that
* The {@code Provides} to compare
*
* @return A negative integer, zero, or a positive integer if this provides
* is less than, equal to, or greater than the given provides
* @return A negative integer, zero, or a positive integer if this
* {@code Provides} is less than, equal to, or greater than
* the given {@code Provides}
*/
public int compareTo(Provides that) {
if (this == that) return 0;
@ -850,7 +851,7 @@ public class ModuleDescriptor
}
/**
* Computes a hash code for this provides.
* Computes a hash code for this {@code Provides}.
*
* <p> The hash code is based upon the service type and the set of
* providers. It satisfies the general contract of the {@link
@ -864,7 +865,7 @@ public class ModuleDescriptor
}
/**
* Tests this provides for equality with the given object.
* Tests this {@code Provides} for equality with the given object.
*
* <p> If the given object is not a {@code Provides} then this method
* returns {@code false}. Two {@code Provides} objects are equal if the
@ -889,9 +890,9 @@ public class ModuleDescriptor
}
/**
* Returns a string describing this provides.
* Returns a string describing this {@code Provides}.
*
* @return A string describing this provides
* @return A string describing this {@code Provides}
*/
@Override
public String toString() {
@ -1416,7 +1417,7 @@ public class ModuleDescriptor
/**
* <p> Returns the string with the possibly-unparseable version of the
* module </p>
* module. </p>
*
* @return The string containing the version of the module or an empty
* {@code Optional} if the module does not have a version

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 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
@ -183,7 +183,7 @@ public interface ModuleReader extends Closeable {
}
/**
* Release a byte buffer. This method should be invoked after consuming
* Releases a byte buffer. This method should be invoked after consuming
* the contents of the buffer returned by the {@code read} method.
* The behavior of this method when invoked to release a buffer that has
* already been released, or the behavior when invoked to release a buffer

@ -138,8 +138,7 @@ public class DatagramSocket implements java.io.Closeable {
/**
* Constructs a datagram socket and binds it to any available port
* on the local host machine. The socket will be bound to the
* {@link InetAddress#isAnyLocalAddress wildcard} address,
* an IP address chosen by the kernel.
* {@link InetAddress#isAnyLocalAddress wildcard} address.
*
* <p>If there is a security manager,
* its {@code checkListen} method is first called
@ -147,7 +146,7 @@ public class DatagramSocket implements java.io.Closeable {
* This could result in a SecurityException.
*
* @throws SocketException if the socket could not be opened,
* or the socket could not bind to the specified local port.
* or the socket could not be bound.
* @throws SecurityException if a security manager exists and its
* {@code checkListen} method doesn't allow the operation.
*
@ -173,7 +172,7 @@ public class DatagramSocket implements java.io.Closeable {
* Creates a datagram socket, bound to the specified local
* socket address.
* <p>
* If, if the address is {@code null}, creates an unbound socket.
* If the address is {@code null} an unbound socket will be created.
*
* <p>If there is a security manager,
* its {@code checkListen} method is first called
@ -201,8 +200,7 @@ public class DatagramSocket implements java.io.Closeable {
/**
* Constructs a datagram socket and binds it to the specified port
* on the local host machine. The socket will be bound to the
* {@link InetAddress#isAnyLocalAddress wildcard} address,
* an IP address chosen by the kernel.
* {@link InetAddress#isAnyLocalAddress wildcard} address.
*
* <p>If there is a security manager,
* its {@code checkListen} method is first called
@ -231,9 +229,9 @@ public class DatagramSocket implements java.io.Closeable {
* 65535 inclusive. A port number of {@code zero} will let the system pick
* up an ephemeral port in a {@code bind} operation.
* <p>
* If the IP address is 0.0.0.0, the socket will be bound to the
* {@link InetAddress#isAnyLocalAddress wildcard} address,
* an IP address chosen by the kernel.
* If the IP address is a {@link InetAddress#isAnyLocalAddress wildcard}
* address, or is {@code null}, the socket will be bound to the wildcard
* address.
*
* <p>If there is a security manager,
* its {@code checkListen} method is first called
@ -242,7 +240,7 @@ public class DatagramSocket implements java.io.Closeable {
* This could result in a SecurityException.
*
* @param port local port to use in the bind operation.
* @param laddr local address to bind
* @param laddr local address to bind (can be {@code null})
*
* @throws SocketException if the socket could not be opened,
* or the socket could not bind to the specified local port.

@ -147,7 +147,9 @@ public class MulticastSocket extends DatagramSocket {
/**
* Create a multicast socket.
* Constructs a multicast socket and binds it to any available port
* on the local host machine. The socket will be bound to the
* {@link InetAddress#isAnyLocalAddress wildcard} address.
*
* <p>
* If there is a security manager, its {@code checkListen} method is first
@ -171,7 +173,9 @@ public class MulticastSocket extends DatagramSocket {
}
/**
* Create a multicast socket and bind it to a specific port.
* Constructs a multicast socket and binds it to the specified port
* on the local host machine. The socket will be bound to the
* {@link InetAddress#isAnyLocalAddress wildcard} address.
*
* <p>If there is a security manager,
* its {@code checkListen} method is first called
@ -188,6 +192,9 @@ public class MulticastSocket extends DatagramSocket {
* while creating the MulticastSocket
* @throws SecurityException if a security manager exists and its
* {@code checkListen} method doesn't allow the operation.
* @throws IllegalArgumentException if port is <a href="DatagramSocket.html#PortRange">
* out of range.</a>
*
* @see SecurityManager#checkListen
* @see java.net.DatagramSocket#setReuseAddress(boolean)
*/
@ -196,9 +203,10 @@ public class MulticastSocket extends DatagramSocket {
}
/**
* Create a MulticastSocket bound to the specified socket address.
* Creates a multicast socket, bound to the specified local
* socket address.
* <p>
* Or, if the address is {@code null}, create an unbound socket.
* If the address is {@code null} an unbound socket will be created.
*
* <p>If there is a security manager,
* its {@code checkListen} method is first called

@ -1469,7 +1469,7 @@ public final class DateTimeFormatter {
/**
* Returns a copy of this formatter with localized values of the locale,
* calendar, region, decimal style and/or timezone, that supercede values in
* calendar, region, decimal style and/or timezone, that supersede values in
* this formatter.
* <p>
* This is used to lookup any part of the formatter needing specific
@ -1489,16 +1489,12 @@ public final class DateTimeFormatter {
*
* @param locale the locale, not null
* @return a formatter based on this formatter with localized values of
* the calendar, decimal style and/or timezone, that supercede values in this
* the calendar, decimal style and/or timezone, that supersede values in this
* formatter.
* @see #withLocale(Locale)
* @since 10
*/
public DateTimeFormatter localizedBy(Locale locale) {
if (this.locale.equals(locale)) {
return this;
}
// Override decimalStyle/chronology/timezone for the locale object
String tzType = locale.getUnicodeLocaleType("tz");
ZoneId z = tzType != null ?
@ -1506,13 +1502,16 @@ public final class DateTimeFormatter {
.map(ZoneId::of)
.orElse(zone) :
zone;
return new DateTimeFormatter(printerParser,
locale,
DecimalStyle.of(locale),
resolverStyle,
resolverFields,
Chronology.ofLocale(locale),
z);
Chronology c = Chronology.ofLocale(locale);
DecimalStyle ds = DecimalStyle.of(locale);
if (this.locale.equals(locale) &&
c.equals(chrono) &&
ds.equals(decimalStyle) &&
Objects.equals(z, zone)) {
return this;
} else {
return new DateTimeFormatter(printerParser, locale, ds, resolverStyle, resolverFields, c, z);
}
}
//-----------------------------------------------------------------------

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 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
@ -94,7 +94,7 @@ public final class ServicesCatalog {
}
/**
* Returns the list of service provides for the given service type
* Returns the list of service providers for the given service type
* name, creating it if needed.
*/
private List<ServiceProvider> providers(String service) {
@ -132,7 +132,7 @@ public final class ServicesCatalog {
}
/**
* Add a provider in the given module to this services catalog
* Adds a provider in the given module to this services catalog.
*
* @apiNote This method is for use by java.lang.instrument
*/

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 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
@ -274,6 +274,17 @@ enum SignatureScheme {
Arrays.asList(handshakeSupportedProtocols);
boolean mediator = true;
// Disable EdDSA algorithms for TLS. Remove this when support is added.
if (id == 0x0807 || id == 0x0808) {
mediator = false;
if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
SSLLogger.warning(
"Signature algorithm, " + algorithm +
", not supported by JSSE");
}
}
// An EC provider, for example the SunEC provider, may support
// AlgorithmParameters but not KeyPairGenerator or Signature.
//

@ -1,5 +1,5 @@
/*
* Copyright (c) 2006, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@ -51,7 +51,7 @@ import org.xml.sax.SAXException;
* serializers (xml, html, text ...) that write output to a stream.
*
* @xsl.usage internal
* @LastModified: Aug 2019
* @LastModified: June 2020
*/
abstract public class ToStream extends SerializerBase {
@ -1354,7 +1354,7 @@ abstract public class ToStream extends SerializerBase {
// characters to read from array is 0.
// Section 7.6.1 of XSLT 1.0 (http://www.w3.org/TR/xslt#value-of) suggest no text node
// is created if string is empty.
if (length == 0 || (isInEntityRef()))
if (length == 0 || (isInEntityRef() && !m_expandDTDEntities))
return;
final boolean shouldNotFormat = !shouldFormatOutput();
@ -1668,7 +1668,7 @@ abstract public class ToStream extends SerializerBase {
*/
public void characters(String s) throws org.xml.sax.SAXException
{
if (isInEntityRef())
if (isInEntityRef() && !m_expandDTDEntities)
return;
final int length = s.length();
if (length > m_charsBuff.length)
@ -2514,7 +2514,7 @@ abstract public class ToStream extends SerializerBase {
m_inExternalDTD = true;
// if this is not the magic [dtd] name
if (!m_inExternalDTD) {
if (!m_expandDTDEntities && !m_inExternalDTD) {
// if it's not in nested entity reference
if (!isInEntityRef()) {
if (shouldFormatOutput()) {

@ -803,6 +803,7 @@ public class Checker extends DocTreePathScanner<Void, Void> {
@Override @DefinedBy(Api.COMPILER_TREE)
public Void visitIndex(IndexTree tree, Void ignore) {
markEnclosingTag(Flag.HAS_INLINE_TAG);
for (TagStackItem tsi : tagStack) {
if (tsi.tag == HtmlTag.A) {
env.messages.warning(HTML, tree, "dc.tag.a.within.a",
@ -956,6 +957,7 @@ public class Checker extends DocTreePathScanner<Void, Void> {
@Override @DefinedBy(Api.COMPILER_TREE)
public Void visitSummary(SummaryTree node, Void aVoid) {
markEnclosingTag(Flag.HAS_INLINE_TAG);
int idx = env.currDocComment.getFullBody().indexOf(node);
// Warn if the node is preceded by non-whitespace characters,
// or other non-text nodes.
@ -967,6 +969,7 @@ public class Checker extends DocTreePathScanner<Void, Void> {
@Override @DefinedBy(Api.COMPILER_TREE)
public Void visitSystemProperty(SystemPropertyTree tree, Void ignore) {
markEnclosingTag(Flag.HAS_INLINE_TAG);
for (TagStackItem tsi : tagStack) {
if (tsi.tag == HtmlTag.A) {
env.messages.warning(HTML, tree, "dc.tag.a.within.a",
@ -1041,6 +1044,7 @@ public class Checker extends DocTreePathScanner<Void, Void> {
@Override @DefinedBy(Api.COMPILER_TREE)
public Void visitUnknownInlineTag(UnknownInlineTagTree tree, Void ignore) {
markEnclosingTag(Flag.HAS_INLINE_TAG);
checkUnknownTag(tree, tree.getTagName());
return super.visitUnknownInlineTag(tree, ignore);
}

@ -464,31 +464,50 @@ public class JavacTrees extends DocTrees {
private Symbol attributeDocReference(TreePath path, DCReference ref) {
Env<AttrContext> env = getAttrContext(path);
if (env == null) return null;
if (ref.moduleName != null && ref.qualifierExpression == null && ref.memberName != null) {
// module name and member name without type
return null;
}
Log.DeferredDiagnosticHandler deferredDiagnosticHandler =
new Log.DeferredDiagnosticHandler(log);
try {
final TypeSymbol tsym;
final Name memberName;
final ModuleSymbol mdlsym;
if (ref.moduleName != null) {
mdlsym = modules.modulesInitialized() ?
modules.getObservableModule(names.fromString(ref.moduleName.toString()))
: null;
if (mdlsym == null) {
return null;
} else if (ref.qualifierExpression == null) {
return mdlsym;
}
} else {
mdlsym = modules.getDefaultModule();
}
if (ref.qualifierExpression == null) {
tsym = env.enclClass.sym;
memberName = (Name) ref.memberName;
} else {
// newSeeTree if the qualifierExpression is a type or package name.
// javac does not provide the exact method required, so
// we first check if qualifierExpression identifies a type,
// and if not, then we check to see if it identifies a package.
Type t = attr.attribType(ref.qualifierExpression, env);
if (t.isErroneous()) {
// Check if qualifierExpression is a type or package, using the methods javac provides.
// If no module name is given we check if qualifierExpression identifies a type.
// If that fails or we have a module name, use that to resolve qualifierExpression to
// a package or type.
Type t = ref.moduleName == null ? attr.attribType(ref.qualifierExpression, env) : null;
if (t == null || t.isErroneous()) {
JCCompilationUnit toplevel =
treeMaker.TopLevel(List.nil());
final ModuleSymbol msym = modules.getDefaultModule();
toplevel.modle = msym;
toplevel.packge = msym.unnamedPackage;
toplevel.modle = mdlsym;
toplevel.packge = mdlsym.unnamedPackage;
Symbol sym = attr.attribIdent(ref.qualifierExpression, toplevel);
if (sym == null)
if (sym == null) {
return null;
}
sym.complete();
@ -500,7 +519,15 @@ public class JavacTrees extends DocTrees {
return null;
}
} else {
if (ref.qualifierExpression.hasTag(JCTree.Tag.IDENT)) {
if (modules.modulesInitialized() && ref.moduleName == null && ref.memberName == null) {
// package/type does not exist, check if there is a matching module
ModuleSymbol moduleSymbol = modules.getObservableModule(names.fromString(ref.signature));
if (moduleSymbol != null) {
return moduleSymbol;
}
}
if (ref.qualifierExpression.hasTag(JCTree.Tag.IDENT) && ref.moduleName == null
&& ref.memberName == null) {
// fixup: allow "identifier" instead of "#identifier"
// for compatibility with javadoc
tsym = env.enclClass.sym;
@ -513,7 +540,7 @@ public class JavacTrees extends DocTrees {
Type e = t;
// If this is an array type convert to element type
while (e instanceof ArrayType)
e = ((ArrayType)e).elemtype;
e = ((ArrayType) e).elemtype;
tsym = e.tsym;
memberName = (Name) ref.memberName;
}

@ -428,9 +428,9 @@ public class DocCommentParser {
* Matching pairs of {@literal < >} are skipped. The text is terminated by the first
* unmatched }. It is an error if the beginning of the next tag is detected.
*/
// TODO: allowMember is currently ignored
// TODO: boolean allowMember should be enum FORBID, ALLOW, REQUIRE
// TODO: improve quality of parse to forbid bad constructions.
// TODO: update to use ReferenceParser
@SuppressWarnings("fallthrough")
protected DCReference reference(boolean allowMember) throws ParseException {
int pos = bp;
@ -485,91 +485,17 @@ public class DocCommentParser {
String sig = newString(pos, bp);
// Break sig apart into qualifiedExpr member paramTypes.
JCTree qualExpr;
Name member;
List<JCTree> paramTypes;
Log.DeferredDiagnosticHandler deferredDiagnosticHandler
= new Log.DeferredDiagnosticHandler(fac.log);
try {
int hash = sig.indexOf("#");
int lparen = sig.indexOf("(", hash + 1);
if (hash == -1) {
if (lparen == -1) {
qualExpr = parseType(sig);
member = null;
} else {
qualExpr = null;
member = parseMember(sig.substring(0, lparen));
}
} else {
qualExpr = (hash == 0) ? null : parseType(sig.substring(0, hash));
if (lparen == -1)
member = parseMember(sig.substring(hash + 1));
else
member = parseMember(sig.substring(hash + 1, lparen));
}
if (lparen < 0) {
paramTypes = null;
} else {
int rparen = sig.indexOf(")", lparen);
if (rparen != sig.length() - 1)
throw new ParseException("dc.ref.bad.parens");
paramTypes = parseParams(sig.substring(lparen + 1, rparen));
}
if (!deferredDiagnosticHandler.getDiagnostics().isEmpty())
throw new ParseException("dc.ref.syntax.error");
} finally {
fac.log.popDiagnosticHandler(deferredDiagnosticHandler);
ReferenceParser.Reference ref = new ReferenceParser(fac).parse(sig);
return m.at(pos).newReferenceTree(sig,
ref.moduleName, ref.qualExpr,
ref.member, ref.paramTypes)
.setEndPos(bp);
} catch (ReferenceParser.ParseException parseException) {
throw new ParseException(parseException.getMessage());
}
return m.at(pos).newReferenceTree(sig, qualExpr, member, paramTypes).setEndPos(bp);
}
JCTree parseType(String s) throws ParseException {
JavacParser p = fac.newParser(s, false, false, false);
JCTree tree = p.parseType();
if (p.token().kind != TokenKind.EOF)
throw new ParseException("dc.ref.unexpected.input");
return tree;
}
Name parseMember(String s) throws ParseException {
JavacParser p = fac.newParser(s, false, false, false);
Name name = p.ident();
if (p.token().kind != TokenKind.EOF)
throw new ParseException("dc.ref.unexpected.input");
return name;
}
List<JCTree> parseParams(String s) throws ParseException {
if (s.trim().isEmpty())
return List.nil();
JavacParser p = fac.newParser(s.replace("...", "[]"), false, false, false);
ListBuffer<JCTree> paramTypes = new ListBuffer<>();
paramTypes.add(p.parseType());
if (p.token().kind == TokenKind.IDENTIFIER)
p.nextToken();
while (p.token().kind == TokenKind.COMMA) {
p.nextToken();
paramTypes.add(p.parseType());
if (p.token().kind == TokenKind.IDENTIFIER)
p.nextToken();
}
if (p.token().kind != TokenKind.EOF)
throw new ParseException("dc.ref.unexpected.input");
return paramTypes.toList();
}
/**

@ -47,6 +47,7 @@ public class ReferenceParser {
* Any, but not all, of the member fields may be null.
*/
static public class Reference {
public final JCTree.JCExpression moduleName;
/** The type, if any, in the signature. */
public final JCTree qualExpr;
/** The member name, if any, in the signature. */
@ -54,7 +55,8 @@ public class ReferenceParser {
/** The parameter types, if any, in the signature. */
public final List<JCTree> paramTypes;
Reference(JCTree qualExpr, Name member, List<JCTree> paramTypes) {
Reference(JCTree.JCExpression moduleName, JCTree qualExpr, Name member, List<JCTree> paramTypes) {
this.moduleName = moduleName;
this.qualExpr = qualExpr;
this.member = member;
this.paramTypes = paramTypes;
@ -89,7 +91,8 @@ public class ReferenceParser {
*/
public Reference parse(String sig) throws ParseException {
// Break sig apart into qualifiedExpr member paramTypes.
// Break sig apart into moduleName qualifiedExpr member paramTypes.
JCTree.JCExpression moduleName;
JCTree qualExpr;
Name member;
List<JCTree> paramTypes;
@ -98,18 +101,27 @@ public class ReferenceParser {
= new Log.DeferredDiagnosticHandler(fac.log);
try {
int hash = sig.indexOf("#");
int lparen = sig.indexOf("(", hash + 1);
if (hash == -1) {
int slash = sig.indexOf("/");
int hash = sig.indexOf("#", slash + 1);
int lparen = sig.indexOf("(", Math.max(slash, hash) + 1);
if (slash > -1) {
moduleName = parseModule(sig.substring(0, slash));
} else {
moduleName = null;
}
if (slash > 0 && sig.length() == slash + 1) {
qualExpr = null;
member = null;
} else if (hash == -1) {
if (lparen == -1) {
qualExpr = parseType(sig);
qualExpr = parseType(sig.substring(slash + 1));
member = null;
} else {
qualExpr = null;
member = parseMember(sig.substring(0, lparen));
member = parseMember(sig.substring(slash + 1, lparen));
}
} else {
qualExpr = (hash == 0) ? null : parseType(sig.substring(0, hash));
qualExpr = (hash == slash + 1) ? null : parseType(sig.substring(slash + 1, hash));
if (lparen == -1)
member = parseMember(sig.substring(hash + 1));
else
@ -132,7 +144,15 @@ public class ReferenceParser {
fac.log.popDiagnosticHandler(deferredDiagnosticHandler);
}
return new Reference(qualExpr, member, paramTypes);
return new Reference(moduleName, qualExpr, member, paramTypes);
}
private JCTree.JCExpression parseModule(String s) throws ParseException {
JavacParser p = fac.newParser(s, false, false, false);
JCTree.JCExpression expr = p.qualident(false);
if (p.token().kind != TokenKind.EOF)
throw new ParseException("dc.ref.unexpected.input");
return expr;
}
private JCTree parseType(String s) throws ParseException {

@ -647,13 +647,15 @@ public abstract class DCTree implements DocTree {
// The following are not directly exposed through ReferenceTree
// use DocTrees.getElement(DocTreePath)
public final JCTree.JCExpression moduleName;
public final JCTree qualifierExpression;
public final Name memberName;
public final List<JCTree> paramTypes;
DCReference(String signature, JCTree qualExpr, Name member, List<JCTree> paramTypes) {
DCReference(String signature, JCTree.JCExpression moduleName, JCTree qualExpr, Name member, List<JCTree> paramTypes) {
this.signature = signature;
this.moduleName = moduleName;
qualifierExpression = qualExpr;
memberName = member;
this.paramTypes = paramTypes;

@ -378,7 +378,7 @@ public class DocTreeMaker implements DocTreeFactory {
public DCReference newReferenceTree(String signature) {
try {
ReferenceParser.Reference ref = referenceParser.parse(signature);
DCReference tree = new DCReference(signature, ref.qualExpr, ref.member, ref.paramTypes);
DCReference tree = new DCReference(signature, ref.moduleName, ref.qualExpr, ref.member, ref.paramTypes);
tree.pos = pos;
return tree;
} catch (ReferenceParser.ParseException e) {
@ -386,8 +386,8 @@ public class DocTreeMaker implements DocTreeFactory {
}
}
public DCReference newReferenceTree(String signature, JCTree qualExpr, Name member, List<JCTree> paramTypes) {
DCReference tree = new DCReference(signature, qualExpr, member, paramTypes);
public DCReference newReferenceTree(String signature, JCTree.JCExpression moduleName, JCTree qualExpr, Name member, List<JCTree> paramTypes) {
DCReference tree = new DCReference(signature, moduleName, qualExpr, member, paramTypes);
tree.pos = pos;
return tree;
}

@ -998,7 +998,7 @@ public class HtmlDocletWriter {
CommentHelper ch = utils.getCommentHelper(element);
String tagName = ch.getTagName(see);
String seetext = replaceDocRootDir(utils.normalizeNewlines(ch.getText(see)).toString());
String seetext = replaceDocRootDir(removeTrailingSlash(utils.normalizeNewlines(ch.getText(see)).toString()));
// Check if @see is an href or "string"
if (seetext.startsWith("<") || seetext.startsWith("\"")) {
return new RawHtml(seetext);
@ -1010,7 +1010,6 @@ public class HtmlDocletWriter {
Content text = plainOrCode(kind == LINK_PLAIN, new RawHtml(seetext));
TypeElement refClass = ch.getReferencedClass(see);
String refClassName = ch.getReferencedClassName(see);
Element refMem = ch.getReferencedMember(see);
String refMemName = ch.getReferencedMemberName(see);
@ -1018,6 +1017,10 @@ public class HtmlDocletWriter {
refMemName = refMem.toString();
}
if (refClass == null) {
ModuleElement refModule = ch.getReferencedModule(see);
if (refModule != null && utils.isIncluded(refModule)) {
return getModuleLink(refModule, label.isEmpty() ? text : label);
}
//@see is not referencing an included class
PackageElement refPackage = ch.getReferencedPackage(see);
if (refPackage != null && utils.isIncluded(refPackage)) {
@ -1028,9 +1031,11 @@ public class HtmlDocletWriter {
return getPackageLink(refPackage, label);
} else {
// @see is not referencing an included class, module or package. Check for cross links.
DocLink elementCrossLink = (configuration.extern.isModule(refClassName))
? getCrossModuleLink(utils.elementUtils.getModuleElement(refClassName)) :
(refPackage != null) ? getCrossPackageLink(refPackage) : null;
String refModuleName = ch.getReferencedModuleName(see);
DocLink elementCrossLink = (refPackage != null) ? getCrossPackageLink(refPackage) :
(configuration.extern.isModule(refModuleName))
? getCrossModuleLink(utils.elementUtils.getModuleElement(refModuleName))
: null;
if (elementCrossLink != null) {
// Element cross link found
return links.createLink(elementCrossLink,
@ -1118,6 +1123,10 @@ public class HtmlDocletWriter {
}
}
private String removeTrailingSlash(String s) {
return s.endsWith("/") ? s.substring(0, s.length() -1) : s;
}
private Content plainOrCode(boolean plain, Content body) {
return (plain || body.isEmpty()) ? body : HtmlTree.CODE(body);
}

@ -38,6 +38,7 @@ import java.net.URI;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -74,10 +75,18 @@ public class CommentUtils {
final Utils utils;
final Resources resources;
final DocTreeFactory treeFactory;
final HashMap<Element, DocCommentDuo> dcTreesMap = new HashMap<>();
final DocTrees trees;
final Elements elementUtils;
/**
* A map for storing automatically generated comments for various
* elements, such as mandated elements (Enum.values, Enum.valueOf, etc)
* and JavaFX properties.
*
* @see Utils#dcTreeCache
*/
final HashMap<Element, DocCommentInfo> dcInfoMap = new HashMap<>();
protected CommentUtils(BaseConfiguration configuration) {
this.configuration = configuration;
utils = configuration.utils;
@ -133,7 +142,7 @@ public class CommentUtils {
List<DocTree> tags = new ArrayList<>();
tags.add(treeFactory.newReturnTree(descriptions));
DocCommentTree docTree = treeFactory.newDocCommentTree(fullBody, tags);
dcTreesMap.put(ee, new DocCommentDuo(null, docTree));
dcInfoMap.put(ee, new DocCommentInfo(null, docTree));
}
public void setEnumValueOfTree(ExecutableElement ee) {
@ -167,7 +176,7 @@ public class CommentUtils {
DocCommentTree docTree = treeFactory.newDocCommentTree(fullBody, tags);
dcTreesMap.put(ee, new DocCommentDuo(null, docTree));
dcInfoMap.put(ee, new DocCommentInfo(null, docTree));
}
/**
@ -190,7 +199,7 @@ public class CommentUtils {
}
DocCommentTree docTree = treeFactory.newDocCommentTree(fullBody, tags);
dcTreesMap.put(ee, new DocCommentDuo(null, docTree));
dcInfoMap.put(ee, new DocCommentInfo(null, docTree));
}
/**
@ -226,7 +235,7 @@ public class CommentUtils {
TreePath treePath = utils.getTreePath(ee.getEnclosingElement());
DocCommentTree docTree = treeFactory.newDocCommentTree(fullBody, List.of(paramTree, returnTree));
dcTreesMap.put(ee, new DocCommentDuo(treePath, docTree));
dcInfoMap.put(ee, new DocCommentInfo(treePath, docTree));
}
private void add(List<DocTree> contents, String resourceKey) {
@ -262,7 +271,7 @@ public class CommentUtils {
List.of(makeTextTreeForResource("doclet.record_hashCode_doc.return")));
DocCommentTree docTree = treeFactory.newDocCommentTree(fullBody, List.of(returnTree));
dcTreesMap.put(ee, new DocCommentDuo(null, docTree));
dcInfoMap.put(ee, new DocCommentInfo(null, docTree));
}
/**
@ -277,7 +286,7 @@ public class CommentUtils {
treeFactory.newTextTree(resources.getText("doclet.record_toString_doc.return"))));
DocCommentTree docTree = treeFactory.newDocCommentTree(fullBody, List.of(returnTree));
dcTreesMap.put(ee, new DocCommentDuo(null, docTree));
dcInfoMap.put(ee, new DocCommentInfo(null, docTree));
}
/**
@ -294,7 +303,7 @@ public class CommentUtils {
makeDescriptionWithComponent("doclet.record_accessor_doc.return", te, ee.getSimpleName()));
DocCommentTree docTree = treeFactory.newDocCommentTree(fullBody, List.of(returnTree));
dcTreesMap.put(ee, new DocCommentDuo(null, docTree));
dcInfoMap.put(ee, new DocCommentInfo(null, docTree));
}
/**
@ -308,7 +317,7 @@ public class CommentUtils {
makeDescriptionWithComponent("doclet.record_field_doc.fullbody", te, ve.getSimpleName());
DocCommentTree docTree = treeFactory.newDocCommentTree(fullBody, List.of());
dcTreesMap.put(ve, new DocCommentDuo(null, docTree));
dcInfoMap.put(ve, new DocCommentInfo(null, docTree));
}
/**
@ -395,16 +404,19 @@ public class CommentUtils {
}
/*
* Returns the TreePath/DocCommentTree duo for synthesized element.
* Returns the TreePath/DocCommentTree info that has been generated for an element.
* @param e the element
* @return the info object containing the tree path and doc comment
*/
public DocCommentDuo getSyntheticCommentDuo(Element e) {
return dcTreesMap.get(e);
// "synthetic" is not the best word here, and should not be confused with synthetic elements
public DocCommentInfo getSyntheticCommentInfo(Element e) {
return dcInfoMap.get(e);
}
/*
* Returns the TreePath/DocCommentTree duo for html sources.
* Returns the TreePath/DocCommentTree info for HTML sources.
*/
public DocCommentDuo getHtmlCommentDuo(Element e) {
public DocCommentInfo getHtmlCommentInfo(Element e) {
FileObject fo = null;
PackageElement pe = null;
switch (e.getKind()) {
@ -431,7 +443,7 @@ public class CommentUtils {
return null;
}
DocTreePath treePath = trees.getDocTreePath(fo, pe);
return new DocCommentDuo(treePath.getTreePath(), dcTree);
return new DocCommentInfo(treePath.getTreePath(), dcTree);
}
public DocCommentTree parse(URI uri, String text) {
@ -447,24 +459,34 @@ public class CommentUtils {
public void setDocCommentTree(Element element, List<? extends DocTree> fullBody,
List<? extends DocTree> blockTags) {
DocCommentTree docTree = treeFactory.newDocCommentTree(fullBody, blockTags);
dcTreesMap.put(element, new DocCommentDuo(null, docTree));
dcInfoMap.put(element, new DocCommentInfo(null, docTree));
// A method having null comment (no comment) that might need to be replaced
// with a synthetic comment, remove such a comment from the cache.
// with a generated comment, remove such a comment from the cache.
utils.removeCommentHelper(element);
}
/**
* A simplistic container to transport a TreePath, DocCommentTree pair.
* Here is why we need this:
* a. not desirable to add javac's pair.
* b. DocTreePath is not a viable option either, as a null TreePath is required
* to represent synthetic comments for Enum.values, valuesOf, javafx properties.
* Info about a doc comment:
* the position in the enclosing AST, and
* the parsed doc comment itself.
*
* The position in the AST is {@code null} for automatically generated comments,
* such as for {@code Enum.values}, {@code Enum.valuesOf}, and JavaFX properties.
*/
public static class DocCommentDuo {
public static class DocCommentInfo {
/**
* The position of the comment in the enclosing AST, or {@code null}
* for automatically generated comments.
*/
public final TreePath treePath;
/**
* The doc comment tree that is the root node of a parsed doc comment,
* or {@code null} if there is no comment.
*/
public final DocCommentTree dcTree;
public DocCommentDuo(TreePath treePath, DocCommentTree dcTree) {
public DocCommentInfo(TreePath treePath, DocCommentTree dcTree) {
this.treePath = treePath;
this.dcTree = dcTree;
}

@ -31,7 +31,7 @@ import java.util.List;
import java.util.stream.Collectors;
import javax.lang.model.element.Element;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.ModuleElement;
import javax.lang.model.element.PackageElement;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.TypeMirror;
@ -376,23 +376,18 @@ public class CommentHelper {
return null;
} else if (utils.isTypeElement(e)) {
return (TypeElement) e;
} else if (!utils.isPackage(e)) {
} else if (!utils.isPackage(e) && !utils.isModule(e)) {
return utils.getEnclosingTypeElement(e);
}
return null;
}
public String getReferencedClassName(DocTree dtree) {
Utils utils = configuration.utils;
Element e = getReferencedClass(dtree);
if (e != null) {
return utils.isTypeElement(e) ? utils.getSimpleName(e) : null;
}
public String getReferencedModuleName(DocTree dtree) {
String s = getReferencedSignature(dtree);
if (s == null) {
if (s == null || s.contains("#") || s.contains("(")) {
return null;
}
int n = s.indexOf("#");
int n = s.indexOf("/");
return (n == -1) ? s : s.substring(0, n);
}
@ -423,6 +418,15 @@ public class CommentHelper {
return null;
}
public ModuleElement getReferencedModule(DocTree dtree) {
Element e = getReferencedElement(dtree);
if (e != null && configuration.utils.isModule(e)) {
return (ModuleElement) e;
}
return null;
}
public List<? extends DocTree> getFirstSentenceTrees(List<? extends DocTree> body) {
return configuration.docEnv.getDocTrees().getFirstSentence(body);
}

@ -107,7 +107,7 @@ import com.sun.source.util.TreePath;
import com.sun.tools.javac.model.JavacTypes;
import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
import jdk.javadoc.internal.doclets.toolkit.BaseOptions;
import jdk.javadoc.internal.doclets.toolkit.CommentUtils.DocCommentDuo;
import jdk.javadoc.internal.doclets.toolkit.CommentUtils.DocCommentInfo;
import jdk.javadoc.internal.doclets.toolkit.Resources;
import jdk.javadoc.internal.doclets.toolkit.WorkArounds;
import jdk.javadoc.internal.doclets.toolkit.taglets.BaseTaglet;
@ -2651,13 +2651,13 @@ public class Utils {
* @return TreePath
*/
public TreePath getTreePath(Element e) {
DocCommentDuo duo = dcTreeCache.get(e);
if (duo != null && duo.treePath != null) {
return duo.treePath;
DocCommentInfo info = dcTreeCache.get(e);
if (info != null && info.treePath != null) {
return info.treePath;
}
duo = configuration.cmtUtils.getSyntheticCommentDuo(e);
if (duo != null && duo.treePath != null) {
return duo.treePath;
info = configuration.cmtUtils.getSyntheticCommentInfo(e);
if (info != null && info.treePath != null) {
return info.treePath;
}
Map<Element, TreePath> elementToTreePath = configuration.workArounds.getElementToTreePath();
TreePath path = elementToTreePath.get(e);
@ -2668,7 +2668,14 @@ public class Utils {
return elementToTreePath.computeIfAbsent(e, docTrees::getPath);
}
private final Map<Element, DocCommentDuo> dcTreeCache = new LinkedHashMap<>();
/**
* A cache of doc comment info objects for elements.
* The entries may come from the AST and DocCommentParser, or may be autromatically
* generated comments for mandated elements and JavaFX properties.
*
* @see CommentUtils.dcInfoMap
*/
private final Map<Element, DocCommentInfo> dcTreeCache = new LinkedHashMap<>();
/**
* Retrieves the doc comments for a given element.
@ -2677,34 +2684,34 @@ public class Utils {
*/
public DocCommentTree getDocCommentTree0(Element element) {
DocCommentDuo duo = null;
DocCommentInfo info = null;
ElementKind kind = element.getKind();
if (kind == ElementKind.PACKAGE || kind == ElementKind.OTHER) {
duo = dcTreeCache.get(element); // local cache
if (duo == null && kind == ElementKind.PACKAGE) {
info = dcTreeCache.get(element); // local cache
if (info == null && kind == ElementKind.PACKAGE) {
// package-info.java
duo = getDocCommentTuple(element);
info = getDocCommentInfo(element);
}
if (duo == null) {
if (info == null) {
// package.html or overview.html
duo = configuration.cmtUtils.getHtmlCommentDuo(element); // html source
info = configuration.cmtUtils.getHtmlCommentInfo(element); // html source
}
} else {
duo = configuration.cmtUtils.getSyntheticCommentDuo(element);
if (duo == null) {
duo = dcTreeCache.get(element); // local cache
info = configuration.cmtUtils.getSyntheticCommentInfo(element);
if (info == null) {
info = dcTreeCache.get(element); // local cache
}
if (duo == null) {
duo = getDocCommentTuple(element); // get the real mccoy
if (info == null) {
info = getDocCommentInfo(element); // get the real mccoy
}
}
DocCommentTree docCommentTree = isValidDuo(duo) ? duo.dcTree : null;
TreePath path = isValidDuo(duo) ? duo.treePath : null;
DocCommentTree docCommentTree = info == null ? null : info.dcTree;
if (!dcTreeCache.containsKey(element)) {
if (docCommentTree != null && path != null) {
if (!configuration.isAllowScriptInComments()) {
TreePath path = info == null ? null : info.treePath;
if (path != null) {
if (docCommentTree != null && !configuration.isAllowScriptInComments()) {
try {
javaScriptScanner.scan(docCommentTree, path, p -> {
throw new JavaScriptScanner.Fault();
@ -2714,20 +2721,21 @@ public class Utils {
throw new UncheckedDocletException(new SimpleDocletException(text, jsf));
}
}
// run doclint even if docCommentTree is null, to trigger checks for missing comments
configuration.workArounds.runDocLint(path);
}
dcTreeCache.put(element, duo);
dcTreeCache.put(element, info);
}
return docCommentTree;
}
private DocCommentDuo getDocCommentTuple(Element element) {
private DocCommentInfo getDocCommentInfo(Element element) {
// prevent nasty things downstream with overview element
if (element.getKind() != ElementKind.OTHER) {
TreePath path = getTreePath(element);
if (path != null) {
DocCommentTree docCommentTree = docTrees.getDocCommentTree(path);
return new DocCommentDuo(path, docCommentTree);
return new DocCommentInfo(path, docCommentTree);
}
}
return null;
@ -2752,10 +2760,6 @@ public class Utils {
}
}
boolean isValidDuo(DocCommentDuo duo) {
return duo != null && duo.dcTree != null;
}
public DocCommentTree getDocCommentTree(Element element) {
CommentHelper ch = commentHelperCache.get(element);
if (ch != null) {

@ -566,7 +566,10 @@ public class ElementsTable {
continue;
if (!isMandated(mdle, rd) && onlyTransitive == rd.isTransitive()) {
if (!haveModuleSources(dep)) {
messager.printWarning(dep, "main.module_not_found", dep.getSimpleName());
if (!warnedNoSources.contains(dep)) {
messager.printWarning(dep, "main.module_source_not_found", dep.getQualifiedName());
warnedNoSources.add(dep);
}
}
result.add(dep);
} else if (isMandated(mdle, rd) && haveModuleSources(dep)) {
@ -580,9 +583,11 @@ public class ElementsTable {
return toolEnv.elements.getOrigin(mdle, rd) == MANDATED;
}
Set<ModuleElement> warnedNoSources = new HashSet<>();
Map<ModuleSymbol, Boolean> haveModuleSourcesCache = new HashMap<>();
private boolean haveModuleSources(ModuleElement mdle) throws ToolException {
ModuleSymbol msym = (ModuleSymbol)mdle;
ModuleSymbol msym = (ModuleSymbol) mdle;
if (msym.sourceLocation != null) {
return true;
}
@ -620,7 +625,7 @@ public class ElementsTable {
if (expandAll) {
// add non-public requires if needed
result.addAll(getModuleRequires(mdle, !expandAll));
result.addAll(getModuleRequires(mdle, false));
}
}

@ -269,7 +269,8 @@ main.unnecessary_arg_provided=option {0} does not require an argument
main.only_one_argument_with_equals=cannot use ''='' syntax for options that require multiple arguments
main.invalid_flag=invalid flag: {0}
main.No_modules_packages_or_classes_specified=No modules, packages or classes specified.
main.module_not_found=module {0} not found.\n
main.module_not_found=module {0} not found
main.module_source_not_found=source files for module {0} not found
main.cannot_use_sourcepath_for_modules=cannot use source path for multiple modules {0}
main.module_not_found_on_sourcepath=module {0} not found on source path
main.sourcepath_does_not_contain_module=source path does not contain module {0}

@ -217,10 +217,6 @@ public final class ExtendedSocketOptions {
Object value)
throws SocketException
{
SecurityManager sm = System.getSecurityManager();
if (sm != null)
sm.checkPermission(new NetworkPermission("setOption." + option.name()));
if (fd == null || !fd.valid())
throw new SocketException("socket closed");
@ -248,10 +244,6 @@ public final class ExtendedSocketOptions {
SocketOption<?> option)
throws SocketException
{
SecurityManager sm = System.getSecurityManager();
if (sm != null)
sm.checkPermission(new NetworkPermission("getOption." + option.name()));
if (fd == null || !fd.valid())
throw new SocketException("socket closed");

@ -212,7 +212,10 @@ public class CompressedClassPointers {
"-XX:+VerifyBeforeGC", "-version");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldContain("Narrow klass base: 0x0000000000000000");
output.shouldContain("Narrow klass shift: 0");
if (!Platform.isAArch64()) {
// Currently relax this test for Aarch64.
output.shouldContain("Narrow klass shift: 0");
}
output.shouldHaveExitValue(0);
}
@ -230,7 +233,10 @@ public class CompressedClassPointers {
"-XX:+VerifyBeforeGC", "-version");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldContain("Narrow klass base: 0x0000000000000000");
output.shouldContain("Narrow klass shift: 0");
if (!Platform.isAArch64()) {
// Currently relax this test for Aarch64.
output.shouldContain("Narrow klass shift: 0");
}
output.shouldHaveExitValue(0);
}
@ -309,9 +315,7 @@ public class CompressedClassPointers {
heapBaseMinAddressTest();
sharingTest();
boolean ccpRequiresCoop = Platform.isAArch64();
if (!ccpRequiresCoop && !Platform.isOSX()) {
if (!Platform.isOSX()) {
// Testing compressed class pointers without compressed oops.
// This is only possible if the platform supports it. Notably,
// on macOS, when compressed oops is disabled and the heap is

@ -0,0 +1,155 @@
/*
* 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 transform;
import java.io.StringReader;
import java.io.StringWriter;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.stream.StreamResult;
import org.testng.Assert;
import org.testng.annotations.Test;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLFilter;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLFilterImpl;
/*
* @test
* @bug 8237456
* @modules java.xml
* @run testng transform.SAXFilterTest
* @summary Verifies that reference entities are not written out when the element
* is skipped through a filter.
*/
public class SAXFilterTest {
static final String XML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<thing1 xmlns=\"things\">\n"
+ " <name>This &amp; That</name>\n"
+ " <thing2>\n"
+ " <name>The Other</name>\n"
+ " </thing2>\n"
+ " <thing2>\n"
+ " <name>Whatever</name>\n"
+ " </thing2>\n"
+ "</thing1>";
static final String UNEXPECTED = "&amp;";
@Test
public void test() throws Exception {
Transformer t = TransformerFactory.newInstance().newTransformer();
XMLFilter filter = new Thing2Filter(getParser());
StringWriter sw = new StringWriter();
t.transform(new SAXSource(filter, new InputSource(new StringReader(XML))),
new StreamResult(sw));
Assert.assertFalse(sw.toString().contains(UNEXPECTED));
System.out.println(sw.toString());
}
private XMLReader getParser() {
XMLReader reader = null;
try {
SAXParserFactory factory = SAXParserFactory.newInstance();
String saxParserFactoryClassName = factory.getClass().getName();
System.out.println("SAXParserFactory class: " + saxParserFactoryClassName);
factory.setValidating(false);
factory.setNamespaceAware(true);
SAXParser parser = factory.newSAXParser();
reader = parser.getXMLReader();
System.out.println("XmlReader class: " + reader.getClass().getName());
} catch (ParserConfigurationException pce) {
pce.printStackTrace();
} catch (SAXException se) {
se.printStackTrace();
}
return reader;
}
class Thing2Filter extends XMLFilterImpl {
private boolean inMatch = false;
private int elementLocator;
private boolean doneMatching = false;
public Thing2Filter(XMLReader parent) {
super(parent);
}
@Override
public void startDocument() throws SAXException {
doneMatching = false;
super.startDocument();
}
@Override
public void startElement(String namespaceURI, String localName, String qName, Attributes attrs) throws SAXException {
if (localName.equals("thing2") && !doneMatching) { // start matching when the first thing2 is hit
inMatch = true;
}
if (inMatch) {
super.startElement(namespaceURI, localName, qName, attrs);
}
}
@Override
public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
if (inMatch) {
super.endElement(namespaceURI, localName, qName);
}
if (localName.equals("thing2")) { // match is over once end of first thing2 is hit
inMatch = false;
doneMatching = true;
}
}
@Override
public void characters(char[] ch, int start, int length) throws SAXException {
if (inMatch) {
super.characters(ch, start, length);
}
}
@Override
public void startPrefixMapping(java.lang.String prefix, java.lang.String uri) throws SAXException {
super.startPrefixMapping(prefix, uri);
}
@Override
public void endPrefixMapping(java.lang.String prefix) throws SAXException {
super.endPrefixMapping(prefix);
}
}
}

@ -22,28 +22,28 @@
*/
/* @test
* @bug 8243507
* @summary Checks to ensure that DatagramSocket constructors throw expected
* exceptions.
* @bug 8243507 8243999
* @summary Checks to ensure that DatagramSocket constructors behave as expected
* @run testng Constructor
*/
import org.testng.annotations.Test;
import java.io.IOException;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketAddress;
import static org.testng.Assert.assertThrows;
import static org.testng.Assert.assertTrue;
public class Constructor {
private static final InetAddress LOOPBACK =
InetAddress.getLoopbackAddress();
private static final Class<IllegalArgumentException> IAE =
IllegalArgumentException.class;
private static final InetAddress LOOPBACK = InetAddress.getLoopbackAddress();
private static final Class<IllegalArgumentException> IAE = IllegalArgumentException.class;
private class TestSocketAddress extends SocketAddress {
TestSocketAddress() {}
TestSocketAddress() {
}
}
@Test
@ -55,10 +55,25 @@ public class Constructor {
@Test
public void testInvalidPortRange() {
var invalidPortValues = new int[] {-1, 65536, Integer.MAX_VALUE};
var invalidPortValues = new int[]{-1, 65536, Integer.MAX_VALUE};
for (int i : invalidPortValues) {
assertThrows(IAE, () -> new DatagramSocket(i));
assertThrows(IAE, () -> new DatagramSocket(i, LOOPBACK));
}
}
@Test
public void testDSNullAddress() throws IOException {
try (var ds = new DatagramSocket()) {
assertTrue(ds.getLocalAddress().isAnyLocalAddress());
}
try (var ds1 = new DatagramSocket(null)) {
assertTrue(ds1.getLocalAddress().isAnyLocalAddress());
}
try (var ds2 = new DatagramSocket(0, null)) {
assertTrue(ds2.getLocalAddress().isAnyLocalAddress());
}
}
}

@ -0,0 +1,48 @@
/*
* 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 8243999
* @summary Checks to ensure that Multicast constructors behave as expected
* @run testng Constructor
*/
import org.testng.annotations.Test;
import java.io.IOException;
import java.net.MulticastSocket;
import static org.testng.Assert.assertTrue;
public class Constructor {
@Test
public void testMSNullAddress() throws IOException {
try (var ms = new MulticastSocket()) {
assertTrue(ms.getLocalAddress().isAnyLocalAddress());
}
try (var ms1 = new MulticastSocket(null)) {
assertTrue(ms1.getLocalAddress().isAnyLocalAddress());
}
}
}

@ -31,6 +31,7 @@
* @run main/othervm -Djdk.net.usePlainDatagramSocketImpl OptionsTest
* @run main/othervm -Xcheck:jni -Djava.net.preferIPv4Stack=true OptionsTest
* @run main/othervm --limit-modules=java.base OptionsTest
* @run main/othervm/policy=options.policy OptionsTest
*/
import java.lang.reflect.Method;
@ -343,7 +344,7 @@ public class OptionsTest {
static Object getServerSocketTrafficClass(ServerSocket ss) throws Exception {
try {
Class<?> c = Class.forName("jdk.net.Sockets");
Method m = c.getDeclaredMethod("getOption", ServerSocket.class, SocketOption.class);
Method m = c.getMethod("getOption", ServerSocket.class, SocketOption.class);
return m.invoke(null, ss, StandardSocketOptions.IP_TOS);
} catch (ClassNotFoundException e) {
// Ok, jdk.net module not present, just fall back

@ -0,0 +1,28 @@
//
// 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.
//
grant {
permission java.net.SocketPermission "localhost:*", "connect, accept, listen, resolve";
permission java.util.PropertyPermission "java.net.preferIPv4Stack", "read";
permission java.util.PropertyPermission "java.net.preferIPv6Addresses", "read";
};

@ -47,6 +47,7 @@ import java.time.temporal.TemporalField;
import java.time.temporal.WeekFields;
import java.util.Locale;
import java.util.TimeZone;
import java.util.stream.Stream;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
@ -825,15 +826,26 @@ public class TestUnicodeExtension {
public void test_localizedBy(Locale locale, Chronology chrono, ZoneId zone,
Chronology chronoExpected, ZoneId zoneExpected,
String formatExpected) {
DateTimeFormatter dtf =
DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL, FormatStyle.FULL)
.withChronology(chrono).withZone(zone).localizedBy(locale);
assertEquals(dtf.getChronology(), chronoExpected);
assertEquals(dtf.getZone(), zoneExpected);
String formatted = dtf.format(ZDT);
assertEquals(formatted, formatExpected);
assertEquals(dtf.parse(formatted, ZonedDateTime::from),
zoneExpected != null ? ZDT.withZoneSameInstant(zoneExpected) : ZDT);
// try this test both with the implicit default locale, and explicit default locale ja-JP
Locale def = Locale.getDefault();
try {
Stream.of(def, Locale.JAPAN).forEach(l -> {
System.out.println(" Testing with the default locale: " + l);
Locale.setDefault(l);
DateTimeFormatter dtf =
DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL, FormatStyle.FULL)
.withChronology(chrono).withZone(zone).localizedBy(locale);
assertEquals(dtf.getChronology(), chronoExpected);
assertEquals(dtf.getZone(), zoneExpected);
String formatted = dtf.format(ZDT);
assertEquals(formatted, formatExpected);
assertEquals(dtf.parse(formatted, ZonedDateTime::from),
zoneExpected != null ? ZDT.withZoneSameInstant(zoneExpected) : ZDT);
});
} finally {
Locale.setDefault(def);
}
}
@Test(dataProvider="withLocale")

@ -0,0 +1,255 @@
/*
* 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 8164408
* @summary Add module support for see, link and linkplain javadoc tags
* @library /tools/lib ../../lib
* @modules
* jdk.javadoc/jdk.javadoc.internal.tool
* jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.main
* @build javadoc.tester.*
* @run main TestLinkTagletWithModule
*/
import java.nio.file.Path;
import java.nio.file.Paths;
import builder.ClassBuilder;
import builder.ClassBuilder.*;
import toolbox.ModuleBuilder;
import toolbox.ToolBox;
import javadoc.tester.JavadocTester;
public class TestLinkTagletWithModule extends JavadocTester {
final ToolBox tb;
private final Path src;
public static void main(String... args) throws Exception {
TestLinkTagletWithModule tester = new TestLinkTagletWithModule();
tester.runTests(m -> new Object[]{Paths.get(m.getName())});
}
TestLinkTagletWithModule() throws Exception {
tb = new ToolBox();
src = Paths.get("src");
generateSources();
}
@Test
public void testLinkModuleInternal(Path base) throws Exception {
Path out = base.resolve("out");
javadoc("-d", out.toString(),
"--module-source-path", src.toString(),
"--module", "m1,m2,m3",
"m2/com.m2.lib");
checkExit(Exit.OK);
checkOutput("m3/com/m3/app/App.html", true,
"""
<div class="block"><a href="../../../../m1/module-summary.html"><code>m1</code></a>
<a href="../../../../m1/module-summary.html"><code>m1</code></a>
<a href="../../../../m1/com/m1/lib/package-summary.html"><code>package link</code></a>
<a href="../../../../m1/com/m1/lib/Lib.html" title="class in com.m1.lib"><code>Lib</code></a>
<a href="../../../../m1/com/m1/lib/Lib.html#method(java.lang.String)"><code>Lib.method(java.lang.String)</code></a>
<a href="../../../../m1/com/m1/lib/Lib.html#method(java.lang.String)"><code>Lib.method(String)</code></a>
<a href="../../../../m2/module-summary.html">m2</a>
<a href="../../../../m2/module-summary.html">m2</a>
<a href="../../../../m2/com/m2/lib/package-summary.html">com.m2.lib</a>
<a href="../../../../m2/com/m2/lib/Lib.html" title="class in com.m2.lib">Lib</a>
<a href="../../../../m2/com/m2/lib/Lib.html#method(java.lang.String)">class link</a>
<a href="../../../../m2/com/m2/lib/Lib.html#method(java.lang.String)">Lib.method(String)</a></div>
""");
}
@Test
public void testLinkModuleExternal(Path base) throws Exception {
Path out1 = base.resolve("out1"), out2 = base.resolve("out2");
javadoc("-d", out1.toString(),
"--module-source-path", src.toString(),
"--module", "m1,m2",
"m2/com.m2.lib");
javadoc("-d", out2.toString(),
"--module-source-path", src.toString(),
"--add-modules", "m2",
"--module", "m3",
"-link", "../" + out1.getFileName());
checkExit(Exit.OK);
checkOutput("m3/com/m3/app/App.html", true,
"""
<div class="block"><a href="../../../../../out1/m1/module-summary.html" class="external-link"><code>m1</code></a>
<a href="../../../../../out1/m1/module-summary.html" class="external-link"><code>m1</code></a>
<a href="../../../../../out1/m1/com/m1/lib/package-summary.html" class="external-link"><code>package link</code></a>
<a href="../../../../../out1/m1/com/m1/lib/Lib.html" title="class or interface in com.m1.lib"\
class="external-link"><code>Lib</code></a>
<a href="../../../../../out1/m1/com/m1/lib/Lib.html#method(java.lang.String)" title="class or\
interface in com.m1.lib" class="external-link"><code>Lib.method(java.lang.String)</code></a>
<a href="../../../../../out1/m1/com/m1/lib/Lib.html#method(java.lang.String)" title="class or\
interface in com.m1.lib" class="external-link"><code>Lib.method(String)</code></a>
<a href="../../../../../out1/m2/module-summary.html" class="external-link">m2</a>
<a href="../../../../../out1/m2/module-summary.html" class="external-link">m2</a>
<a href="../../../../../out1/m2/com/m2/lib/package-summary.html" class="external-link">m2/com.m2.lib</a>
<a href="../../../../../out1/m2/com/m2/lib/Lib.html" title="class or interface in com.m2.lib" class="external-link">Lib</a>
<a href="../../../../../out1/m2/com/m2/lib/Lib.html#method(java.lang.String)" title="class or\
interface in com.m2.lib" class="external-link">class link</a>
<a href="../../../../../out1/m2/com/m2/lib/Lib.html#method(java.lang.String)" title="class or\
interface in com.m2.lib" class="external-link">Lib.method(String)</a></div>
""");
}
@Test
public void testLinkModuleSameNameInternal(Path base) throws Exception {
Path out = base.resolve("out");
javadoc("-d", out.toString(),
"--module-source-path", src.toString(),
"--module", "com.ex1,com.ex2");
checkExit(Exit.OK);
checkOutput("com.ex2/com/ex2/B.html", true,
"""
<div class="block"><a href="../../../com.ex1/com/ex1/package-summary.html"><code>package link</code></a>
<a href="../../../com.ex1/module-summary.html"><code>module link</code></a>
<a href="../../../com.ex1/com/ex1/package-summary.html"><code>com.ex1</code></a>
<a href="../../../com.ex1/com/ex1/A.html" title="class in com.ex1"><code>class link</code></a>
<a href="../../../com.ex1/com/ex1/A.html#m()"><code>A.m()</code></a>
<a href="../../../com.ex1/com/ex1/A.html#m()"><code>A.m()</code></a>
<a href="package-summary.html"><code>com.ex2</code></a>
<a href="../../module-summary.html"><code>com.ex2</code></a></div>
""");
}
@Test
public void testLinkModuleSameNameExternal(Path base) throws Exception {
Path out1 = base.resolve("out1"), out2 = base.resolve("out2");
javadoc("-d", out1.toString(),
"--module-source-path", src.toString(),
"--module", "com.ex1");
javadoc("-d", out2.toString(),
"--module-source-path", src.toString(),
"--module", "com.ex2",
"-link", "../" + out1.getFileName());
checkExit(Exit.OK);
checkOutput("com.ex2/com/ex2/B.html", true,
"""
<div class="block"><a href="../../../../out1/com.ex1/com/ex1/package-summary.html" class="external-link"><code>package link</code></a>
<a href="../../../../out1/com.ex1/module-summary.html" class="external-link"><code>module link</code></a>
<a href="../../../../out1/com.ex1/com/ex1/package-summary.html" class="external-link"><code>com.ex1/com.ex1</code></a>
<a href="../../../../out1/com.ex1/com/ex1/A.html" title="class or interface in com.ex1" class="external-link"><code>class link</code></a>
<a href="../../../../out1/com.ex1/com/ex1/A.html#m()" title="class or interface in com.ex1" class="external-link"><code>A.m()</code></a>
<a href="../../../../out1/com.ex1/com/ex1/A.html#m()" title="class or interface in com.ex1" class="external-link"><code>A.m()</code></a>
<a href="package-summary.html"><code>com.ex2</code></a>
<a href="../../module-summary.html"><code>com.ex2</code></a></div>
""");
}
void generateSources() throws Exception {
new ModuleBuilder(tb, "m1")
.exports("com.m1.lib")
.classes("""
package com.m1.lib;
public class Lib {
public String method(String s) {
return s;
}
}""")
.write(src);
new ModuleBuilder(tb, "m2")
.classes("""
package com.m2.lib;
public class Lib {
public String method(String s) {
return s;
}
}""")
.write(src);
new ModuleBuilder(tb, "m3")
.exports("com.m3.app")
.requires("m1")
.classes("""
package com.m3.app;\s
public class App{
/**
* {@link m1}
* {@link m1/}
* {@link m1/com.m1.lib package link}
* {@link m1/com.m1.lib.Lib}
* {@link m1/com.m1.lib.Lib#method}
* {@link m1/com.m1.lib.Lib#method(String)}
* {@linkplain m2}
* {@linkplain m2/}
* {@linkplain m2/com.m2.lib}
* {@linkplain m2/com.m2.lib.Lib}
* {@linkplain m2/com.m2.lib.Lib#method class link}
* {@linkplain m2/com.m2.lib.Lib#method(String)}
*/
public App(){}
}
""")
.write(src);
new ModuleBuilder(tb, "com.ex1")
.exports("com.ex1")
.classes("""
package com.ex1;
public class A{
public void m() {}
}""",
"""
package com.ex1;
public class B {}""")
.write(src);
new ModuleBuilder(tb, "com.ex2")
.requires("com.ex1")
.exports("com.ex2")
.classes("""
package com.ex2;\s
import com.ex1.A;
public class B{
/**
* {@link com.ex1 package link}
* {@link com.ex1/ module link}
* {@link com.ex1/com.ex1}
* {@link com.ex1/com.ex1.A class link}
* {@link com.ex1/com.ex1.A#m}
* {@link com.ex1/com.ex1.A#m()}
* {@link com.ex2}
* {@link com.ex2/}
*/
public B(A obj){}
}
""")
.write(src);
}
}

@ -0,0 +1,121 @@
/*
* 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 8242607
* @summary -Xdoclint doesn't report missing/unexpected comments
* @library /tools/lib ../../lib
* @modules jdk.javadoc/jdk.javadoc.internal.tool
* @build toolbox.ToolBox javadoc.tester.*
* @run main TestMissingComment
*/
import java.io.File;
import java.nio.file.Path;
import javadoc.tester.JavadocTester;
import toolbox.ToolBox;
public class TestMissingComment extends JavadocTester {
public static void main(String... args) throws Exception {
TestMissingComment tester = new TestMissingComment();
tester.runTests(m -> new Object[] { Path.of(m.getName() )});
}
private ToolBox tb = new ToolBox();
@Test
public void testClass(Path base) throws Exception {
test(base.resolve("class"), """
// no doc comment
public class C { }
""",
"""
testClass/class/src/C.java:2: warning: no comment
public class C { }
^
""");
}
@Test
public void testExecutable(Path base) throws Exception {
test(base.resolve("executable"), """
/** Class comment. */
public class C {
// no doc comment
public void m() { }
}
""",
"""
testExecutable/executable/src/C.java:4: warning: no comment
public void m() { }
^
""");
}
@Test
public void testField(Path base) throws Exception {
test(base.resolve("field"), """
/** Class comment. */
public class C {
// no doc comment
public int f;
}
""",
"""
testField/field/src/C.java:4: warning: no comment
public int f;
^
""");
}
@Test
public void testNested(Path base) throws Exception {
test(base.resolve("nest"), """
/** Class comment. */
public class C {
// no doc comment
public class Nested { }
}
""",
"""
testNested/nest/src/C.java:4: warning: no comment
public class Nested { }
^
""");
}
private void test(Path base, String code, String expect) throws Exception {
Path src = base.resolve("src");
tb.writeJavaFiles(src, code);
javadoc("-d", base.resolve("api").toString(),
"-Xdoclint:missing",
src.resolve("C.java").toString());
checkExit(Exit.OK);
checkOutput(Output.OUT, true,
expect.replace("/", File.separator),
"1 warning");
}
}

@ -0,0 +1,283 @@
/*
* 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 8164408
* @summary Add module support for see, link and linkplain javadoc tags
* @library /tools/lib ../../lib
* @modules
* jdk.javadoc/jdk.javadoc.internal.tool
* jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.main
* @build javadoc.tester.*
* @run main TestSeeTagWithModule
*/
import java.nio.file.Path;
import java.nio.file.Paths;
import builder.ClassBuilder;
import builder.ClassBuilder.*;
import toolbox.ModuleBuilder;
import toolbox.ToolBox;
import javadoc.tester.JavadocTester;
public class TestSeeTagWithModule extends JavadocTester {
final ToolBox tb;
private final Path src;
public static void main(String... args) throws Exception {
TestSeeTagWithModule tester = new TestSeeTagWithModule();
tester.runTests(m -> new Object[]{Paths.get(m.getName())});
}
TestSeeTagWithModule() throws Exception {
tb = new ToolBox();
src = Paths.get("src");
generateSources();
}
@Test
public void testSeeModuleInternal(Path base) throws Exception {
Path out = base.resolve("out");
javadoc("-d", out.toString(),
"--module-source-path", src.toString(),
"--module", "m1,m2,m3",
"m2/com.m2.lib");
checkExit(Exit.OK);
checkOutput("m3/com/m3/app/App.html", true,
"""
<dt>See Also:</dt>
<dd><a href="../../../../m1/module-summary.html"><code>m1</code></a>,\s
<a href="../../../../m1/module-summary.html"><code>m1</code></a>,\s
<a href="../../../../m1/com/m1/lib/package-summary.html"><code>com.m1.lib</code></a>,\s
<a href="../../../../m1/com/m1/lib/Lib.html" title="class in com.m1.lib"><code>Lib</code></a>,\s
<a href="../../../../m1/com/m1/lib/Lib.html#method(java.lang.String)"><code>Lib.method(java.lang.String)</code></a>,\s
<a href="../../../../m1/com/m1/lib/Lib.html#method(java.lang.String)"><code>Lib.method(String)</code></a>,\s
<a href="../../../../m2/module-summary.html"><code>m2</code></a>,\s
<a href="../../../../m2/module-summary.html"><code>m2</code></a>,\s
<a href="../../../../m2/com/m2/lib/package-summary.html"><code>com.m2.lib</code></a>,\s
<a href="../../../../m2/com/m2/lib/Lib.html" title="class in com.m2.lib"><code>Lib</code></a>,\s
<a href="../../../../m2/com/m2/lib/Lib.html#method(java.lang.String)"><code>Lib.method(java.lang.String)</code></a>,\s
<a href="../../../../m2/com/m2/lib/Lib.html#method(java.lang.String)"><code>Lib.method(String)</code></a></dd>
""");
}
@Test
public void testSeeModuleExternal(Path base) throws Exception {
Path out1 = base.resolve("out1"), out2 = base.resolve("out2");
javadoc("-d", out1.toString(),
"--module-source-path", src.toString(),
"--module", "m1,m2",
"m2/com.m2.lib");
javadoc("-d", out2.toString(),
"--module-source-path", src.toString(),
"--add-modules", "m2",
"--module", "m3",
"-link", "../" + out1.getFileName());
checkExit(Exit.OK);
checkOutput("m3/com/m3/app/App.html", true,
"""
<dt>See Also:</dt>
<dd><a href="../../../../../out1/m1/module-summary.html" class="external-link"><code>m1</code></a>,\s
<a href="../../../../../out1/m1/module-summary.html" class="external-link"><code>m1</code></a>,\s
<a href="../../../../../out1/m1/com/m1/lib/package-summary.html" class="external-link"><code>m1/com.m1.lib</code></a>,\s
<a href="../../../../../out1/m1/com/m1/lib/Lib.html" title="class or interface in com.m1.lib" class="external-link"><code>Lib</code></a>,\s
<a href="../../../../../out1/m1/com/m1/lib/Lib.html#method(java.lang.String)" title="class or \
interface in com.m1.lib" class="external-link"><code>Lib.method(java.lang.String)</code></a>,\s
<a href="../../../../../out1/m1/com/m1/lib/Lib.html#method(java.lang.String)" title="class or \
interface in com.m1.lib" class="external-link"><code>Lib.method(String)</code></a>,\s
<a href="../../../../../out1/m2/module-summary.html" class="external-link"><code>m2</code></a>,\s
<a href="../../../../../out1/m2/module-summary.html" class="external-link"><code>m2</code></a>,\s
<a href="../../../../../out1/m2/com/m2/lib/package-summary.html" class="external-link"><code>m2/com.m2.lib</code></a>,\s
<a href="../../../../../out1/m2/com/m2/lib/Lib.html" title="class or interface in com.m2.lib" class="external-link"><code>Lib</code></a>,\s
<a href="../../../../../out1/m2/com/m2/lib/Lib.html#method(java.lang.String)" title="class or \
interface in com.m2.lib" class="external-link"><code>Lib.method(java.lang.String)</code></a>,\s
<a href="../../../../../out1/m2/com/m2/lib/Lib.html#method(java.lang.String)" title="class or \
interface in com.m2.lib" class="external-link"><code>Lib.method(String)</code></a></dd>
""");
}
@Test
public void testSeeModuleSameNameInternal(Path base) throws Exception {
Path out = base.resolve("out");
javadoc("-d", out.toString(),
"--module-source-path", src.toString(),
"--module", "com.ex1,com.ex2");
checkExit(Exit.OK);
checkOutput("com.ex2/com/ex2/B.html", true,
"""
<dt>See Also:</dt>
<dd><a href="../../../com.ex1/com/ex1/package-summary.html"><code>com.ex1</code></a>,\s
<a href="../../../com.ex1/module-summary.html"><code>com.ex1</code></a>,\s
<a href="../../../com.ex1/com/ex1/package-summary.html"><code>com.ex1</code></a>,\s
<a href="../../../com.ex1/com/ex1/A.html" title="class in com.ex1"><code>A</code></a>,\s
<a href="../../../com.ex1/com/ex1/A.html#m()"><code>A.m()</code></a>,\s
<a href="../../../com.ex1/com/ex1/A.html#m()"><code>A.m()</code></a>,\s
<a href="package-summary.html"><code>com.ex2</code></a>,\s
<a href="../../module-summary.html"><code>com.ex2</code></a></dd>
""");
}
@Test
public void testSeeModuleSameNameExternal(Path base) throws Exception {
Path out1 = base.resolve("out1"), out2 = base.resolve("out2");
javadoc("-d", out1.toString(),
"--module-source-path", src.toString(),
"--module", "com.ex1");
javadoc("-d", out2.toString(),
"--module-source-path", src.toString(),
"--module", "com.ex2",
"-link", "../" + out1.getFileName());
checkExit(Exit.OK);
checkOutput("com.ex2/com/ex2/B.html", true,
"""
<dt>See Also:</dt>
<dd><a href="../../../../out1/com.ex1/com/ex1/package-summary.html" class="external-link"><code>com.ex1</code></a>,\s
<a href="../../../../out1/com.ex1/module-summary.html" class="external-link"><code>com.ex1</code></a>,\s
<a href="../../../../out1/com.ex1/com/ex1/package-summary.html" class="external-link"><code>com.ex1/com.ex1</code></a>,\s
<a href="../../../../out1/com.ex1/com/ex1/A.html" title="class or interface in com.ex1" class="external-link"><code>A</code></a>,\s
<a href="../../../../out1/com.ex1/com/ex1/A.html#m()" title="class or interface in com.ex1" class="external-link"><code>A.m()</code></a>,\s
<a href="../../../../out1/com.ex1/com/ex1/A.html#m()" title="class or interface in com.ex1" class="external-link"><code>A.m()</code></a>,\s
<a href="package-summary.html"><code>com.ex2</code></a>,\s
<a href="../../module-summary.html"><code>com.ex2</code></a></dd>
""");
}
@Test
public void testMissingType(Path base) throws Exception {
Path out = base.resolve("outMissingType");
javadoc("-d", out.toString(),
"--module-source-path", src.toString(),
"--module", "fail");
checkExit(Exit.ERROR);
}
void generateSources() throws Exception {
new ModuleBuilder(tb, "m1")
.exports("com.m1.lib")
.classes("""
package com.m1.lib;
public class Lib {
public String method(String s) {
return s;
}
}""")
.write(src);
new ModuleBuilder(tb, "m2")
.classes("""
package com.m2.lib;
public class Lib {
public String method(String s) {
return s;
}
}""")
.write(src);
new ModuleBuilder(tb, "m3")
.exports("com.m3.app")
.requires("m1")
.classes("""
package com.m3.app;\s
public class App{
/**
* @see m1
* @see m1/
* @see m1/com.m1.lib
* @see m1/com.m1.lib.Lib
* @see m1/com.m1.lib.Lib#method
* @see m1/com.m1.lib.Lib#method(String)
* @see m2
* @see m2/
* @see m2/com.m2.lib
* @see m2/com.m2.lib.Lib
* @see m2/com.m2.lib.Lib#method
* @see m2/com.m2.lib.Lib#method(String)
*/
public App(){}
}
""")
.write(src);
new ModuleBuilder(tb, "com.ex1")
.exports("com.ex1")
.classes("""
package com.ex1;
public class A{
public void m() {}
}""",
"""
package com.ex1;
public class B {}""")
.write(src);
new ModuleBuilder(tb, "com.ex2")
.requires("com.ex1")
.exports("com.ex2")
.classes("""
package com.ex2;\s
import com.ex1.A;
public class B{
/**
* @see com.ex1
* @see com.ex1/
* @see com.ex1/com.ex1
* @see com.ex1/com.ex1.A
* @see com.ex1/com.ex1.A#m
* @see com.ex1/com.ex1.A#m()
* @see com.ex2
* @see com.ex2/
*/
public B(A obj){}
}
""")
.write(src);
new ModuleBuilder(tb, "fail")
.exports("pkg.fail")
.classes("""
package pkg.fail;
/**
* @see fail/#foo()
*/
public class F {
public void foo() {}
}
""")
.write(src);
}
}

@ -44,6 +44,9 @@ public class QuietOption {
final File testSrc;
final String thisClassName;
/**
* Dummy javadoc comment.
*/
public QuietOption() {
File javaHome = new File(System.getProperty("java.home"));
if (javaHome.getName().endsWith("jre"))
@ -53,6 +56,11 @@ public class QuietOption {
thisClassName = QuietOption.class.getName();
}
/**
* Dummy javadoc comment.
* @param args dummy
* @throws Exception if error
*/
public static void main(String... args) throws Exception {
QuietOption test = new QuietOption();
test.run1();

@ -108,6 +108,8 @@ public class DocLintTest {
DL_ERR_P1TEST(ERROR, "P1Test.java:3:16: compiler.err.proc.messager: malformed HTML"),
DL_ERR_P2TEST(ERROR, "P2Test.java:3:16: compiler.err.proc.messager: malformed HTML"),
DL_WARN_P1TEST(WARNING, "P1Test.java:2:8: compiler.warn.proc.messager: no comment"),
DL_WARN_P2TEST(WARNING, "P2Test.java:2:8: compiler.warn.proc.messager: no comment"),
// doclint messages when -XDrawDiagnostics is not in effect
DL_ERR9A(ERROR, "Test.java:9: error: reference not found"),
@ -201,11 +203,13 @@ public class DocLintTest {
test(List.of(htmlVersion, rawDiags),
Main.Result.ERROR,
EnumSet.of(Message.DL_ERR_P1TEST, Message.DL_ERR_P2TEST));
EnumSet.of(Message.DL_ERR_P1TEST, Message.DL_ERR_P2TEST,
Message.DL_WARN_P1TEST, Message.DL_WARN_P2TEST));
test(List.of(htmlVersion, rawDiags, "-Xdoclint/package:p1"),
Main.Result.ERROR,
EnumSet.of(Message.DL_ERR_P1TEST));
EnumSet.of(Message.DL_ERR_P1TEST,
Message.DL_WARN_P1TEST));
test(List.of(htmlVersion, rawDiags, "-Xdoclint/package:*p"),
Main.Result.ERROR,

@ -23,7 +23,7 @@
/*
* @test
* @bug 8176481
* @bug 8176481 8246705
* @summary Tests behavior of the tool, when modules are present as
* binaries.
* @modules
@ -60,7 +60,7 @@ public class MissingSourceModules extends ModuleTestBase {
execNegativeTask("--module-path", modulePath.toString(),
"--module", "ma");
assertMessagePresent("module ma not found.");
assertMessagePresent("module ma not found");
}
@Test
@ -77,11 +77,11 @@ public class MissingSourceModules extends ModuleTestBase {
Path mPath = Paths.get(modulePath.toString(), "ma");
execNegativeTask("--source-path", mPath.toString(),
"--module", "ma");
assertMessagePresent("module ma not found.");
assertMessagePresent("module ma not found on source path");
execNegativeTask("--class-path", mPath.toString(),
"--module", "ma");
assertMessagePresent("module ma not found.");
assertMessagePresent("module ma not found");
}
@Test
@ -106,7 +106,7 @@ public class MissingSourceModules extends ModuleTestBase {
"--module-source-path", src.toString(),
"--expand-requires", "all",
"--module", "ma");
assertMessagePresent("module mb not found.");
assertMessagePresent("source files for module mb not found");
}
@Test
@ -131,6 +131,6 @@ public class MissingSourceModules extends ModuleTestBase {
"--module-source-path", src.toString(),
"--expand-requires", "transitive",
"--module", "ma");
assertMessagePresent("module mb not found.");
assertMessagePresent("source files for module mb not found");
}
}

@ -534,7 +534,7 @@ public class Modules extends ModuleTestBase {
"--module", "MIA",
"--expand-requires", "all");
assertMessagePresent("javadoc: error - module MIA not found.");
assertMessagePresent("javadoc: error - module MIA not found");
}
@Test

@ -0,0 +1,151 @@
/*
* 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 8246712
* @summary doclint incorrectly reports some HTML elements as empty
* @modules jdk.compiler/com.sun.tools.doclint
* @library /tools/lib
* @build toolbox.TestRunner toolbox.ToolBox
* @run main EmptyHtmlTest
*/
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.Method;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import com.sun.source.doctree.DocTreeVisitor;
import com.sun.source.doctree.InlineTagTree;
import com.sun.tools.doclint.DocLint;
import toolbox.TestRunner;
import toolbox.ToolBox;
public class EmptyHtmlTest extends TestRunner {
public static void main(String... args) throws Exception {
EmptyHtmlTest t = new EmptyHtmlTest();
t.runTests(m -> new Object[] { Path.of(m.getName()) });
}
public EmptyHtmlTest() {
super(System.err);
}
ToolBox tb = new ToolBox();
/**
* This test is intended to be future-proof, and hence detect any
* problems in any inline tags added in the future.
* Since there is not yet any mapping between DocTree.Kind and
* the corresponding subtype DocTree (see javac Tree.Kind, Tree)
* the list of all current inline tag classes is determined by
* scanning DocTreeVisitor.
*
* @param base working directory for the test case
* @throws Exception if an error occurs
*/
@Test
public void testInlines(Path base) throws Exception {
Class<DocTreeVisitor> c = DocTreeVisitor.class;
for (Method m : c.getDeclaredMethods()) {
if (m.getName().startsWith("visit") && m.getParameterCount() == 2) {
Class<?>[] paramTypes = m.getParameterTypes();
Class<?> firstParamType = paramTypes[0];
if (InlineTagTree.class.isAssignableFrom(firstParamType)) {
testInline(base, firstParamType);
}
}
}
}
void testInline(Path base, Class<?> type) throws Exception {
// the following can eventually be converted to instanceof pattern switch
Path d = Files.createDirectories(base.resolve(type.getSimpleName()));
switch (type.getSimpleName()) {
case "DocRootTree" ->
test(d, type, "{@docRoot}");
case "IndexTree" ->
test(d, type, "{@index Object}");
case "InheritDocTree" ->
test(d, type, "{@inheritDoc}");
case "LinkTree" ->
test(d, type, "{@link Object}");
case "LiteralTree" ->
test(d, type, "{@literal abc}");
case "SummaryTree" ->
test(d, type, "{@summary First sentence.}");
case "SystemPropertyTree" ->
test(d, type, "{@systemProperty file.separator}");
case "UnknownInlineTagTree" ->
test(d, type, "{@unknown}");
case "ValueTree" ->
test(d, type, "{@value Math.PI}");
default ->
error("no test case provided for " + type);
}
}
void test(Path base, Class<?> type, String tag) throws Exception {
System.err.println("test " + type.getSimpleName() + " " + tag);
Path src = base.resolve("src");
String text = """
/**
* This is a comment.
* <b>INSERT</b>
*/
public class C { }
""".replace("INSERT", tag);
tb.writeJavaFiles(src, text);
List<String> cmdArgs = List.of(
"-Xmsgs:html",
"-XcustomTags:unknown",
src.resolve("C.java").toString()
);
StringWriter sw = new StringWriter();
try (PrintWriter pw = new PrintWriter(sw)) {
new DocLint().run(pw, cmdArgs.toArray(new String[0]));
}
String log = sw.toString();
if (!log.isEmpty()) {
System.err.println("output:");
log.lines().forEach(System.err::println);
error("Unexpected output from doclint");
}
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 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
@ -229,14 +229,13 @@ public class LambdaParserTest extends ComboInstance<LambdaParserTest> {
public static void main(String... args) throws Exception {
new ComboTestHelper<LambdaParserTest>()
.withFilter(LambdaParserTest::redundantTestFilter)
.withFilter(LambdaParserTest::badImplicitFilter)
.withDimension("SOURCE", (x, sk) -> x.sk = sk, SourceKind.values())
.withDimension("LAMBDA", (x, lk) -> x.lk = lk, LambdaKind.values())
.withDimension("NAME", (x, name) -> x.pn = name, LambdaParameterName.values())
.withArrayDimension("TYPE", (x, type, idx) -> x.pks[idx] = type, 2, LambdaParameterKind.values())
.withArrayDimension("MOD", (x, mod, idx) -> x.mks[idx] = mod, 2, ModifierKind.values())
.withDimension("EXPR", ExprKind.values())
.withDimension("SUBEXPR", SubExprKind.values())
.withDimension("EXPR", (x, exp) -> x.exp = exp, ExprKind.values())
.withDimension("SUBEXPR", (x, sub) -> x.sub = sub, SubExprKind.values())
.run(LambdaParserTest::new);
}
@ -245,21 +244,29 @@ public class LambdaParserTest extends ComboInstance<LambdaParserTest> {
LambdaKind lk;
LambdaParameterName pn;
SourceKind sk;
boolean badImplicitFilter() {
return !(mks[0] != ModifierKind.NONE && lk.isShort());
}
ExprKind exp;
SubExprKind sub;
boolean redundantTestFilter() {
for (int i = lk.arity(); i < mks.length ; i++) {
if (mks[i].ordinal() != 0) {
return false;
if (sub == SubExprKind.NONE) {
switch (exp) {
//followings combinations with empty sub-expressions produces the same source
case SINGLE_PAREN2, DOUBLE_PAREN2, DOUBLE_PAREN3: return false;
}
} else {
switch (lk) {
//any non-empty subexpression does not combine with lambda statements
case NILARY_STMT, ONEARY_SHORT_STMT, ONEARY_STMT, TWOARY_STMT: return false;
}
}
for (int i = lk.arity(); i < pks.length ; i++) {
if (pks[i].ordinal() != 0) {
return false;
}
switch (lk) {
//parameters not present in the expression are redundant
case NILARY_EXPR, NILARY_STMT:
if (pn.ordinal() != 0) return false;
case ONEARY_SHORT_EXPR, ONEARY_SHORT_STMT:
if (pks[0].ordinal() != 0 || mks[0].ordinal() != 0) return false;
case ONEARY_EXPR, ONEARY_STMT :
if (pks[1].ordinal() != 0 || mks[1].ordinal() != 0) return false;
}
return true;
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -90,7 +90,7 @@ public abstract class KeyAgreementBench extends CryptoBase {
@Param({"ECDH"})
private String algorithm;
@Param({"224", "256", "384", "521"})
@Param({"256", "384", "521"})
private int keyLength;
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 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
@ -67,7 +67,7 @@ public class KeyPairGeneratorBench extends CryptoBase {
@Param({"EC"})
private String algorithm;
@Param({"160", "224", "256"})
@Param({"256", "384", "521"})
private int keyLength;
}

@ -121,7 +121,7 @@ public class SignatureBench extends CryptoBase {
@Param({"SHA256withECDSA"})
private String algorithm;
@Param({"160", "224", "256"})
@Param({"256"})
private int keyLength;
}