Skip to content

Commit

Permalink
8292498: java/lang/invoke/lambda/LogGeneratedClassesTest.java failed …
Browse files Browse the repository at this point in the history
…with "AssertionError: only show error once expected [1] but found [0]"

Reviewed-by: psandoz, mchung, jpai, rriggs
  • Loading branch information
jddarcy committed Aug 18, 2022
1 parent d00e7b9 commit f567fa0
Show file tree
Hide file tree
Showing 2 changed files with 144 additions and 74 deletions.
217 changes: 144 additions & 73 deletions src/java.base/share/classes/java/lang/reflect/AccessFlag.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,25 @@
*/
@SuppressWarnings("doclint:reference") // cross-module link
public enum AccessFlag {
// Note to maintainers: anonymous class instances are used rather
// than lambdas to initialize the functions used for the
// cffvToLocations field to avoid using lambdas too early in JDK
// initialization.

/**
* The access flag {@code ACC_PUBLIC}, corresponding to the source
* modifier {@link Modifier#PUBLIC public} with a mask value of
* <code>{@value "0x%04x" Modifier#PUBLIC}</code>.
*/
PUBLIC(Modifier.PUBLIC, true,
Location.SET_PUBLIC_1,
cffv -> {
return (cffv == ClassFileFormatVersion.RELEASE_0) ?
Location.SET_CLASS_FIELD_METHOD:
Location.SET_PUBLIC_1;
new Function<ClassFileFormatVersion, Set<Location>>() {
@Override
public Set<Location> apply(ClassFileFormatVersion cffv) {
return (cffv == ClassFileFormatVersion.RELEASE_0) ?
Location.SET_CLASS_FIELD_METHOD:
Location.SET_PUBLIC_1;
}
}),

/**
Expand All @@ -111,10 +119,13 @@ public enum AccessFlag {
* value of <code>{@value "0x%04x" Modifier#PRIVATE}</code>.
*/
PRIVATE(Modifier.PRIVATE, true, Location.SET_FIELD_METHOD_INNER_CLASS,
cffv -> {
return (cffv == ClassFileFormatVersion.RELEASE_0) ?
Location.SET_FIELD_METHOD:
Location.SET_FIELD_METHOD_INNER_CLASS;
new Function<ClassFileFormatVersion, Set<Location>>() {
@Override
public Set<Location> apply(ClassFileFormatVersion cffv) {
return (cffv == ClassFileFormatVersion.RELEASE_0) ?
Location.SET_FIELD_METHOD:
Location.SET_FIELD_METHOD_INNER_CLASS;
}
}),

/**
Expand All @@ -123,19 +134,28 @@ public enum AccessFlag {
* value of <code>{@value "0x%04x" Modifier#PROTECTED}</code>.
*/
PROTECTED(Modifier.PROTECTED, true, Location.SET_FIELD_METHOD_INNER_CLASS,
cffv -> {return (cffv == ClassFileFormatVersion.RELEASE_0) ?
new Function<ClassFileFormatVersion, Set<Location>>() {
@Override
public Set<Location> apply(ClassFileFormatVersion cffv) {
return (cffv == ClassFileFormatVersion.RELEASE_0) ?
Location.SET_FIELD_METHOD:
Location.SET_FIELD_METHOD_INNER_CLASS;}),
Location.SET_FIELD_METHOD_INNER_CLASS;
}
}),

/**
* The access flag {@code ACC_STATIC}, corresponding to the source
* modifier {@link Modifier#STATIC static} with a mask value of
* <code>{@value "0x%04x" Modifier#STATIC}</code>.
*/
STATIC(Modifier.STATIC, true, Location.SET_FIELD_METHOD_INNER_CLASS,
cffv -> {return (cffv == ClassFileFormatVersion.RELEASE_0) ?
Location.SET_FIELD_METHOD:
Location.SET_FIELD_METHOD_INNER_CLASS;}),
new Function<ClassFileFormatVersion, Set<Location>>() {
@Override
public Set<Location> apply(ClassFileFormatVersion cffv) {
return (cffv == ClassFileFormatVersion.RELEASE_0) ?
Location.SET_FIELD_METHOD:
Location.SET_FIELD_METHOD_INNER_CLASS;}
}),

/**
* The access flag {@code ACC_FINAL}, corresponding to the source
Expand All @@ -144,13 +164,16 @@ public enum AccessFlag {
*/
FINAL(Modifier.FINAL, true,
Location.SET_FINAL_8,
cffv -> {
if (cffv.compareTo(ClassFileFormatVersion.RELEASE_8) >= 0) {
return Location.SET_FINAL_8;
} else {
return (cffv == ClassFileFormatVersion.RELEASE_0) ?
Location.SET_CLASS_FIELD_METHOD :
Location.SET_CLASS_FIELD_METHOD_INNER_CLASS;
new Function<ClassFileFormatVersion, Set<Location>>() {
@Override
public Set<Location> apply(ClassFileFormatVersion cffv) {
if (cffv.compareTo(ClassFileFormatVersion.RELEASE_8) >= 0) {
return Location.SET_FINAL_8;
} else {
return (cffv == ClassFileFormatVersion.RELEASE_0) ?
Location.SET_CLASS_FIELD_METHOD :
Location.SET_CLASS_FIELD_METHOD_INNER_CLASS;
}
}
}),

Expand All @@ -170,19 +193,27 @@ public enum AccessFlag {
* @see java.lang.module.ModuleDescriptor#isOpen
*/
OPEN(0x0000_0020, false, Location.SET_MODULE,
cffv -> { return (cffv.compareTo(ClassFileFormatVersion.RELEASE_9) >= 0 ) ?
Location.SET_MODULE:
Location.EMPTY_SET;}),
new Function<ClassFileFormatVersion, Set<Location>>() {
@Override
public Set<Location> apply(ClassFileFormatVersion cffv) {
return (cffv.compareTo(ClassFileFormatVersion.RELEASE_9) >= 0 ) ?
Location.SET_MODULE:
Location.EMPTY_SET;}
}),

/**
* The module requires flag {@code ACC_TRANSITIVE} with a mask
* value of {@code 0x0020}.
* @see java.lang.module.ModuleDescriptor.Requires.Modifier#TRANSITIVE
*/
TRANSITIVE(0x0000_0020, false, Location.SET_MODULE_REQUIRES,
cffv -> {return (cffv.compareTo(ClassFileFormatVersion.RELEASE_9) >= 0 ) ?
Location.SET_MODULE_REQUIRES:
Location.EMPTY_SET;}),
new Function<ClassFileFormatVersion, Set<Location>>() {
@Override
public Set<Location> apply(ClassFileFormatVersion cffv) {
return (cffv.compareTo(ClassFileFormatVersion.RELEASE_9) >= 0 ) ?
Location.SET_MODULE_REQUIRES:
Location.EMPTY_SET;}
}),

/**
* The access flag {@code ACC_SYNCHRONIZED}, corresponding to the
Expand All @@ -197,9 +228,13 @@ public enum AccessFlag {
* @see java.lang.module.ModuleDescriptor.Requires.Modifier#STATIC
*/
STATIC_PHASE(0x0000_0040, false, Location.SET_MODULE_REQUIRES,
cffv -> {return (cffv.compareTo(ClassFileFormatVersion.RELEASE_9) >= 0 ) ?
Location.SET_MODULE_REQUIRES:
Location.EMPTY_SET;}),
new Function<ClassFileFormatVersion, Set<Location>>() {
@Override
public Set<Location> apply(ClassFileFormatVersion cffv) {
return (cffv.compareTo(ClassFileFormatVersion.RELEASE_9) >= 0 ) ?
Location.SET_MODULE_REQUIRES:
Location.EMPTY_SET;}
}),

/**
* The access flag {@code ACC_VOLATILE}, corresponding to the
Expand All @@ -214,9 +249,13 @@ public enum AccessFlag {
* @see Method#isBridge()
*/
BRIDGE(Modifier.BRIDGE, false, Location.SET_METHOD,
cffv -> {return (cffv.compareTo(ClassFileFormatVersion.RELEASE_5) >= 0 ) ?
Location.SET_METHOD:
Location.EMPTY_SET;}),
new Function<ClassFileFormatVersion, Set<Location>>() {
@Override
public Set<Location> apply(ClassFileFormatVersion cffv) {
return (cffv.compareTo(ClassFileFormatVersion.RELEASE_5) >= 0 ) ?
Location.SET_METHOD:
Location.EMPTY_SET;}
}),

/**
* The access flag {@code ACC_TRANSIENT}, corresponding to the
Expand All @@ -231,10 +270,13 @@ public enum AccessFlag {
* @see Executable#isVarArgs()
*/
VARARGS(Modifier.VARARGS, false, Location.SET_METHOD,
cffv -> {return (cffv.compareTo(ClassFileFormatVersion.RELEASE_5) >= 0 ) ?
Location.SET_METHOD:
Location.EMPTY_SET;}),

new Function<ClassFileFormatVersion, Set<Location>>() {
@Override
public Set<Location> apply(ClassFileFormatVersion cffv) {
return (cffv.compareTo(ClassFileFormatVersion.RELEASE_5) >= 0 ) ?
Location.SET_METHOD:
Location.EMPTY_SET;}
}),

/**
* The access flag {@code ACC_NATIVE}, corresponding to the source
Expand All @@ -249,9 +291,13 @@ public enum AccessFlag {
* @see Class#isInterface()
*/
INTERFACE(Modifier.INTERFACE, false, Location.SET_CLASS_INNER_CLASS,
cffv -> { return (cffv.compareTo(ClassFileFormatVersion.RELEASE_0) == 0 ) ?
Location.SET_CLASS:
Location.SET_CLASS_INNER_CLASS;}),
new Function<ClassFileFormatVersion, Set<Location>>() {
@Override
public Set<Location> apply(ClassFileFormatVersion cffv) {
return (cffv.compareTo(ClassFileFormatVersion.RELEASE_0) == 0 ) ?
Location.SET_CLASS:
Location.SET_CLASS_INNER_CLASS;}
}),

/**
* The access flag {@code ACC_ABSTRACT}, corresponding to the
Expand All @@ -260,9 +306,13 @@ public enum AccessFlag {
*/
ABSTRACT(Modifier.ABSTRACT, true,
Location.SET_CLASS_METHOD_INNER_CLASS,
cffv -> { return (cffv.compareTo(ClassFileFormatVersion.RELEASE_0) == 0 ) ?
Location.SET_CLASS_METHOD:
Location.SET_CLASS_METHOD_INNER_CLASS;}),
new Function<ClassFileFormatVersion, Set<Location>>() {
@Override
public Set<Location> apply(ClassFileFormatVersion cffv) {
return (cffv.compareTo(ClassFileFormatVersion.RELEASE_0) == 0 ) ?
Location.SET_CLASS_METHOD:
Location.SET_CLASS_METHOD_INNER_CLASS;}
}),

/**
* The access flag {@code ACC_STRICT}, corresponding to the source
Expand All @@ -275,11 +325,14 @@ public enum AccessFlag {
* corresponding to Java SE 1.2 through 16.
*/
STRICT(Modifier.STRICT, true, Location.SET_METHOD,
cffv -> {return (cffv.compareTo(ClassFileFormatVersion.RELEASE_2) >= 0 &&
cffv.compareTo(ClassFileFormatVersion.RELEASE_16) <= 0) ?
Location.SET_METHOD:
Location.EMPTY_SET;}),

new Function<ClassFileFormatVersion, Set<Location>>() {
@Override
public Set<Location> apply(ClassFileFormatVersion cffv) {
return (cffv.compareTo(ClassFileFormatVersion.RELEASE_2) >= 0 &&
cffv.compareTo(ClassFileFormatVersion.RELEASE_16) <= 0) ?
Location.SET_METHOD:
Location.EMPTY_SET;}
}),

/**
* The access flag {@code ACC_SYNTHETIC} with a mask value of
Expand All @@ -289,16 +342,19 @@ public enum AccessFlag {
* @see java.lang.module.ModuleDescriptor.Modifier#SYNTHETIC
*/
SYNTHETIC(Modifier.SYNTHETIC, false, Location.SET_SYNTHETIC_9,
cffv -> {
if (cffv.compareTo(ClassFileFormatVersion.RELEASE_9) >= 0 )
return Location.SET_SYNTHETIC_9;
else {
return
switch(cffv) {
case RELEASE_7 -> Location.SET_SYNTHETIC_7;
case RELEASE_8 -> Location.SET_SYNTHETIC_8;
default -> Location.EMPTY_SET;
};
new Function<ClassFileFormatVersion, Set<Location>>() {
@Override
public Set<Location> apply(ClassFileFormatVersion cffv) {
if (cffv.compareTo(ClassFileFormatVersion.RELEASE_9) >= 0 )
return Location.SET_SYNTHETIC_9;
else {
return
switch(cffv) {
case RELEASE_7 -> Location.SET_SYNTHETIC_7;
case RELEASE_8 -> Location.SET_SYNTHETIC_8;
default -> Location.EMPTY_SET;
};
}
}
}),

Expand All @@ -308,32 +364,43 @@ public enum AccessFlag {
* @see Class#isAnnotation()
*/
ANNOTATION(Modifier.ANNOTATION, false, Location.SET_CLASS_INNER_CLASS,
cffv -> {return (cffv.compareTo(ClassFileFormatVersion.RELEASE_5) >= 0 ) ?
Location.SET_CLASS_INNER_CLASS:
Location.EMPTY_SET;}),
new Function<ClassFileFormatVersion, Set<Location>>() {
@Override
public Set<Location> apply(ClassFileFormatVersion cffv) {
return (cffv.compareTo(ClassFileFormatVersion.RELEASE_5) >= 0 ) ?
Location.SET_CLASS_INNER_CLASS:
Location.EMPTY_SET;}
}),

/**
* The access flag {@code ACC_ENUM} with a mask value of
* <code>{@value "0x%04x" Modifier#ENUM}</code>.
* @see Class#isEnum()
*/
ENUM(Modifier.ENUM, false, Location.SET_CLASS_FIELD_INNER_CLASS,
cffv -> {return (cffv.compareTo(ClassFileFormatVersion.RELEASE_5) >= 0 ) ?
Location.SET_CLASS_FIELD_INNER_CLASS:
Location.EMPTY_SET;}),
new Function<ClassFileFormatVersion, Set<Location>>() {
@Override
public Set<Location> apply(ClassFileFormatVersion cffv) {
return (cffv.compareTo(ClassFileFormatVersion.RELEASE_5) >= 0 ) ?
Location.SET_CLASS_FIELD_INNER_CLASS:
Location.EMPTY_SET;}
}),

/**
* The access flag {@code ACC_MANDATED} with a mask value of
* <code>{@value "0x%04x" Modifier#MANDATED}</code>.
*/
MANDATED(Modifier.MANDATED, false, Location.SET_MANDATED_9,
cffv -> {
if (cffv.compareTo(ClassFileFormatVersion.RELEASE_9) >= 0 ) {
return Location.SET_MANDATED_9;
} else {
return (cffv == ClassFileFormatVersion.RELEASE_8) ?
Location.SET_METHOD_PARAM:
Location.EMPTY_SET;
new Function<ClassFileFormatVersion, Set<Location>>() {
@Override
public Set<Location> apply(ClassFileFormatVersion cffv) {
if (cffv.compareTo(ClassFileFormatVersion.RELEASE_9) >= 0 ) {
return Location.SET_MANDATED_9;
} else {
return (cffv == ClassFileFormatVersion.RELEASE_8) ?
Location.SET_METHOD_PARAM:
Location.EMPTY_SET;
}
}
}),

Expand All @@ -342,9 +409,13 @@ public enum AccessFlag {
* 0x8000}.
*/
MODULE(0x0000_8000, false, Location.SET_CLASS,
cffv -> {return (cffv.compareTo(ClassFileFormatVersion.RELEASE_9) >= 0 ) ?
Location.SET_CLASS:
Location.EMPTY_SET;})
new Function<ClassFileFormatVersion, Set<Location>>() {
@Override
public Set<Location> apply(ClassFileFormatVersion cffv) {
return (cffv.compareTo(ClassFileFormatVersion.RELEASE_9) >= 0 ) ?
Location.SET_CLASS:
Location.EMPTY_SET;}
})
;

// May want to override toString for a different enum constant ->
Expand Down
1 change: 0 additions & 1 deletion test/jdk/ProblemList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,6 @@ java/lang/invoke/LFCaching/LFGarbageCollectedTest.java 8078602 generic-
java/lang/invoke/lambda/LambdaFileEncodingSerialization.java 8249079 linux-x64
java/lang/invoke/RicochetTest.java 8251969 generic-all
java/lang/ProcessBuilder/PipelineLeaksFD.java 8291760 linux-all
java/lang/invoke/lambda/LogGeneratedClassesTest.java 8292498 windows-x64

############################################################################

Expand Down

1 comment on commit f567fa0

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.