Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8344541: [lworld] jdk/tools/sincechecker/modules/java_base/CheckSince_javaBase.java finds "@since" version errors #1312

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/java.base/share/classes/java/lang/reflect/AccessFlag.java
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,8 @@ public static Set<AccessFlag> maskToAccessFlags(int mask, Location location) {
* @param cffv the class file format version
* @throws IllegalArgumentException if the mask contains bit
* positions not supported for the location in question
*
* @since Valhalla
*/
public static Set<AccessFlag> maskToAccessFlags(int mask, Location location,
ClassFileFormatVersion cffv) {
Expand Down
1 change: 1 addition & 0 deletions src/java.base/share/classes/java/util/Objects.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ public static String toIdentityString(Object o) {
*
* @param obj an object
* @throws NullPointerException if {@code obj} is {@code null}
* @since Valhalla
*/
@PreviewFeature(feature = PreviewFeature.Feature.VALUE_OBJECTS)
// @IntrinsicCandidate
Expand Down
5 changes: 5 additions & 0 deletions src/java.base/share/classes/java/util/WeakHashMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ public WeakHashMap(int initialCapacity, float loadFactor) {
* @throws IllegalArgumentException if the initial capacity is negative,
* or if the load factor is nonpositive.
* @throws NullPointerException if {@code valuePolicy} is null
* @since Valhalla
*/
public WeakHashMap(int initialCapacity, float loadFactor, ValuePolicy valuePolicy) {
if (initialCapacity < 0)
Expand Down Expand Up @@ -301,6 +302,8 @@ public WeakHashMap() {
*
* @param valuePolicy The {@link ValuePolicy} for keys that are value objects; non-null
* @throws NullPointerException if {@code valuePolicy} is null
*
* @since Valhalla
*/
public WeakHashMap(ValuePolicy valuePolicy) {
this(DEFAULT_INITIAL_CAPACITY, DEFAULT_LOAD_FACTOR, valuePolicy);
Expand Down Expand Up @@ -328,6 +331,8 @@ public WeakHashMap(Map<? extends K, ? extends V> m) {

/**
* {@return the {@link ValuePolicy} for this WeakHashMap.}
*
* @since Valhalla
*/
public ValuePolicy valuePolicy() {
return valuePolicy;
Expand Down
1 change: 0 additions & 1 deletion test/jdk/ProblemList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -839,4 +839,3 @@ java/awt/dnd/WinMoveFileToShellTest.java 8341665 windows-all

# valhalla
jdk/jfr/event/runtime/TestSyncOnValueBasedClassEvent.java 8328777 generic-all
tools/sincechecker/modules/java_base/CheckSince_javaBase.java 8344541 generic-all
22 changes: 20 additions & 2 deletions test/jdk/tools/sincechecker/SinceChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,12 @@ of its enclosing class or interface, whether direct or inherited
it is somewhat inspired from the VM Method Descriptors. But we use the erased return so that methods
that were later generified remain the same.

To help projects still in development, unsure of actual `@since` tag value, one may want to use token name instead of continuely
updating the current version since tags. For example, `@since LongRunningProjectName`. The option `--ignoreSince` maybe used to
ignore these tags (`--ignoreSince LongRunningProjectName`). Maybe be specified multiple times.

usage: the checker is run from a module specific test
`@run main SinceChecker <moduleName> [--exclude package1,package2 | --exclude package1 package2]`
`@run main SinceChecker <moduleName> [--ignoreSince <string>] [--exclude package1,package2 | --exclude package1 package2]`
*/

public class SinceChecker {
Expand All @@ -111,6 +115,11 @@ public class SinceChecker {
private final JavaCompiler tool;
private int errorCount = 0;

// Ignored since tags
private static final Set<String> IGNORE_SINCE = new HashSet<>();
// Simply replace ignored since tags with the latest version
private static final Version IGNORE_VERSION = Version.parse(Integer.toString(Runtime.version().major()));

// packages to skip during the test
private static final Set<String> EXCLUDE_LIST = new HashSet<>();

Expand All @@ -127,7 +136,11 @@ public static void main(String[] args) throws Exception {
boolean excludeFlag = false;

for (int i = 1; i < args.length; i++) {
if ("--exclude".equals(args[i])) {
if ("--ignoreSince".equals(args[i])) {
i++;
IGNORE_SINCE.add("@since " + args[i]);
}
else if ("--exclude".equals(args[i])) {
excludeFlag = true;
continue;
}
Expand Down Expand Up @@ -452,6 +465,11 @@ private void checkElement(Element explicitOwner, Element element, Types types,
}

private Version extractSinceVersionFromText(String documentation) {
for (String ignoreSince : IGNORE_SINCE) {
if (documentation.contains(ignoreSince)) {
return IGNORE_VERSION;
}
}
Pattern pattern = Pattern.compile("@since\\s+(\\d+(?:\\.\\d+)?)");
Matcher matcher = pattern.matcher(documentation);
if (matcher.find()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@
* @modules jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.util
* jdk.compiler/com.sun.tools.javac.code
* @run main SinceChecker java.base --exclude java.lang.classfile
* @run main SinceChecker java.base --ignoreSince Valhalla --exclude java.lang.classfile
*/