8292498: java/lang/invoke/lambda/LogGeneratedClassesTest.java failed with "AssertionError: only show error once expected [1] but found [0]"

Reviewed-by: psandoz, mchung, jpai, rriggs
This commit is contained in:
Joe Darcy 2022-08-18 16:09:26 +00:00
parent d00e7b92b4
commit f567fa0fd5
2 changed files with 144 additions and 74 deletions

View File

@ -92,6 +92,11 @@ import static java.util.Map.entry;
*/ */
@SuppressWarnings("doclint:reference") // cross-module link @SuppressWarnings("doclint:reference") // cross-module link
public enum AccessFlag { 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 * The access flag {@code ACC_PUBLIC}, corresponding to the source
* modifier {@link Modifier#PUBLIC public} with a mask value of * modifier {@link Modifier#PUBLIC public} with a mask value of
@ -99,10 +104,13 @@ public enum AccessFlag {
*/ */
PUBLIC(Modifier.PUBLIC, true, PUBLIC(Modifier.PUBLIC, true,
Location.SET_PUBLIC_1, Location.SET_PUBLIC_1,
cffv -> { new Function<ClassFileFormatVersion, Set<Location>>() {
return (cffv == ClassFileFormatVersion.RELEASE_0) ? @Override
Location.SET_CLASS_FIELD_METHOD: public Set<Location> apply(ClassFileFormatVersion cffv) {
Location.SET_PUBLIC_1; return (cffv == ClassFileFormatVersion.RELEASE_0) ?
Location.SET_CLASS_FIELD_METHOD:
Location.SET_PUBLIC_1;
}
}), }),
/** /**
@ -111,10 +119,13 @@ public enum AccessFlag {
* value of <code>{@value "0x%04x" Modifier#PRIVATE}</code>. * value of <code>{@value "0x%04x" Modifier#PRIVATE}</code>.
*/ */
PRIVATE(Modifier.PRIVATE, true, Location.SET_FIELD_METHOD_INNER_CLASS, PRIVATE(Modifier.PRIVATE, true, Location.SET_FIELD_METHOD_INNER_CLASS,
cffv -> { new Function<ClassFileFormatVersion, Set<Location>>() {
return (cffv == ClassFileFormatVersion.RELEASE_0) ? @Override
Location.SET_FIELD_METHOD: public Set<Location> apply(ClassFileFormatVersion cffv) {
Location.SET_FIELD_METHOD_INNER_CLASS; return (cffv == ClassFileFormatVersion.RELEASE_0) ?
Location.SET_FIELD_METHOD:
Location.SET_FIELD_METHOD_INNER_CLASS;
}
}), }),
/** /**
@ -123,9 +134,14 @@ public enum AccessFlag {
* value of <code>{@value "0x%04x" Modifier#PROTECTED}</code>. * value of <code>{@value "0x%04x" Modifier#PROTECTED}</code>.
*/ */
PROTECTED(Modifier.PROTECTED, true, Location.SET_FIELD_METHOD_INNER_CLASS, 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:
Location.SET_FIELD_METHOD_INNER_CLASS;}), Location.SET_FIELD_METHOD_INNER_CLASS;
}
}),
/** /**
* The access flag {@code ACC_STATIC}, corresponding to the source * The access flag {@code ACC_STATIC}, corresponding to the source
@ -133,9 +149,13 @@ public enum AccessFlag {
* <code>{@value "0x%04x" Modifier#STATIC}</code>. * <code>{@value "0x%04x" Modifier#STATIC}</code>.
*/ */
STATIC(Modifier.STATIC, true, Location.SET_FIELD_METHOD_INNER_CLASS, STATIC(Modifier.STATIC, true, Location.SET_FIELD_METHOD_INNER_CLASS,
cffv -> {return (cffv == ClassFileFormatVersion.RELEASE_0) ? new Function<ClassFileFormatVersion, Set<Location>>() {
Location.SET_FIELD_METHOD: @Override
Location.SET_FIELD_METHOD_INNER_CLASS;}), 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 * The access flag {@code ACC_FINAL}, corresponding to the source
@ -144,13 +164,16 @@ public enum AccessFlag {
*/ */
FINAL(Modifier.FINAL, true, FINAL(Modifier.FINAL, true,
Location.SET_FINAL_8, Location.SET_FINAL_8,
cffv -> { new Function<ClassFileFormatVersion, Set<Location>>() {
if (cffv.compareTo(ClassFileFormatVersion.RELEASE_8) >= 0) { @Override
return Location.SET_FINAL_8; public Set<Location> apply(ClassFileFormatVersion cffv) {
} else { if (cffv.compareTo(ClassFileFormatVersion.RELEASE_8) >= 0) {
return (cffv == ClassFileFormatVersion.RELEASE_0) ? return Location.SET_FINAL_8;
Location.SET_CLASS_FIELD_METHOD : } else {
Location.SET_CLASS_FIELD_METHOD_INNER_CLASS; return (cffv == ClassFileFormatVersion.RELEASE_0) ?
Location.SET_CLASS_FIELD_METHOD :
Location.SET_CLASS_FIELD_METHOD_INNER_CLASS;
}
} }
}), }),
@ -170,9 +193,13 @@ public enum AccessFlag {
* @see java.lang.module.ModuleDescriptor#isOpen * @see java.lang.module.ModuleDescriptor#isOpen
*/ */
OPEN(0x0000_0020, false, Location.SET_MODULE, OPEN(0x0000_0020, false, Location.SET_MODULE,
cffv -> { return (cffv.compareTo(ClassFileFormatVersion.RELEASE_9) >= 0 ) ? new Function<ClassFileFormatVersion, Set<Location>>() {
Location.SET_MODULE: @Override
Location.EMPTY_SET;}), 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 * The module requires flag {@code ACC_TRANSITIVE} with a mask
@ -180,9 +207,13 @@ public enum AccessFlag {
* @see java.lang.module.ModuleDescriptor.Requires.Modifier#TRANSITIVE * @see java.lang.module.ModuleDescriptor.Requires.Modifier#TRANSITIVE
*/ */
TRANSITIVE(0x0000_0020, false, Location.SET_MODULE_REQUIRES, TRANSITIVE(0x0000_0020, false, Location.SET_MODULE_REQUIRES,
cffv -> {return (cffv.compareTo(ClassFileFormatVersion.RELEASE_9) >= 0 ) ? new Function<ClassFileFormatVersion, Set<Location>>() {
Location.SET_MODULE_REQUIRES: @Override
Location.EMPTY_SET;}), 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 * The access flag {@code ACC_SYNCHRONIZED}, corresponding to the
@ -197,9 +228,13 @@ public enum AccessFlag {
* @see java.lang.module.ModuleDescriptor.Requires.Modifier#STATIC * @see java.lang.module.ModuleDescriptor.Requires.Modifier#STATIC
*/ */
STATIC_PHASE(0x0000_0040, false, Location.SET_MODULE_REQUIRES, STATIC_PHASE(0x0000_0040, false, Location.SET_MODULE_REQUIRES,
cffv -> {return (cffv.compareTo(ClassFileFormatVersion.RELEASE_9) >= 0 ) ? new Function<ClassFileFormatVersion, Set<Location>>() {
Location.SET_MODULE_REQUIRES: @Override
Location.EMPTY_SET;}), 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 * The access flag {@code ACC_VOLATILE}, corresponding to the
@ -214,9 +249,13 @@ public enum AccessFlag {
* @see Method#isBridge() * @see Method#isBridge()
*/ */
BRIDGE(Modifier.BRIDGE, false, Location.SET_METHOD, BRIDGE(Modifier.BRIDGE, false, Location.SET_METHOD,
cffv -> {return (cffv.compareTo(ClassFileFormatVersion.RELEASE_5) >= 0 ) ? new Function<ClassFileFormatVersion, Set<Location>>() {
Location.SET_METHOD: @Override
Location.EMPTY_SET;}), 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 * The access flag {@code ACC_TRANSIENT}, corresponding to the
@ -231,10 +270,13 @@ public enum AccessFlag {
* @see Executable#isVarArgs() * @see Executable#isVarArgs()
*/ */
VARARGS(Modifier.VARARGS, false, Location.SET_METHOD, VARARGS(Modifier.VARARGS, false, Location.SET_METHOD,
cffv -> {return (cffv.compareTo(ClassFileFormatVersion.RELEASE_5) >= 0 ) ? new Function<ClassFileFormatVersion, Set<Location>>() {
Location.SET_METHOD: @Override
Location.EMPTY_SET;}), 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 * The access flag {@code ACC_NATIVE}, corresponding to the source
@ -249,9 +291,13 @@ public enum AccessFlag {
* @see Class#isInterface() * @see Class#isInterface()
*/ */
INTERFACE(Modifier.INTERFACE, false, Location.SET_CLASS_INNER_CLASS, INTERFACE(Modifier.INTERFACE, false, Location.SET_CLASS_INNER_CLASS,
cffv -> { return (cffv.compareTo(ClassFileFormatVersion.RELEASE_0) == 0 ) ? new Function<ClassFileFormatVersion, Set<Location>>() {
Location.SET_CLASS: @Override
Location.SET_CLASS_INNER_CLASS;}), 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 * The access flag {@code ACC_ABSTRACT}, corresponding to the
@ -260,9 +306,13 @@ public enum AccessFlag {
*/ */
ABSTRACT(Modifier.ABSTRACT, true, ABSTRACT(Modifier.ABSTRACT, true,
Location.SET_CLASS_METHOD_INNER_CLASS, Location.SET_CLASS_METHOD_INNER_CLASS,
cffv -> { return (cffv.compareTo(ClassFileFormatVersion.RELEASE_0) == 0 ) ? new Function<ClassFileFormatVersion, Set<Location>>() {
Location.SET_CLASS_METHOD: @Override
Location.SET_CLASS_METHOD_INNER_CLASS;}), 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 * The access flag {@code ACC_STRICT}, corresponding to the source
@ -275,11 +325,14 @@ public enum AccessFlag {
* corresponding to Java SE 1.2 through 16. * corresponding to Java SE 1.2 through 16.
*/ */
STRICT(Modifier.STRICT, true, Location.SET_METHOD, STRICT(Modifier.STRICT, true, Location.SET_METHOD,
cffv -> {return (cffv.compareTo(ClassFileFormatVersion.RELEASE_2) >= 0 && new Function<ClassFileFormatVersion, Set<Location>>() {
cffv.compareTo(ClassFileFormatVersion.RELEASE_16) <= 0) ? @Override
Location.SET_METHOD: public Set<Location> apply(ClassFileFormatVersion cffv) {
Location.EMPTY_SET;}), 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 * The access flag {@code ACC_SYNTHETIC} with a mask value of
@ -289,16 +342,19 @@ public enum AccessFlag {
* @see java.lang.module.ModuleDescriptor.Modifier#SYNTHETIC * @see java.lang.module.ModuleDescriptor.Modifier#SYNTHETIC
*/ */
SYNTHETIC(Modifier.SYNTHETIC, false, Location.SET_SYNTHETIC_9, SYNTHETIC(Modifier.SYNTHETIC, false, Location.SET_SYNTHETIC_9,
cffv -> { new Function<ClassFileFormatVersion, Set<Location>>() {
if (cffv.compareTo(ClassFileFormatVersion.RELEASE_9) >= 0 ) @Override
return Location.SET_SYNTHETIC_9; public Set<Location> apply(ClassFileFormatVersion cffv) {
else { if (cffv.compareTo(ClassFileFormatVersion.RELEASE_9) >= 0 )
return return Location.SET_SYNTHETIC_9;
switch(cffv) { else {
case RELEASE_7 -> Location.SET_SYNTHETIC_7; return
case RELEASE_8 -> Location.SET_SYNTHETIC_8; switch(cffv) {
default -> Location.EMPTY_SET; case RELEASE_7 -> Location.SET_SYNTHETIC_7;
}; case RELEASE_8 -> Location.SET_SYNTHETIC_8;
default -> Location.EMPTY_SET;
};
}
} }
}), }),
@ -308,9 +364,13 @@ public enum AccessFlag {
* @see Class#isAnnotation() * @see Class#isAnnotation()
*/ */
ANNOTATION(Modifier.ANNOTATION, false, Location.SET_CLASS_INNER_CLASS, ANNOTATION(Modifier.ANNOTATION, false, Location.SET_CLASS_INNER_CLASS,
cffv -> {return (cffv.compareTo(ClassFileFormatVersion.RELEASE_5) >= 0 ) ? new Function<ClassFileFormatVersion, Set<Location>>() {
Location.SET_CLASS_INNER_CLASS: @Override
Location.EMPTY_SET;}), 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 * The access flag {@code ACC_ENUM} with a mask value of
@ -318,22 +378,29 @@ public enum AccessFlag {
* @see Class#isEnum() * @see Class#isEnum()
*/ */
ENUM(Modifier.ENUM, false, Location.SET_CLASS_FIELD_INNER_CLASS, ENUM(Modifier.ENUM, false, Location.SET_CLASS_FIELD_INNER_CLASS,
cffv -> {return (cffv.compareTo(ClassFileFormatVersion.RELEASE_5) >= 0 ) ? new Function<ClassFileFormatVersion, Set<Location>>() {
Location.SET_CLASS_FIELD_INNER_CLASS: @Override
Location.EMPTY_SET;}), 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 * The access flag {@code ACC_MANDATED} with a mask value of
* <code>{@value "0x%04x" Modifier#MANDATED}</code>. * <code>{@value "0x%04x" Modifier#MANDATED}</code>.
*/ */
MANDATED(Modifier.MANDATED, false, Location.SET_MANDATED_9, MANDATED(Modifier.MANDATED, false, Location.SET_MANDATED_9,
cffv -> { new Function<ClassFileFormatVersion, Set<Location>>() {
if (cffv.compareTo(ClassFileFormatVersion.RELEASE_9) >= 0 ) { @Override
return Location.SET_MANDATED_9; public Set<Location> apply(ClassFileFormatVersion cffv) {
} else { if (cffv.compareTo(ClassFileFormatVersion.RELEASE_9) >= 0 ) {
return (cffv == ClassFileFormatVersion.RELEASE_8) ? return Location.SET_MANDATED_9;
Location.SET_METHOD_PARAM: } else {
Location.EMPTY_SET; return (cffv == ClassFileFormatVersion.RELEASE_8) ?
Location.SET_METHOD_PARAM:
Location.EMPTY_SET;
}
} }
}), }),
@ -342,9 +409,13 @@ public enum AccessFlag {
* 0x8000}. * 0x8000}.
*/ */
MODULE(0x0000_8000, false, Location.SET_CLASS, MODULE(0x0000_8000, false, Location.SET_CLASS,
cffv -> {return (cffv.compareTo(ClassFileFormatVersion.RELEASE_9) >= 0 ) ? new Function<ClassFileFormatVersion, Set<Location>>() {
Location.SET_CLASS: @Override
Location.EMPTY_SET;}) 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 -> // May want to override toString for a different enum constant ->

View File

@ -496,7 +496,6 @@ java/lang/invoke/LFCaching/LFGarbageCollectedTest.java 8078602 generic-
java/lang/invoke/lambda/LambdaFileEncodingSerialization.java 8249079 linux-x64 java/lang/invoke/lambda/LambdaFileEncodingSerialization.java 8249079 linux-x64
java/lang/invoke/RicochetTest.java 8251969 generic-all java/lang/invoke/RicochetTest.java 8251969 generic-all
java/lang/ProcessBuilder/PipelineLeaksFD.java 8291760 linux-all java/lang/ProcessBuilder/PipelineLeaksFD.java 8291760 linux-all
java/lang/invoke/lambda/LogGeneratedClassesTest.java 8292498 windows-x64
############################################################################ ############################################################################